
Security News
PodRocket Podcast: Inside the Recent npm Supply Chain Attacks
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
danger-plugin-labels
Advanced tools
Let any contributor (even without write permissions) add labels to their pull requests
Let any contributor add labels to their pull requests and issues
Install:
yarn add danger-plugin-labels --dev
At a glance:
// dangerfile.js
import { schedule } from 'danger'
import labels from 'danger-plugin-labels'
schedule(labels({
rules: [
{ match: /WIP/i, label: 'Work In Progress' },
{ match: /Ready for Review/i, label: 'Ready for Review' }
]
}))
<!-- PULL_REQUEST_TEMPLATE.md -->
**Status (check one)**
- [ ] WIP
- [ ] Ready for Review
Now contributors even without write access to the repo can label their PR as "Work In Progress" and "Ready for Review"!
Note: There is experimental issue support if you're using Peril and point the
issue
event hook to your Dangerfile. No guarantees it won't break though!
rules
(required)Rules lets you specify which labels to apply depending on which checkboxes are ticked:
schedule(labels({
// A checked box with "WIP" will apply the "Work In Progress" label
rules: [{
match: /WIP/i,
label: "Work In Progress"
}]
}))
Because it's tedious to repeat the same string twice if the label matches the checkbox, you can also provide the shorthand notation:
schedule(labels({
// A checked box with "WIP" will apply the "WIP" label
rules: ["WIP"]
}))
Note: The checkbox text in this case is case insensitive (
wip
,Wip
andWIP
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!)
validate
A 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:
import { fail } from 'danger';
schedule(labels({
rules: [/* ... */],
validate: (labels) => {
if (labels.length < 1 || labels.length > 3) {
fail('Please specify at least one and at most 3 labels.');
return false;
}
return true;
}
}))
This method can also be asynchronous so you can do all sorts of cool stuff, like close issues that users want to label as questions:
import { fail } from 'danger';
schedule(labels({
rules: [/* ... */],
validate: async (labels) => {
if (labels.includes('Question')) {
fail('Please direct questions to the community on Spectrum.')
await closeIssue();
return false;
}
return true;
}
}))
See the GitHub release history.
See CONTRIBUTING.md.
FAQs
Let any contributor (even without write permissions) add labels to their pull requests
We found that danger-plugin-labels demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.