0.1.10 ⢠Published 2 years ago
eslint-plugin-naming v0.1.10
Enforce a case style for file and folder names
š¼ This rule is enabled in the ā
recommended.
Enforces all linted files and folders to have their names in a certain case style and lowercase file extension. The default is kebab.
Cases
kebab
foo-bar.jsfoo-bar.test.jsfoo-bar.test-utils.js
camel
fooBar.jsfooBar.test.jsfooBar.testUtils.js
pascal
FooBar.jsFooBar.Test.jsFooBar.TestUtils.js
snake
foo_bar.jsfoo_bar.test.jsfoo_bar.test_utils.js
flat
foobar.jsfoobar.test.jsfoobar.testutils.js
Install
$ yarn add --dev eslint-plugin-namingUsage
module.exports = {
extends: ['plugin:naming/recommended'],
};Options
Single match
Type: string
You can set the match option like this:
module.exports = {
extends: ['plugin:naming/recommended'],
rules: {
'naming/case': ['error', 'kebab'],
},
};Multiple match
Type: {string[]}
You can set the match option to allow multiple cases:
module.exports = {
extends: ['plugin:naming/recommended'],
rules: {
'naming/case': ['error', ['kebab', 'camel']],
},
};Options object
Options object has the following properties:
| Name | Type | Default | Description |
|---|---|---|---|
match | string[] | ["kebab"] | List of cases to match |
ignore | string[] RegExp[] | [] | List of regular expressions |
defaultIgnore | boolean | true | Property that allows turning off default ignored values |
validateFolders | boolean | true | Property that allows turning off folders naming validation |
validateExtensions | boolean | true | Property that allows turning off extensions lowercase validation |
Example
module.exports = {
extends: ['plugin:naming/recommended'],
rules: {
'naming/case': [
'error',
{
match: 'kebab',
ignore: ['^FOOBAR\\.js$', '^(B|b)az', '\\.SOMETHING\\.js$', /^vendor/i],
},
],
},
};Don't forget that you must escape special characters that you don't want to be interpreted as part of the regex, for example, if you have [ in the actual filename. For example, to match [id].js, use /^\[id]\.js$/ or '^\\[id]\\.js$'.