{"id":13684336,"url":"https://github.com/withspectrum/danger-plugin-labels","last_synced_at":"2025-04-30T20:33:49.227Z","repository":{"id":49003890,"uuid":"125519919","full_name":"withspectrum/danger-plugin-labels","owner":"withspectrum","description":"Let any contributor add labels to their PRs and issues","archived":true,"fork":false,"pushed_at":"2021-07-01T09:45:16.000Z","size":251,"stargazers_count":16,"open_issues_count":14,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-22T16:50:44.505Z","etag":null,"topics":["danger","danger-plugin"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/withspectrum.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-16T13:28:37.000Z","updated_at":"2023-08-15T16:23:29.000Z","dependencies_parsed_at":"2022-09-07T14:00:40.512Z","dependency_job_id":null,"html_url":"https://github.com/withspectrum/danger-plugin-labels","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/withspectrum%2Fdanger-plugin-labels","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/withspectrum%2Fdanger-plugin-labels/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/withspectrum%2Fdanger-plugin-labels/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/withspectrum%2Fdanger-plugin-labels/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/withspectrum","download_url":"https://codeload.github.com/withspectrum/danger-plugin-labels/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251777736,"owners_count":21642215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["danger","danger-plugin"],"created_at":"2024-08-02T14:00:32.353Z","updated_at":"2025-04-30T20:33:48.752Z","avatar_url":"https://github.com/withspectrum.png","language":"TypeScript","funding_links":[],"categories":["Plugins"],"sub_categories":["TypeScript (danger-js)"],"readme":"# danger-plugin-labels\n\n[![Build Status](https://travis-ci.org/withspectrum/danger-plugin-labels.svg?branch=master)](https://travis-ci.org/withspectrum/danger-plugin-labels)\n[![npm version](https://badge.fury.io/js/danger-plugin-labels.svg)](https://badge.fury.io/js/danger-plugin-labels)\n\n\u003e Let any contributor add labels to their pull requests and issues\n\n## Usage\n\nInstall:\n\n```sh\nyarn add danger-plugin-labels --dev\n```\n\nAt a glance:\n\n```js\n// dangerfile.js\nimport { schedule } from 'danger'\nimport labels from 'danger-plugin-labels'\n\nschedule(labels({\n  rules: [\n    { match: /WIP/i, label: 'Work In Progress' },\n    { match: /Ready for Review/i, label: 'Ready for Review' }\n  ]\n}))\n```\n\n```markdown\n\u003c!-- PULL_REQUEST_TEMPLATE.md --\u003e\n\n**Status (check one)**\n\n- [ ] WIP\n- [ ] Ready for Review\n```\n\nNow contributors even without write access to the repo can label their PR as \"Work In Progress\" and \"Ready for Review\"!\n\n\u003e Note: There is experimental issue support if you're using [Peril](https://github.com/danger/peril) and point the `issue` event hook to your Dangerfile. No guarantees it won't break though!\n\n### Options\n\n#### `rules` (required)\n\nRules lets you specify which labels to apply depending on which checkboxes are ticked:\n\n```js\nschedule(labels({\n  // A checked box with \"WIP\" will apply the \"Work In Progress\" label\n  rules: [{\n    match: /WIP/i,\n    label: \"Work In Progress\"\n  }]\n}))\n```\n\nBecause it's tedious to repeat the same string twice if the label matches the checkbox, you can also provide the shorthand notation:\n\n```js\nschedule(labels({\n  // A checked box with \"WIP\" will apply the \"WIP\" label\n  rules: [\"WIP\"]\n}))\n```\n\n\u003e Note: The checkbox text in this case is case insensitive (`wip`, `Wip` and `WIP` in the markdown would all apply the label), but the label content isn't. (GitHub treats \"WIP\" as a separate label than \"wip\", make sure to match the text exactly!)\n\n#### `validate`\n\nA function that's called with all the matching labels, allowing you to accept or reject them by returnng `true` or `false`, respectively. This is useful for a number of things, for example to limit the maximum number of labels selected:\n\n\n```js\nimport { fail } from 'danger';\n\nschedule(labels({\n  rules: [/* ... */],\n  validate: (labels) =\u003e {\n    if (labels.length \u003c 1 || labels.length \u003e 3) {\n      fail('Please specify at least one and at most 3 labels.');\n      return false;\n    }\n\n    return true;\n  }\n}))\n```\n\nThis method can also be asynchronous so you can do all sorts of cool stuff, like close issues that users want to label as questions:\n\n```js\nimport { fail } from 'danger';\n\nschedule(labels({\n  rules: [/* ... */],\n  validate: async (labels) =\u003e {\n    if (labels.includes('Question')) {\n      fail('Please direct questions to the community on Spectrum.')\n      await closeIssue();\n      return false;\n    }\n    return true;\n  }\n}))\n```\n\n## Changelog\n\nSee the GitHub [release history](https://github.com/withspectrum/danger-plugin-labels/releases).\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwithspectrum%2Fdanger-plugin-labels","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwithspectrum%2Fdanger-plugin-labels","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwithspectrum%2Fdanger-plugin-labels/lists"}