Skip to content

Commit cc6de0d

Browse files
committed
docs: update docs
1 parent abc37d1 commit cc6de0d

File tree

2 files changed

+23
-59
lines changed

2 files changed

+23
-59
lines changed

README.md

+22-58
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
[![Test Coverage][test-coverage-image]][test-coverage-url]
88
[![Follow Author on X][x-follow-image]][x-follow-url]
99

10-
[![Donate][ko-fi-image]][ko-fi-url]
11-
12-
ESLint rules for consistent filename and folder. Allows you to enforce a consistent naming pattern for the filename and folder.
10+
An ESLint plugin that enforces consistent naming conventions for files and folders in your project. It helps maintain a clean and organized codebase by allowing you to define and enforce specific patterns for filenames and directory structures.
1311

1412
## Installation
1513

@@ -28,17 +26,19 @@ npm install eslint-plugin-check-file --save-dev
2826

2927
## Usage
3028

31-
### Flat Config
29+
This plugin supports ESLint's [flat configuration](https://eslint.org/docs/latest/use/configure/configuration-files). Here's a complete example:
3230

3331
```javascript
3432
import checkFile from 'eslint-plugin-check-file';
3533

3634
export default [
3735
{
38-
files: ['src/**/*'],
36+
files: ['src/**/*.*'],
3937
plugins: {
4038
'check-file': checkFile,
4139
},
40+
// optional: add this processor if you want to lint non-js/ts files (images, styles, etc.)
41+
processor: 'check-file/eslint-processor-check-file',
4242
rules: {
4343
'check-file/no-index': 'error',
4444
'check-file/filename-blocklist': [
@@ -52,76 +52,28 @@ export default [
5252
'error',
5353
{
5454
'*.test.{js,jsx,ts,tsx}': '**/__tests__/',
55-
'*.styled.{jsx,tsx}': '**/pages/',
55+
'*.styled.{jsx,tsx}': '**/components/',
5656
},
5757
],
5858
'check-file/filename-naming-convention': [
5959
'error',
6060
{
61-
'**/*.{jsx,tsx}': 'CAMEL_CASE',
62-
'**/*.{js,ts}': 'KEBAB_CASE',
61+
'**/*.{jsx,tsx}': 'PASCAL_CASE',
62+
'**/*.{js,ts}': 'CAMEL_CASE',
6363
},
6464
],
6565
'check-file/folder-naming-convention': [
6666
'error',
6767
{
68-
'src/**/': 'CAMEL_CASE',
69-
'mocks/*/': 'KEBAB_CASE',
68+
'src/components/*/': 'PASCAL_CASE',
69+
'src/!(components)/**/!(__tests__)/': 'CAMEL_CASE',
7070
},
7171
],
7272
},
7373
},
7474
];
7575
```
7676

77-
### `eslintrc`
78-
79-
Add `check-file` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
80-
81-
```json
82-
{
83-
"plugins": ["check-file"]
84-
}
85-
```
86-
87-
Then configure the rules you want to use under the rules section.
88-
89-
```json
90-
{
91-
"rules": {
92-
"check-file/no-index": "error",
93-
"check-file/filename-blocklist": [
94-
"error",
95-
{
96-
"**/*.model.ts": "*.models.ts",
97-
"**/*.util.ts": "*.utils.ts"
98-
}
99-
],
100-
"check-file/folder-match-with-fex": [
101-
"error",
102-
{
103-
"*.test.{js,jsx,ts,tsx}": "**/__tests__/",
104-
"*.styled.{jsx,tsx}": "**/pages/"
105-
}
106-
],
107-
"check-file/filename-naming-convention": [
108-
"error",
109-
{
110-
"**/*.{jsx,tsx}": "CAMEL_CASE",
111-
"**/*.{js,ts}": "KEBAB_CASE"
112-
}
113-
],
114-
"check-file/folder-naming-convention": [
115-
"error",
116-
{
117-
"src/**/": "CAMEL_CASE",
118-
"mocks/*/": "KEBAB_CASE"
119-
}
120-
]
121-
}
122-
}
123-
```
124-
12577
## Supported Rules
12678

12779
- [check-file/no-index](docs/rules/no-index.md): A file cannot be named "index"
@@ -130,6 +82,18 @@ Then configure the rules you want to use under the rules section.
13082
- [check-file/filename-naming-convention](docs/rules/filename-naming-convention.md): Enforce a consistent naming pattern for filenames for specified files
13183
- [check-file/folder-naming-convention](docs/rules/folder-naming-convention.md): Enforce a consistent naming pattern for folder names for specified folders
13284

85+
## Version Compatibility
86+
87+
Version 3.0.0 and above only support ESLint's flat configuration. For legacy configuration support, please use version 2.x.
88+
89+
## Support
90+
91+
If you find this plugin helpful, consider supporting the project:
92+
93+
[![Donate][ko-fi-image]][ko-fi-url]
94+
95+
<iframe src="https://github.com/sponsors/dukeluo/card" title="Sponsor dukeluo" height="225" width="600" style="border: 0;"></iframe>
96+
13397
[npm-image]: https://img.shields.io/npm/v/eslint-plugin-check-file.svg
13498
[downloads-image]: https://img.shields.io/npm/dm/eslint-plugin-check-file.svg
13599
[license-image]: https://img.shields.io/npm/l/eslint-plugin-check-file

lib/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import FolderMatchWithFex from './rules/folder-match-with-fex.js';
99
import FolderNamingConvention from './rules/folder-naming-convention.js';
1010
import NoIndex from './rules/no-index.js';
1111

12-
export const rules = {
12+
const rules = {
1313
'filename-blocklist': FilenameBlocklist,
1414
'filename-naming-convention': FilenameNamingConvention,
1515
'folder-match-with-fex': FolderMatchWithFex,

0 commit comments

Comments
 (0)