Skip to content

Commit 6e32ae6

Browse files
committed
docs: update docs for rule filename-naming-convention
1 parent 572c535 commit 6e32ae6

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

docs/rules/filename-naming-convention.md

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,38 +45,42 @@ In addition to the built-in naming conventions, you can also set custom naming p
4545
...
4646
```
4747

48-
**Tip:** To selecte all your `js` files, your can use the glob expression `**/*.js`.
48+
**Tip 1:** To selecte all your `js` files, your can use the glob expression `**/*.js`.
4949

50-
:warning: :warning: :warning:
50+
**Tip 2:** v1 versions have the legacy support for selecting target files based on their extensions. This legacy support has been removed since v2.0.0. Please select your target files by their file path. For example, using `**/*.js` instead of `*.js` to select all `js` files.
5151

52-
**v1 versions have the legacy support for selecting target files based on their extensions. This legacy support has been removed since v2.0.0. Please select your target files by their file path. For example, using `**/*.js` instead of `*.js` to select all `js` files.**
52+
### Prefined match syntax
5353

54+
Prefined match syntax allow you to capture specific part of the target file pattern and use it in your naming convention pattern. This syntax is particularly useful when you want to make a file to be named the same as its parent folder.
5455

55-
### Options
56+
To use prefined match in your rule set, you can use the `<index>` syntax. The index refers to the position where the glob matcher occurs in the target file pattern expression, starting with `0`. Read more about glob capture groups in the [micromatch documentation](https://github.com/micromatch/micromatch#capture).
5657

57-
#### naming pattern object
58+
If the rule had been set as follows:
59+
```js
60+
...
61+
'check-file/filename-naming-convention': ['error', { '**/*/!(index).*': '<1>' }, { 'ignoreMiddleExtensions': true }],
62+
...
63+
```
5864

59-
You need to specify a different naming pattern for different file. The plugin will only check files you explicitly selected:
65+
Examples of **incorrect** filename with path for this rule:
66+
```sh
67+
src/Portal/type.ts
68+
src/Portal/base.tsx
69+
```
6070

61-
```js
62-
module.exports = {
63-
plugins: [
64-
'check-file',
65-
],
66-
rules: {
67-
'check-file/filename-naming-convention': ['error', {
68-
'**/*.{jsx,tsx}': 'CAMEL_CASE',
69-
'**/*.{js,ts}': 'KEBAB_CASE',
70-
}],
71-
},
72-
};
71+
Examples of **correct** filename with path for this rule:
72+
```sh
73+
src/Portal/index.ts
74+
src/Portal/Portal.test.tsx
75+
src/Portal/Portal.tsx
76+
src/Portal/Portal.types.ts
7377
```
7478

75-
#### using capture groups
79+
### Options
7680

77-
You can use glob capture groups in you rule set using the `<index>` syntax. Read more about glob capture groups in the [micromatch documentation](https://github.com/micromatch/micromatch#capture).
81+
#### naming pattern object
7882

79-
For example the following rule will only allow a file to be named the same as its parent folder :
83+
You need to specify a different naming pattern for different file. The plugin will only check files you explicitly selected:
8084

8185
```js
8286
module.exports = {
@@ -85,10 +89,8 @@ module.exports = {
8589
'check-file/filename-naming-convention': [
8690
'error',
8791
{
88-
'**/*/*': '<1>',
89-
},
90-
{
91-
ignoreMiddleExtensions: true,
92+
'**/*.{jsx,tsx}': 'CAMEL_CASE',
93+
'**/*.{js,ts}': 'KEBAB_CASE',
9294
},
9395
],
9496
},

0 commit comments

Comments
 (0)