Skip to content

Commit aa9330c

Browse files
committed
docs: update docs for rule filename-naming-convention
1 parent e871e3c commit aa9330c

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

docs/rules/filename-naming-convention.md

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

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`.
48+
**Tip:** To selecte all your `js` files, your can use the glob expression `**/*.js`.
5149

5250
:warning: :warning: :warning:
5351
**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.**
5452

5553

5654
### Options
57-
You need to specify a different naming pattern for different file extensions. The plugin will only check files with extensions you explicitly provided:
55+
#### naming pattern object
56+
You need to specify a different naming pattern for different file. The plugin will only check files you explicitly selected:
5857

5958
```js
6059
module.exports = {
@@ -70,6 +69,30 @@ module.exports = {
7069
};
7170
```
7271

72+
#### rule configuration object
73+
##### `ignoreMiddleExtensions`
74+
If `true`, the rule will ignore the middle extensions of the filename.
75+
76+
In some cases, you may want to ignore the middle extensions of the filename. For example, you want to lint the base name of the config and test/spec files—e.g., `babel.config.js` and `date.test.js`, you can do so by setting the `ignoreMiddleExtensions` option to `true`, and the rule will only validate its base name, in this case the base name will be `babel` and `date`.
77+
78+
```js
79+
module.exports = {
80+
plugins: ['check-file'],
81+
rules: {
82+
'check-file/filename-naming-convention': [
83+
'error',
84+
{
85+
'**/*.{jsx,tsx}': 'CAMEL_CASE',
86+
'**/*.{js,ts}': 'KEBAB_CASE',
87+
},
88+
{
89+
ignoreMiddleExtensions: true,
90+
},
91+
],
92+
},
93+
};
94+
```
95+
7396
## Further Reading
7497
- [micromatch](https://github.com/micromatch/micromatch)
7598
- [glob](https://en.wikipedia.org/wiki/Glob_(programming))

0 commit comments

Comments
 (0)