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
Examples of **incorrect** filename with path for this rule:
22
+
21
23
```sh
22
24
src/foo.model.ts
23
25
src/bar.model.ts
24
26
```
25
27
26
28
Examples of **correct** filename with path for this rule:
29
+
27
30
```sh
28
31
src/foo.models.ts
29
32
src/bar.models.ts
30
33
```
31
34
32
35
:warning::warning::warning:
33
36
34
-
**Versions <= v2.0.0 can only select target files by their filenames, not by their paths. This support has been deprecated and will be removed in the future. Please select your target files by their file path. For example, using `**/*.js` instead of `*.js` to select all `js` files.**
35
-
37
+
**Versions <= v2.0.0 can only select target files by their filenames, not by their paths. This support has been deprecated and will be removed in the future. Please select your target files by their file path. For example, using `**/_.js`instead of`_.js`to select all`js` files.\*\*
36
38
37
39
### Options
38
40
@@ -42,43 +44,48 @@ The key is used to declare the blocklisted filename pattern, while the value is
42
44
43
45
```js
44
46
module.exports= {
45
-
plugins: [
46
-
'check-file',
47
-
],
47
+
plugins: ['check-file'],
48
48
rules: {
49
-
'check-file/filename-blocklist': ['error', {
50
-
'**/*.model.ts':'*.models.ts',
51
-
'**/*.util.ts':'*.utils.ts',
52
-
}],
49
+
'check-file/filename-blocklist': [
50
+
'error',
51
+
{
52
+
'**/*.model.ts':'*.models.ts',
53
+
'**/*.util.ts':'*.utils.ts',
54
+
},
55
+
],
53
56
},
54
57
};
55
58
```
56
59
57
-
An optional "nonGlobSuggestion" argument can be passed that allows the blocklist reason to be any string, instead of a strict glob pattern
60
+
#### rule configuration object
61
+
62
+
##### `nonGlobSuggestion`
63
+
64
+
If `true`, it allows the blocklist reason to be any string, instead of a strict glob pattern.
58
65
59
66
```js
60
67
module.exports= {
61
-
plugins: [
62
-
'check-file',
63
-
],
68
+
plugins: ['check-file'],
64
69
rules: {
65
-
'check-file/filename-blocklist': ['error', {
66
-
'**/*.model.ts':'see the repo rules at http://some/example.com',
67
-
'**/*.util.ts':'for a non glob related reason',
68
-
},
69
-
{ nonGlobSuggestion:true, }
70
+
'check-file/filename-blocklist': [
71
+
'error',
72
+
{
73
+
'**/*.model.ts':'see the repo rules at http://some/example.com',
74
+
'**/*.util.ts':'for a non glob related reason',
75
+
},
76
+
{ nonGlobSuggestion:true },
70
77
],
71
78
},
72
79
};
73
80
```
74
81
75
82
These rules would produce errors that look like:
76
-
1. 'The filename "model.ts" matches the blocklisted "**/*.model.ts" pattern, this is not allowed see the repo rules at http://some/example.com'
77
-
2. 'The filename "util.ts" matches the blocklisted "**/*.util.ts" pattern, this is not allowed for a non glob related reason'
78
83
84
+
-`The filename "model.ts" matches the blocklisted "**/*.model.ts" pattern, this is not allowed see the repo rules at http://some/example.com`
85
+
-`The filename "util.ts" matches the blocklisted "**/*.util.ts" pattern, this is not allowed for a non glob related reason`
Copy file name to clipboardexpand all lines: docs/rules/filename-naming-convention.md
+15-8
Original file line number
Diff line number
Diff line change
@@ -8,23 +8,25 @@ This rule aims to format the filename of the specified file. This rule uses the
8
8
9
9
There are six naming conventions built into this rule, including `CAMEL_CASE`, `PASCAL_CASE`, `SNAKE_CASE`, `KEBAB_CASE`, `SCREAMING_SNAKE_CASE` and `FLAT_CASE`.
Examples of **correct** filename with path for this rule:
38
+
36
39
```sh
37
40
src/services/DownloadService.js
38
41
src/download-service.js // this file is not be specified by the target pattern, so it is skipped
39
42
```
40
43
41
44
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 `__`:
@@ -56,19 +60,22 @@ Prefined match syntax allow you to capture specific part of the target file patt
56
60
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).
Copy file name to clipboardexpand all lines: docs/rules/folder-match-with-fex.md
+13-8
Original file line number
Diff line number
Diff line change
@@ -7,18 +7,21 @@ Allows you to enforce a consistent naming pattern for the specified files' folde
7
7
This rule aims to format the folder of the specified files. It will be useful when you want to group the specified files into a folder. This rule uses the glob match syntax to match target files and declare the naming pattern for their folder names.
For the file `foo.test.js`, examples of **incorrect** folder for this rule:
18
+
17
19
```sh
18
20
bar/_tests_/foo.test.js
19
21
```
20
22
21
23
For the file `foo.test.js`, examples of **correct** folder for this rule:
24
+
22
25
```sh
23
26
bar/__tests__/foo.test.js
24
27
```
@@ -28,22 +31,24 @@ bar/__tests__/foo.test.js
28
31
#### naming pattern object
29
32
30
33
The key is used to select target files, while the value is used to declare the naming pattern for their folder names. You can specify a different folder naming pattern for different target files. The plugin will only check files you explicitly provided:
0 commit comments