2.8.0 • Published 17 days ago

eslint-plugin-check-file v2.8.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
17 days ago

eslint-plugin-check-file

NPM Version NPM Downloads NPM License Test Workflow Status Test Coverage Follow Author on X

Donate

ESLint rules for consistent filename and folder. Allows you to enforce a consistent naming pattern for the filename and folder.

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-check-file:

npm install eslint-plugin-check-file --save-dev

Usage

Flat Config

import checkFile from 'eslint-plugin-check-file';

export default [
  {
    files: ['src/**/*'],
    plugins: {
      'check-file': checkFile,
    },
    rules: {
      'check-file/no-index': 'error',
      'check-file/filename-blocklist': [
        'error',
        {
          '**/*.model.ts': '*.models.ts',
          '**/*.util.ts': '*.utils.ts',
        },
      ],
      'check-file/folder-match-with-fex': [
        'error',
        {
          '*.test.{js,jsx,ts,tsx}': '**/__tests__/',
          '*.styled.{jsx,tsx}': '**/pages/',
        },
      ],
      'check-file/filename-naming-convention': [
        'error',
        {
          '**/*.{jsx,tsx}': 'CAMEL_CASE',
          '**/*.{js,ts}': 'KEBAB_CASE',
        },
      ],
      'check-file/folder-naming-convention': [
        'error',
        {
          'src/**/': 'CAMEL_CASE',
          'mocks/*/': 'KEBAB_CASE',
        },
      ],
    },
  },
];

eslintrc

Add check-file to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
  "plugins": ["check-file"]
}

Then configure the rules you want to use under the rules section.

{
  "rules": {
    "check-file/no-index": "error",
    "check-file/filename-blocklist": [
      "error",
      {
        "**/*.model.ts": "*.models.ts",
        "**/*.util.ts": "*.utils.ts"
      }
    ],
    "check-file/folder-match-with-fex": [
      "error",
      {
        "*.test.{js,jsx,ts,tsx}": "**/__tests__/",
        "*.styled.{jsx,tsx}": "**/pages/"
      }
    ],
    "check-file/filename-naming-convention": [
      "error",
      {
        "**/*.{jsx,tsx}": "CAMEL_CASE",
        "**/*.{js,ts}": "KEBAB_CASE"
      }
    ],
    "check-file/folder-naming-convention": [
      "error",
      {
        "src/**/": "CAMEL_CASE",
        "mocks/*/": "KEBAB_CASE"
      }
    ]
  }
}

Supported Rules

2.8.0

17 days ago

2.7.1

2 months ago

2.7.0

2 months ago

2.6.2

9 months ago

2.5.0

10 months ago

2.6.1

9 months ago

2.6.0

9 months ago

2.4.0

11 months ago

2.3.0

12 months ago

2.2.0

1 year ago

2.1.0

1 year ago

2.0.0

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.3

2 years ago

1.2.0

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago