A plugin providing a rule that enforces a naming convention for top-level constants.
You'll first need to install ESLint:
npm i eslint --save-dev
Next, install eslint-plugin-top-level-constant-naming
:
npm install eslint-plugin-top-level-constant-naming --save-dev
Add top-level-constant-naming
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": [
"top-level-constant-naming"
]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"top-level-constant-naming/top-level-constant-naming": [
"warning",
{
"casing": "camelCase",
"pattern": "**/index.ts",
"skipDeclarationTypes": ["function"]
}
]
}
}
top-level-constant-naming/top-level-constant-naming
{
"top-level-constant-naming/top-level-constant-naming": [
"error",
{
"casing": "camelCase",
"pattern": "**/index.ts",
"skipDeclarationTypes": ["function"]
}
]
}
Options can be any of the following properties:
casing
: Required string defining which case should be enforced, can be "camelCase", "pascalCase", "snakeCase", or "screamingSnakeCase"pattern
: Optional glob pattern that if provided will match only files that fit the pattern for applying the ruleskipDeclarationTypes
: Optional array of declaration types that will be skipped by the rule. May include any of "string", "number", "boolean", "array", "object" or "function".exceptionPattern
: Optional glob pattern of exceptions in constant names. If not provided all top-level constant names are eligible.inclusionPattern
: Optional glob pattern of inclusions in constant names. If not provided all top-level constant names are eligible.