Skip to content

Commit 063227e

Browse files
committed
docs: improve docs
1 parent eb1836d commit 063227e

File tree

3 files changed

+56
-37
lines changed

3 files changed

+56
-37
lines changed

docs/rules/filename-blocklist.md

+28-21
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,30 @@ Allows you to blocklist certain file name patterns.
1111
This rule aims to maintain a consistent naming scheme. This rule uses the glob match syntax to declare blocklisted and preferred filename patterns.
1212

1313
If the rule had been set as follows:
14+
1415
```js
1516
...
1617
'check-file/filename-blocklist': ['error', { '**/*.model.ts': '*.models.ts' }],
1718
...
1819
```
1920

2021
Examples of **incorrect** filename with path for this rule:
22+
2123
```sh
2224
src/foo.model.ts
2325
src/bar.model.ts
2426
```
2527

2628
Examples of **correct** filename with path for this rule:
29+
2730
```sh
2831
src/foo.models.ts
2932
src/bar.models.ts
3033
```
3134

3235
:warning: :warning: :warning:
3336

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.\*\*
3638

3739
### Options
3840

@@ -42,43 +44,48 @@ The key is used to declare the blocklisted filename pattern, while the value is
4244

4345
```js
4446
module.exports = {
45-
plugins: [
46-
'check-file',
47-
],
47+
plugins: ['check-file'],
4848
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+
],
5356
},
5457
};
5558
```
5659

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.
5865

5966
```js
6067
module.exports = {
61-
plugins: [
62-
'check-file',
63-
],
68+
plugins: ['check-file'],
6469
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 },
7077
],
7178
},
7279
};
7380
```
7481

7582
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'
7883

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`
7986

8087
## Further Reading
8188

8289
- [micromatch](https://github.com/micromatch/micromatch)
83-
- [glob](https://en.wikipedia.org/wiki/Glob_(programming))
90+
- [glob](<https://en.wikipedia.org/wiki/Glob_(programming)>)
8491
- [testing glob expression online](https://globster.xyz)

docs/rules/filename-naming-convention.md

+15-8
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,25 @@ This rule aims to format the filename of the specified file. This rule uses the
88

99
There are six naming conventions built into this rule, including `CAMEL_CASE`, `PASCAL_CASE`, `SNAKE_CASE`, `KEBAB_CASE`, `SCREAMING_SNAKE_CASE` and `FLAT_CASE`.
1010

11-
| Formatting | Name |
12-
|---|---|
13-
| helloWorld | `CAMEL_CASE` |
14-
| HelloWorld | `PASCAL_CASE` |
15-
| hello_world | `SNAKE_CASE` |
16-
| hello-world | `KEBAB_CASE` |
11+
| Formatting | Name |
12+
| ----------- | ---------------------- |
13+
| helloWorld | `CAMEL_CASE` |
14+
| HelloWorld | `PASCAL_CASE` |
15+
| hello_world | `SNAKE_CASE` |
16+
| hello-world | `KEBAB_CASE` |
1717
| HELLO_WORLD | `SCREAMING_SNAKE_CASE` |
18-
| helloworld | `FLAT_CASE` |
18+
| helloworld | `FLAT_CASE` |
1919

2020
If the rule had been set as follows:
21+
2122
```js
2223
...
2324
'check-file/filename-naming-convention': ['error', { 'src/services/*.js': 'PASCAL_CASE' }],
2425
...
2526
```
2627

2728
Examples of **incorrect** filename with path for this rule:
29+
2830
```sh
2931
src/services/downloadService.js
3032
src/services/downloadservice.js
@@ -33,12 +35,14 @@ src/services/download_service.js
3335
```
3436

3537
Examples of **correct** filename with path for this rule:
38+
3639
```sh
3740
src/services/DownloadService.js
3841
src/download-service.js // this file is not be specified by the target pattern, so it is skipped
3942
```
4043

4144
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 `__`:
45+
4246
```js
4347
...
4448
'check-file/filename-naming-convention': ['error', {'**/*.js': '__+([a-z])'}],
@@ -56,19 +60,22 @@ Prefined match syntax allow you to capture specific part of the target file patt
5660
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).
5761

5862
If the rule had been set as follows:
63+
5964
```js
6065
...
6166
'check-file/filename-naming-convention': ['error', { '**/*/!(index).*': '<1>' }, { 'ignoreMiddleExtensions': true }],
6267
...
6368
```
6469

6570
Examples of **incorrect** filename with path for this rule:
71+
6672
```sh
6773
src/Portal/type.ts
6874
src/Portal/base.tsx
6975
```
7076

7177
Examples of **correct** filename with path for this rule:
78+
7279
```sh
7380
src/Portal/index.ts
7481
src/Portal/Portal.test.tsx
@@ -126,5 +133,5 @@ module.exports = {
126133
## Further Reading
127134

128135
- [micromatch](https://github.com/micromatch/micromatch)
129-
- [glob](https://en.wikipedia.org/wiki/Glob_(programming))
136+
- [glob](<https://en.wikipedia.org/wiki/Glob_(programming)>)
130137
- [testing glob expression online](https://globster.xyz)

docs/rules/folder-match-with-fex.md

+13-8
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,21 @@ Allows you to enforce a consistent naming pattern for the specified files' folde
77
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.
88

99
If the rule had been set as follows:
10+
1011
```js
1112
...
1213
'check-file/folder-match-with-fex': ['error', {'*.test.js': '**/__tests__/'}],
1314
...
1415
```
1516

1617
For the file `foo.test.js`, examples of **incorrect** folder for this rule:
18+
1719
```sh
1820
bar/_tests_/foo.test.js
1921
```
2022

2123
For the file `foo.test.js`, examples of **correct** folder for this rule:
24+
2225
```sh
2326
bar/__tests__/foo.test.js
2427
```
@@ -28,22 +31,24 @@ bar/__tests__/foo.test.js
2831
#### naming pattern object
2932

3033
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:
34+
3135
```js
3236
module.exports = {
33-
plugins: [
34-
'check-file',
35-
],
37+
plugins: ['check-file'],
3638
rules: {
37-
'check-file/folder-match-with-fex': ['error', {
38-
'*.test.{js,jsx,ts,tsx}': '**/__tests__/',
39-
'*.styled.{jsx,tsx}': '**/pages/',
40-
}],
39+
'check-file/folder-match-with-fex': [
40+
'error',
41+
{
42+
'*.test.{js,jsx,ts,tsx}': '**/__tests__/',
43+
'*.styled.{jsx,tsx}': '**/pages/',
44+
},
45+
],
4146
},
4247
};
4348
```
4449

4550
## Further Reading
4651

4752
- [micromatch](https://github.com/micromatch/micromatch)
48-
- [glob](https://en.wikipedia.org/wiki/Glob_(programming))
53+
- [glob](<https://en.wikipedia.org/wiki/Glob_(programming)>)
4954
- [testing glob expression online](https://globster.xyz)

0 commit comments

Comments
 (0)