Commit 5a66558
committed
feat(linter): Handle config docs for string/enum values and add config option docs for various rules. (#15759)
This allows rules like `return-await` to render their possible values accurately on the docs website. Fixes #15078. Also part of #14743.
Used GitHub Copilot + Claude Sonnet 4.5 for most of the json schema edits, after figuring out which parts needed modification to enable this.
Updates the following rules with config option docs and uses DefaultRuleConfig for configuration handling:
- `react/prefer-es6-class`
- `unicorn/switch-case-braces`
- `vue/define-emits-declaration`
- `vue/define-props-declaration`
- `typescript/consistent-indexed-object-style`
Generated docs are as follows.
For `typescript/consistent-indexed-object-style`:
```md
## Configuration
This rule accepts one of the following string values:
### `"record"`
When set to `record`, enforces the use of a `Record` for indexed object types, e.g. `Record<string, unknown>`.
### `"index-signature"`
When set to `index-signature`, enforces the use of indexed signature types, e.g. `{ [key: string]: unknown }`.
```
For `typescript/return-await`:
```md
## Configuration
This rule accepts one of the following string values:
### `"in-try-catch"`
Require `await` when returning Promises inside try/catch/finally blocks.
This ensures proper error handling and stack traces.
### `"always"`
Require `await` before returning Promises in all cases.
Example: `return await Promise.resolve()` is required.
### `"error-handling-correctness-only"`
Require `await` only when it affects error handling correctness.
Only flags cases where omitting await would change error handling behavior.
### `"never"`
Disallow `await` before returning Promises in all cases.
Example: `return Promise.resolve()` is required (no await).
```
For `vue/define-emits-declaration`:
```md
## Configuration
This rule accepts one of the following string values:
### `"type-based"`
Enforce type-based declaration.
### `"type-literal"`
Enforce type-literal declaration.
### `"runtime"`
Enforce runtime declaration.
```
For `vue/define-props-declaration`:
```md
## Configuration
This rule accepts one of the following string values:
### `"type-based"`
Enforce type-based declaration.
### `"runtime"`
Enforce runtime declaration.
```
For `react/prefer-es6-class`:
```md
## Configuration
This rule accepts one of the following string values:
### `"always"`
Always prefer ES6 class-style components
### `"never"`
Do not allow ES6 class-style
```1 parent c3744c4 commit 5a66558
File tree
8 files changed
+200
-120
lines changed- crates/oxc_linter
- src/rules
- react
- typescript
- unicorn
- vue
- tests
- tasks/website/src/linter
- rules
8 files changed
+200
-120
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
9 | | - | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
23 | | - | |
24 | | - | |
25 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
26 | 33 | | |
27 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
28 | 38 | | |
29 | 39 | | |
30 | 40 | | |
| |||
48 | 58 | | |
49 | 59 | | |
50 | 60 | | |
| 61 | + | |
51 | 62 | | |
52 | 63 | | |
53 | 64 | | |
54 | 65 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
63 | 71 | | |
64 | 72 | | |
65 | 73 | | |
66 | 74 | | |
67 | 75 | | |
68 | | - | |
69 | | - | |
| 76 | + | |
70 | 77 | | |
71 | 78 | | |
72 | 79 | | |
73 | 80 | | |
74 | | - | |
| 81 | + | |
75 | 82 | | |
76 | 83 | | |
77 | 84 | | |
| |||
87 | 94 | | |
88 | 95 | | |
89 | 96 | | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | 97 | | |
107 | 98 | | |
108 | 99 | | |
| |||
Lines changed: 13 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
| 35 | + | |
| 36 | + | |
48 | 37 | | |
49 | 38 | | |
50 | 39 | | |
51 | 40 | | |
| 41 | + | |
52 | 42 | | |
53 | 43 | | |
| 44 | + | |
54 | 45 | | |
55 | 46 | | |
56 | 47 | | |
| |||
113 | 104 | | |
114 | 105 | | |
115 | 106 | | |
116 | | - | |
| 107 | + | |
117 | 108 | | |
118 | 109 | | |
119 | 110 | | |
120 | 111 | | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
129 | 117 | | |
130 | 118 | | |
131 | 119 | | |
132 | | - | |
| 120 | + | |
133 | 121 | | |
134 | | - | |
| 122 | + | |
135 | 123 | | |
136 | 124 | | |
137 | 125 | | |
| |||
Lines changed: 30 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
7 | 14 | | |
8 | 15 | | |
9 | 16 | | |
| |||
24 | 31 | | |
25 | 32 | | |
26 | 33 | | |
27 | | - | |
28 | | - | |
29 | | - | |
| 34 | + | |
30 | 35 | | |
31 | 36 | | |
32 | 37 | | |
33 | | - | |
| 38 | + | |
34 | 39 | | |
35 | 40 | | |
36 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
37 | 52 | | |
38 | 53 | | |
39 | 54 | | |
| |||
68 | 83 | | |
69 | 84 | | |
70 | 85 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
| 86 | + | |
82 | 87 | | |
83 | 88 | | |
84 | 89 | | |
85 | 90 | | |
86 | 91 | | |
87 | 92 | | |
88 | | - | |
| 93 | + | |
| 94 | + | |
89 | 95 | | |
90 | 96 | | |
91 | 97 | | |
92 | 98 | | |
93 | | - | |
94 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
95 | 104 | | |
96 | 105 | | |
97 | 106 | | |
| |||
116 | 125 | | |
117 | 126 | | |
118 | 127 | | |
119 | | - | |
| 128 | + | |
120 | 129 | | |
121 | 130 | | |
122 | 131 | | |
| |||
141 | 150 | | |
142 | 151 | | |
143 | 152 | | |
144 | | - | |
| 153 | + | |
145 | 154 | | |
146 | 155 | | |
147 | 156 | | |
| |||
Lines changed: 19 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
13 | | - | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| |||
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
33 | | - | |
| 35 | + | |
| 36 | + | |
34 | 37 | | |
| 38 | + | |
| 39 | + | |
35 | 40 | | |
36 | 41 | | |
| 42 | + | |
| 43 | + | |
37 | 44 | | |
| 45 | + | |
| 46 | + | |
38 | 47 | | |
39 | 48 | | |
40 | 49 | | |
| |||
111 | 120 | | |
112 | 121 | | |
113 | 122 | | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | 123 | | |
125 | 124 | | |
126 | 125 | | |
127 | | - | |
| 126 | + | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
138 | 137 | | |
| 138 | + | |
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| |||
0 commit comments