0.1.9 ā€¢ Published 5 days ago

eslint-plugin-naming v0.1.9

Weekly downloads
-
License
MIT
Repository
-
Last release
5 days ago

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.js
  • foo-bar.test.js
  • foo-bar.test-utils.js

camel

  • fooBar.js
  • fooBar.test.js
  • fooBar.testUtils.js

pascal

  • FooBar.js
  • FooBar.Test.js
  • FooBar.TestUtils.js

snake

  • foo_bar.js
  • foo_bar.test.js
  • foo_bar.test_utils.js

flat

  • foobar.js
  • foobar.test.js
  • foobar.testutils.js

Install

$ yarn add --dev eslint-plugin-naming

Usage

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:

NameTypeDefaultDescription
matchstring[]["kebab"]List of cases to match
ignorestring[] RegExp[][]List of regular expressions
defaultIgnorebooleantrueProperty that allows turning off default ignored values
validateFoldersbooleantrueProperty that allows turning off folders naming validation
validateExtensionsbooleantrueProperty 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$'.

0.1.9

5 days ago

0.1.8

8 months ago

0.1.4

8 months ago

0.1.3

8 months ago

0.1.2

8 months ago

0.1.1

8 months ago

0.1.0

8 months ago