Skip to content

Commit bd82d9d

Browse files
committed
docs: update docs for rule filename-naming-convention
1 parent e8ddf67 commit bd82d9d

File tree

1 file changed

+50
-40
lines changed

1 file changed

+50
-40
lines changed

docs/rules/filename-naming-convention.md

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ In addition to the built-in naming conventions, you can also set custom naming p
4949
...
5050
```
5151

52-
**Tip 1:** To selecte all your `js` files, your can use the glob expression `**/*.js`.
53-
54-
**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.
52+
**Tip:** To selecte all your `js` files, your can use the glob expression `**/*.js`.
5553

5654
### Prefined Match Syntax
5755

@@ -90,18 +88,22 @@ src/Portal/Portal.types.ts
9088
The key is used to select target files, while the value is used to declare the naming pattern for the filename. You can specify a different naming pattern for different files. The plugin will only check files you explicitly selected:
9189

9290
```js
93-
module.exports = {
94-
plugins: ['check-file'],
95-
rules: {
96-
'check-file/filename-naming-convention': [
97-
'error',
98-
{
99-
'**/*.{jsx,tsx}': 'CAMEL_CASE',
100-
'**/*.{js,ts}': 'KEBAB_CASE',
101-
},
102-
],
91+
export default [
92+
{
93+
plugins: {
94+
'check-file': checkFile,
95+
},
96+
rules: {
97+
'check-file/filename-naming-convention': [
98+
'error',
99+
{
100+
'**/*.{jsx,tsx}': 'CAMEL_CASE',
101+
'**/*.{js,ts}': 'KEBAB_CASE',
102+
},
103+
],
104+
},
103105
},
104-
};
106+
];
105107
```
106108

107109
#### rule configuration object
@@ -113,21 +115,25 @@ If `true`, the rule will ignore the middle extensions of the filename.
113115
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`.
114116

115117
```js
116-
module.exports = {
117-
plugins: ['check-file'],
118-
rules: {
119-
'check-file/filename-naming-convention': [
120-
'error',
121-
{
122-
'**/*.{jsx,tsx}': 'CAMEL_CASE',
123-
'**/*.{js,ts}': 'KEBAB_CASE',
124-
},
125-
{
126-
ignoreMiddleExtensions: true,
127-
},
128-
],
118+
export default [
119+
{
120+
plugins: {
121+
'check-file': checkFile,
122+
},
123+
rules: {
124+
'check-file/filename-naming-convention': [
125+
'error',
126+
{
127+
'**/*.{jsx,tsx}': 'CAMEL_CASE',
128+
'**/*.{js,ts}': 'KEBAB_CASE',
129+
},
130+
{
131+
ignoreMiddleExtensions: true,
132+
},
133+
],
134+
},
129135
},
130-
};
136+
];
131137
```
132138

133139
##### `errorMessage`
@@ -138,19 +144,23 @@ Customizes the error message displayed when a file's filename doesn't match the
138144
- `{{ pattern }}`: Represents the naming pattern.
139145

140146
```js
141-
module.exports = {
142-
plugins: ['check-file'],
143-
rules: {
144-
'check-file/filename-naming-convention': [
145-
'error',
146-
{ '**/*/!(index).*': '<1>' },
147-
{
148-
errorMessage:
149-
'The file "{{ target }}" does not match file naming convention defined("{{ pattern }}") for this project, see contribute.md for details',
150-
},
151-
],
147+
export default [
148+
{
149+
plugins: {
150+
'check-file': checkFile,
151+
},
152+
rules: {
153+
'check-file/filename-naming-convention': [
154+
'error',
155+
{ '**/*/!(index).*': '<1>' },
156+
{
157+
errorMessage:
158+
'The file "{{ target }}" does not match file naming convention defined("{{ pattern }}") for this project, see contribute.md for details',
159+
},
160+
],
161+
},
152162
},
153-
};
163+
];
154164
```
155165

156166
## Further Reading

0 commit comments

Comments
 (0)