eslint-plugin-validate-filename

0.0.4 • Public • Published

eslint-plugin-validate-filename

ESLint rule to force file names format. You can define folder names and patterns. Create common rules for file names by folder name or regex pattern.

Install

npm install --save-dev eslint-plugin-validate-filename

Uasge

{
  "plugins": ["validate-filename"]
}

validate-filename/naming-rules

Create a rule in the name of ESLint. index is an option that determines whether files with index in the filename are allowed. You can set multiple rules.

{
  "rules": {
    "validate-filename/naming-rules": [
      "error",
      {
        index: true,
        rules: [
          {
            case: 'pascal', // camel or pascal or snake or kebab or flat
            target: "**/components/**", // target "components" folder
            excludes: ['hooks'], // "hooks" folder is excluded.
          }
          {
            case: 'camel',
            target: "**/hooks/**", // target "hooks" folder
            patterns: '^use', // file names begin with "use".
          }
        ] 
      }
    ],
}

validate-filename/limit-extensions

Only certain extensions are allowed. target is a regular expression that identifies the folder. extensions you want to allow for extensions.

{
  "rules": {
    "validate-filename/limit-extensions": [
      "error",
      {
        rules: [
          {
            target: "**/hooks/**",
            extensions: ['.ts', '.tsx'], // This cannot be created except for .ts or .tsx under the hooks folder.
          }
        ]
      }
    ],
}

Next.js structure settings example

TODO

Readme

Keywords

Package Sidebar

Install

npm i eslint-plugin-validate-filename

Weekly Downloads

1,224

Version

0.0.4

License

MIT

Unpacked Size

12.8 kB

Total Files

8

Last publish

Collaborators

  • hiro08