Skip to content

Commit 3052a0a

Browse files
committed
docs: improve docs for rule folder-naming-convention
1 parent 099ea28 commit 3052a0a

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

docs/rules/folder-naming-convention.md

+22-17
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,21 @@ This rule aims to format the name of the specified folder. This rule uses the gl
88

99
There are six basic 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` |
17-
| HELLO_WORLD | `SCREAMING_SNAKE_CASE` |
18-
| helloworld | `FLAT_CASE` |
11+
**Additionally, there is a naming convention called `NEXT_JS_APP_ROUTER_CASE` used to format folder names in Next.js projects that used App Router.** `NEXT_JS_APP_ROUTER_CASE` aims to support a wide range of named constructs in Next.js App Router projects, including Standard routes, Dynamic segments, Catch-all segments, Optional Catch-all Segments, Route groups, and Named slots.
12+
13+
While `NEXT_JS_APP_ROUTER_CASE` covers many naming cases, it's possible that some cases may be missing. If you come across any missing cases, I encourage you to open an issue and provide the necessary details. Your feedback will help me improve and enhance the naming convention.
1914

20-
And there are a naming convention `NEXT_JS_APP_ROUTER_CASE` for the Next.js app router, which is used to format its folder name.
15+
| Formatting | Name |
16+
| ----------- | ---------------------- |
17+
| helloWorld | `CAMEL_CASE` |
18+
| HelloWorld | `PASCAL_CASE` |
19+
| hello_world | `SNAKE_CASE` |
20+
| hello-world | `KEBAB_CASE` |
21+
| HELLO_WORLD | `SCREAMING_SNAKE_CASE` |
22+
| helloworld | `FLAT_CASE` |
2123

2224
If the rule had been set as follows:
25+
2326
```js
2427
...
2528
'check-file/folder-naming-convention': ['error', { 'src/**/': 'CAMEL_CASE' }],
@@ -41,6 +44,7 @@ src/components/displayLabel/displayLabel.js
4144
```
4245

4346
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 the folders under the `components` folder are named begin with `__`:
47+
4448
```js
4549
...
4650
'check-file/folder-naming-convention': ['error', [{ 'components/*/': '__+([a-z])' }]],
@@ -57,20 +61,21 @@ The key is used to select target folders, while the value is used to declare the
5761

5862
```js
5963
module.exports = {
60-
plugins: [
61-
'check-file',
62-
],
64+
plugins: ['check-file'],
6365
rules: {
64-
'check-file/folder-naming-convention': ['error', {
65-
'src/**/': 'CAMEL_CASE',
66-
'mocks/*/': 'KEBAB_CASE',
67-
}],
66+
'check-file/folder-naming-convention': [
67+
'error',
68+
{
69+
'src/**/': 'CAMEL_CASE',
70+
'mocks/*/': 'KEBAB_CASE',
71+
},
72+
],
6873
},
6974
};
7075
```
7176

7277
## Further Reading
7378

7479
- [micromatch](https://github.com/micromatch/micromatch)
75-
- [glob](https://en.wikipedia.org/wiki/Glob_(programming))
80+
- [glob](<https://en.wikipedia.org/wiki/Glob_(programming)>)
7681
- [testing glob expression online](https://globster.xyz)

0 commit comments

Comments
 (0)