|
1 | 1 | # The folder should follow the folder naming convention (folder-naming-convention)
|
2 | 2 |
|
3 |
| -Please describe the origin of the rule here. |
| 3 | +Allows you to enforce a consistent naming pattern for the name of the specified folder. |
4 | 4 |
|
5 | 5 | ## Rule Details
|
6 | 6 |
|
7 |
| -This rule aims to... |
| 7 | +This rule aims to format the name of the specified folder. This rule uses the glob match syntax to match a folder and declare the naming pattern for the name. |
8 | 8 |
|
9 |
| -Examples of **incorrect** code for this rule: |
| 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`. |
10 | 10 |
|
| 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` | |
| 19 | + |
| 20 | +If the rule had been set as follows: |
11 | 21 | ```js
|
| 22 | +... |
| 23 | +'check-file/folder-naming-convention': ['error', { 'src/**/': 'CAMEL_CASE' }], |
| 24 | +... |
| 25 | +``` |
12 | 26 |
|
13 |
| -// fill me in |
| 27 | +Examples of **incorrect** folder name for this rule: |
14 | 28 |
|
| 29 | +```sh |
| 30 | +src/Components/DisplayLabel/displayLabel.js |
| 31 | +src/components/DisplayLabel/displayLabel.js |
| 32 | +src/components/displayLabel/DisplayLabel.js |
15 | 33 | ```
|
16 | 34 |
|
17 |
| -Examples of **correct** code for this rule: |
| 35 | +Examples of **correct** folder name for this rule: |
18 | 36 |
|
19 |
| -```js |
20 |
| - |
21 |
| -// fill me in |
| 37 | +```sh |
| 38 | +src/components/displayLabel/displayLabel.js |
| 39 | +``` |
22 | 40 |
|
| 41 | +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 `__`: |
| 42 | +```js |
| 43 | +... |
| 44 | +'check-file/folder-naming-convention': ['error', [{ 'components/*/': '__+([a-z])' }]], |
| 45 | +... |
23 | 46 | ```
|
24 | 47 |
|
25 | 48 | ### Options
|
26 | 49 |
|
27 |
| -If there are any options, describe them here. Otherwise, delete this section. |
28 |
| - |
29 |
| -## When Not To Use It |
| 50 | +You need to specify a different naming pattern for different folder. The plugin will only check folders you explicitly provided: |
30 | 51 |
|
31 |
| -Give a short description of when it would be appropriate to turn off this rule. |
| 52 | +```js |
| 53 | +module.exports = { |
| 54 | + plugins: [ |
| 55 | + 'check-file', |
| 56 | + ], |
| 57 | + rules: { |
| 58 | + 'check-file/folder-naming-convention': ['error', { |
| 59 | + 'src/**/': 'CAMEL_CASE', |
| 60 | + 'mocks/*/': 'KEBAB_CASE', |
| 61 | + }], |
| 62 | + }, |
| 63 | +}; |
| 64 | +``` |
32 | 65 |
|
33 | 66 | ## Further Reading
|
34 | 67 |
|
35 |
| -If there are other links that describe the issue this rule addresses, please include them here in a bulleted list. |
| 68 | +- [micromatch](https://github.com/micromatch/micromatch) |
| 69 | +- [glob](https://en.wikipedia.org/wiki/Glob_(programming)) |
0 commit comments