eslint-plugin-highlight-temporary-code v1.0.0
eslint-plugin-temporary-code
Problem :
Sometimes during development, we might change a dynamic logic to something static for testing out different scenarios without relying upon the application state.
What if we forget to revoke those temporary changes and unfortunately there is no unit test cases to catch it?
This plugin would help you remember those temporary code by throwing a eslint warning on it.
How it works
It searches for comments containing
@temp and warns about it. The user is expected to add a line of comment that contains @temp above or below his temporary code so that the plugin highlights it until its gone.
Installation
You'll first need to install ESLint:
npm i -D eslintNext, install eslint-plugin-temporary-code:
npm i -D eslint-plugin-temporary-codeUsage
Add temporary-code to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:
{
"plugins": [
"highlight-temporary-code"
]
}Then configure the rule under the rules section.
{
"rules": {
"highlight-temporary-code/check-for-temporary-code": "warn"
}
}Example code :
In the code, while entering the temporary code statement add the comment
@temp above or below it.
Let say,if we temporarily replace the below
const isPresent = someFunctioThatReturnsTrueOrFalse()with
const isPresent = falsethen replace it like
// @temp
const isPresent = falseor
/* @temp */
const isPresent = falseso that the plugin would know that this is the temporary code and throws a eslint warning.
Note :
It works in jsx with
{/* @temp */}
3 years ago