eslint-plugin-project v0.2.2
eslint-plugin-project
This ESLint plugin allows you load project-scope ESLint rules.
Install
npm i -D eslint-plugin-projector
yarn add --dev eslint-plugin-projectUsage
You must put your rules definition files somewhere.
By default, this plugin will look up tools/eslint-rules directory.
For example, we put some rules in eslint/rules of your current working directory.
Now we configure our ESLint config file like this:
{
"settings": {
"projectRulesDir": "eslint/rules"
}
}That is, we tell the plugin to search the rules in eslint/rules directory.
The path can be absulote or relative (to current working directory).
Note that the projectRulesDir can be an array if you want to specify multiple directories.
Next enable this plugin in ESLint config file:
{
"plugins": ["project"],
"settings": {
"projectRulesDir": "eslint/rules"
}
}Now you can use your rules:
{
"plugins": ["project"],
"settings": {
"projectRulesDir": "eslint/rules"
},
"rules": {
"project/my-internal-rule": 2
}
}Comparsion
This plugin is inspired from
eslint-plugin-rulesdir. However,eslint-plugin-rulesdirisn't friendly for static ESLint config file. (You must use.eslintrc.jsfile and set a property in JavaScript runtime.) Andeslint-plugin-rulesdirhas issue with Visual Studio Code integration. If you don't mind the format of ESLint config file and doesn't care about the integration with VS Code, you still can use this plugin, andeslint-plugin-rulesdiris used in ESLint official repository.eslint-plugin-local-rulesdoesn't allow you to customize your local rules path. And, you only can put all your rules in one file, which troubles project management.
License
MIT License (c) 2019-present Pig Fang