Skip to content

Commit 939ee67

Browse files
committed
docs: add docs for the rule match-with-fex
1 parent fd682f1 commit 939ee67

File tree

4 files changed

+44
-28
lines changed

4 files changed

+44
-28
lines changed

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# eslint-plugin-checkfolder
22

3-
check the file folder
3+
Allows you to enforce a consistent naming pattern for the folder of the specified file.
44

55
## Installation
66

@@ -33,14 +33,20 @@ Then configure the rules you want to use under the rules section.
3333

3434
```json
3535
{
36-
"rules": {
37-
"checkfolder/rule-name": 2
38-
}
36+
"rules":{
37+
"checkfolder/match-with-fex":[
38+
"error",
39+
{
40+
"*.test.{js,jsx,ts,tsx}":"**/__tests__/",
41+
"*.styled.{jsx,tsx}":"**/pages/"
42+
}
43+
]
44+
}
3945
}
4046
```
4147

4248
## Supported Rules
4349

44-
* Fill in provided rules here
50+
- [checkfolder/match-with-fex](docs/rules/match-with-fex.md): Enforce a consistent naming pattern for the folder of the specified file
4551

4652

docs/rules/match-with-fex.md

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,45 @@
1-
# The folder should match the rules specified by the file extension (match-with-fex)
1+
# The folder should match the naming pattern specified by the file extension (match-with-fex)
22

3-
Please describe the origin of the rule here.
3+
Allows you to enforce a consistent naming pattern for the folder of the specified file.
44

55
## Rule Details
66

7-
This rule aims to...
8-
9-
Examples of **incorrect** code for this rule:
7+
This rule aims to format the folder of the specified file. This rule uses the glob match syntax to match a file and declare the naming pattern for the folder.
108

9+
If the rule had been set as follows:
1110
```js
12-
13-
// fill me in
14-
11+
...
12+
'checkfolder/match-with-fex': ['error', {'*.test.js': '**/__tests__/'}],
13+
...
1514
```
1615

17-
Examples of **correct** code for this rule:
18-
19-
```js
20-
21-
// fill me in
16+
For the file `foo.test.js`, examples of **incorrect** folder for this rule:
17+
```sh
18+
bar/_tests_/foo.test.js
19+
```
2220

21+
For the file `foo.test.js`, examples of **correct** folder for this rule:
22+
```sh
23+
bar/__tests__/foo.test.js
2324
```
2425

2526
### Options
27+
You need to specify a different naming pattern for different file extensions. The plugin will only check files with extensions you explicitly provided:
2628

27-
If there are any options, describe them here. Otherwise, delete this section.
28-
29-
## When Not To Use It
30-
31-
Give a short description of when it would be appropriate to turn off this rule.
29+
```js
30+
module.exports = {
31+
plugins: [
32+
'checkfolder',
33+
],
34+
rules: {
35+
'checkfolder/match-with-fex': ['error', {
36+
'*.test.{js,jsx,ts,tsx}': '**/__tests__/',
37+
'*.styled.{jsx,tsx}': '**/pages/',
38+
}],
39+
},
40+
};
41+
```
3242

3343
## Further Reading
34-
35-
If there are other links that describe the issue this rule addresses, please include them here in a bulleted list.
44+
- [micromatch](https://github.com/micromatch/micromatch)
45+
- [glob](https://en.wikipedia.org/wiki/Glob_(programming))

lib/rules/match-with-fex.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @fileoverview The folder should match the rules specified by the file extension
2+
* @fileoverview The folder should match the naming pattern specified by the file extension
33
* @author Duke Luo
44
*/
55
'use strict';
@@ -15,7 +15,7 @@ module.exports = {
1515
type: 'layout',
1616
docs: {
1717
description:
18-
'The folder should match the rules specified by the file extension',
18+
'The folder should match the naming pattern specified by the file extension',
1919
category: 'Layout & Formatting',
2020
recommended: false,
2121
url: null, //TODO URL to the documentation page for this rule

tests/lib/rules/match-with-fex.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @fileoverview The folder should match the rules specified by the file extension
2+
* @fileoverview The folder should match the naming pattern specified by the file extension
33
* @author Duke Luo
44
*/
55
'use strict';

0 commit comments

Comments
 (0)