You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/rules/filename-naming-convention.md
+50-40Lines changed: 50 additions & 40 deletions
Original file line number
Diff line number
Diff line change
@@ -49,9 +49,7 @@ In addition to the built-in naming conventions, you can also set custom naming p
49
49
...
50
50
```
51
51
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`.
55
53
56
54
### Prefined Match Syntax
57
55
@@ -90,18 +88,22 @@ src/Portal/Portal.types.ts
90
88
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:
91
89
92
90
```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
+
exportdefault [
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
+
},
103
105
},
104
-
};
106
+
];
105
107
```
106
108
107
109
#### rule configuration object
@@ -113,21 +115,25 @@ If `true`, the rule will ignore the middle extensions of the filename.
113
115
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`.
114
116
115
117
```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
+
exportdefault [
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
+
},
129
135
},
130
-
};
136
+
];
131
137
```
132
138
133
139
##### `errorMessage`
@@ -138,19 +144,23 @@ Customizes the error message displayed when a file's filename doesn't match the
138
144
-`{{ pattern }}`: Represents the naming pattern.
139
145
140
146
```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
+
exportdefault [
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',
0 commit comments