Skip to content

dolsem/eslint-plugin-filename-rules

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
December 7, 2022 11:39
August 11, 2020 15:06
August 11, 2020 15:06
August 11, 2020 15:06
August 11, 2020 15:06
August 11, 2020 15:06
August 11, 2020 15:06
September 26, 2020 19:54
August 11, 2020 15:06
December 13, 2022 14:19
December 13, 2022 14:19

eslint-plugin-filename-rules

Adds an ESLint rule to enforce filename conventions for linted files. Allows different options for different file extensions. Supports custom regular expressions.

NPM Version NPM Downloads Build Status Coverage Status License: MIT

Installation

$ npm install -D eslint-plugin-filename-rules

Add it to your .eslintrc.js:

module.exports = {
  plugins: [
    'filename-rules',
  ],
  rules: {
    'filename-rules/match': [2, 'camelcase'],
  },
};

Plugin Options

The following built-in values are supported: pascalcase/PascalCase, camelcase/camelCase, snakecase/snake_case, kebabcase/kebab-case. You can also provide your own regex:

...
'filename-rules/match': [2, /^([a-z]+-)*[a-z]+(?:\..*)?$/],
...

You can also specify different options for different file extensions. In this case the plugin will only check files with extensions you explicitly provided:

...
'filename-rules/match': [2, { '.js': 'camelCase', '.ts': /^([a-z]+-)*[a-z]+(?:\..*)?$/ }],
...

You can use the includePath: true option to have the pattern matched against the full file path (instead of only the file basename):

...
'filename-rules/match': [2, { includePath: true, pattern: /^([a-z]+-)*[a-z]+(?:\..*)?$/ }],
...

The inverse rule not-match checks that the files do NOT match the given pattern. Supports all the same options:

...
'filename-rules/not-match': [2, 'camelCase'],
...

License

MIT