"There is nothing more permanent than a temporary fix."
- Rule details
- Patterns considered warnings/errors
- Patterns not considered warnings/errors
- Installation
- Options
We've all been there: there's a fix coming in soon, but it's currently a blocker, and there's just a little hack needed today, which you can fix up later.
What about that PR that exposed some needed maintenance tasks, but you didn't want to junk up/confuse the diffs, so you said that work would happen "... in a future pull request."
With 100% good intentions, there's still a pretty good chance your codebase has that little hack, and that second PR just hasn't made it yet.
The @removeby annotation allows you to leave a toolable and human-readable task for a later date. Like a TODO comment that reminds you it exists without you having to dig it back out.
It might be a fix that needs to happen once some other code has been merged in, it might be a deprecated API that's scheduled to go away, or maybe it's something to fix right after this next sprint.
Whatever it is, slap a @removeby annotation on it to make sure you get reminded when it's time is up.
// @removeby 12/21/2018 dev@example.com Remove after snow.
Assuming the current date is 8/1/2018.
celebrate(); // @removeby 7/5/2018 dev@example.com Remove after July 4th sale.
/*
* @removeby 7/5/2018 dev@example.com Remove after 4th of July sale.
*/
celebrate();
// Will error because of malformed date and email.
celebrate(); // @removeby a/b/cc @example.com Bad format :(
Assuming the current date is 12/20/2017.
celebrate(); // @removeby 7/5/2018 dev@example.com Remove after July 4th sale.
/*
* @removeby 7/5/2018 dev@example.com Remove after 4th of July sale.
*/
celebrate();
Install the pocket-fluff eslint plugin in your project.
# NPM
npm install eslint-plugin-pocket-fluff --dev
# Yarn
yarn add eslint-plugin-pocket-fluff --dev
Enable the plugin and the rule in your .eslintrc (or other config) file.
{
"plugins": ["pocket-fluff"],
"rules": {
"pocket-fluff/no-dead-code": "error"
}
}
The rule takes a single, optional, options object with the properties and default values shown:
{
"rules": {
"pocket-fluff/no-dead-code": [
"error",
{
"currentEpochTimeMS": Date.now(), // For testing or decoupling from system time.
"daysBeforeToReport": 0, // For warning/email pass X days before removeby.
"annotation": '@removeby' // For renaming the annotation. String form of regex match.
}
],
}
}