eslint-plugin-check-file
v2.8.0
Published
ESLint rules for consistent filename and folder. Allows you to enforce a consistent naming pattern for the filename and folder
Downloads
920,734
Maintainers
Readme
eslint-plugin-check-file
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
- check-file/no-index: A file cannot be named "index"
- check-file/filename-blocklist: Blocklist filenames by pattern
- check-file/folder-match-with-fex: Enforce a consistent naming pattern for folder names for specified files
- check-file/filename-naming-convention: Enforce a consistent naming pattern for filenames for specified files
- check-file/folder-naming-convention: Enforce a consistent naming pattern for folder names for specified folders