Skip to content

Commit 2e087cc

Browse files
committed
docs: update docs for rule filename-naming-convention
1 parent e08f471 commit 2e087cc

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ Then configure the rules you want to use under the rules section.
4545
"check-file/filename-naming-convention":[
4646
"error",
4747
{
48-
"*.{jsx,tsx}":"CAMEL_CASE",
49-
"*.{js,ts}":"KEBAB_CASE"
48+
"**/*.{jsx,tsx}":"CAMEL_CASE",
49+
"**/*.{js,ts}":"KEBAB_CASE"
5050
}
5151
],
5252
"check-file/no-index":"error",
@@ -64,6 +64,6 @@ Then configure the rules you want to use under the rules section.
6464
## Supported Rules
6565

6666
- [check-file/folder-match-with-fex](docs/rules/folder-match-with-fex.md): Enforce a consistent naming pattern for the folder of the specified file extension
67-
- [check-file/filename-naming-convention](docs/rules/filename-naming-convention.md): Enforce a consistent naming pattern for the filename of the specified file extension
67+
- [check-file/filename-naming-convention](docs/rules/filename-naming-convention.md): Enforce a consistent naming pattern for the filename of the specified file
6868
- [check-file/no-index](docs/rules/no-index.md): A file cannot be named "index"
6969
- [check-file/folder-naming-convention](docs/rules/folder-naming-convention.md): Enforce a consistent naming pattern for the name of the specified folder

docs/rules/filename-naming-convention.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,38 @@ There are six naming conventions built into this rule, including `CAMEL_CASE`, `
2020
If the rule had been set as follows:
2121
```js
2222
...
23-
'check-file/filename-naming-convention': ['error', {'*.js': 'CAMEL_CASE'}],
23+
'check-file/filename-naming-convention': ['error', { 'src/services/*.js': 'PASCAL_CASE' }],
2424
...
2525
```
2626

27-
Examples of **incorrect** filename for this rule:
27+
Examples of **incorrect** filename with path for this rule:
2828
```sh
29-
calculate-price.js
30-
CalculatePrice.js
31-
calculate_price.js
32-
calculateprice.js
29+
src/services/downloadService.js
30+
src/services/downloadservice.js
31+
src/services/download-service.js
32+
src/services/download_service.js
3333
```
3434

35-
Examples of **correct** filename for this rule:
35+
Examples of **correct** filename with path for this rule:
3636
```sh
37-
calculatePrice.js
37+
src/services/DownloadService.js
38+
src/download-service.js // this file is not be selected by the target pattern, so it is skipped
3839
```
3940

4041
In addition to the built-in naming conventions, you can also set custom naming patterns using glob match syntax. The following code shows an example of how to ensure that all your `js` files are named begin with `__`:
4142
```js
4243
...
43-
'check-file/filename-naming-convention': ['error', {'*.js': '__+([a-z])'}],
44+
'check-file/filename-naming-convention': ['error', {'**/*.js': '__+([a-z])'}],
4445
...
4546
```
4647

47-
**Tip:** To exclude some config and test/spec files for all your `js` files, such as `babel.config.js` and `index.test.js`, use the glob expression `'!(*.spec|*.test|*.config).js'` to match the target files. This will exclude all `js` files with filenames containing `.spec`, `.test` or `.config`.
48+
**Tip 1:** To exclude some config and test/spec files for all your `js` files, such as `babel.config.js` and `index.test.js`, use the glob expression `'**/!(*.spec|*.test|*.config).js'` to match the target files. This will exclude all `js` files with filenames containing `.spec`, `.test` or `.config`.
49+
50+
**Tip 2:** To selecte all your `js` files, your can use the glob expression `**/*.js`.
51+
52+
:warning: :warning: :warning:
53+
**Versions below v1.2.0 can only select files by using their extensions. All `v1` versions will have this feature, but is will be removed in the future. Please select your target files by the file path. For example, using `**/*.js` instead of `*.js` to select all `js` files.**
54+
4855

4956
### Options
5057
You need to specify a different naming pattern for different file extensions. The plugin will only check files with extensions you explicitly provided:
@@ -56,8 +63,8 @@ module.exports = {
5663
],
5764
rules: {
5865
'check-file/filename-naming-convention': ['error', {
59-
'*.{jsx,tsx}': 'CAMEL_CASE',
60-
'*.{js,ts}': 'KEBAB_CASE',
66+
'**/*.{jsx,tsx}': 'CAMEL_CASE',
67+
'**/*.{js,ts}': 'KEBAB_CASE',
6168
}],
6269
},
6370
};

0 commit comments

Comments
 (0)