ESLint plugin for enforcing naming conventions on variables and function names.
You'll first need to install ESLint and @typescript-eslint/parser:
npm i -D eslint @typescript-eslint/parser
Next, install eslint-plugin-naming-convention
:
npm i -D eslint-plugin-naming-convention
Add eslint-plugin-naming-convention
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": ["naming-convention"]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"naming-convention/boolean-var-naming-convention": [
"error",
{
"prefixes": ["is", "has"]
}
]
}
}
Because the rules internally requires the generation of parseServices
, it is necessary to set parserOptions.project
for @typescript-eslint/parser
.
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
}
}
🔧 Automatically fixable by the --fix
CLI option.
💡 Manually fixable by editor suggestions.
Name | Description | 🔧 | 💡 |
---|---|---|---|
boolean-var-naming-convention | Enforce the addition of a specified prefix to boolean variable names | 🔧 | 💡 |
eslint-plugin-naming-convention
is licensed under the MIT License.