benyasin / eslint-plugin-filename

eslint plugin for filename checking

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

eslint-plugin-filename

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

The following built-in values are supported: pascalcase/PascalCase, camelcase/camelCase, snakecase/snake_case, kebabcase/kebab-case. Multiple built-in values passed as array are also supported.

Add it to your .eslintrc.js:

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

or

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

Plugin Options

You can also provide your own regex, if you are using your own regex, do not pass them as array.

'filename/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/match': [2, { '.js': 'camelCase', '.ts': /^([a-z]+-)*[a-z]+(?:\..*)?$/ }],

License

MIT

About

eslint plugin for filename checking

License:MIT License


Languages

Language:JavaScript 100.0%