This is just an experimental eslint plugin, to test my knowledge on AST, parsers, and eslint plugins in general.
it handles a few interesting challenges you can face when creating a plugin:
- scope navigation (up/down the tree)
- type comparison in JS
- strict vs non strict mode
Check the tests file to understand the scenarios when the plugin would report an error.
If you are considering using a plugin like that, my advice would be to take a look at a type system.
You'll first need to install ESLint:
npm i eslint --save-devNext, clone this repository and create a local link
yarn linkand the following command in the project you would like to test it:
yarn link eslint-plugin-better-js-codeAdd better-js-code to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:
{
"plugins": [
"better-js-code"
]
}Then configure the rules you want to use under the rules section.
{
"rules": {
"better-js-code/no-diff-variable-types": 2
}
}- Fill in provided rules here