Commit ab46187
authored
docs(linter): Add configuration docs for 6 react rules. (#15198)
Part of #14743.
- react/jsx-fragments
- react/jsx-filename-extension
- react/style-prop-object
- react/jsx-curly-brace-presence
- react/jsx-no-script-url
- react/jsx-pascal-case
Generated docs:
```md
## Configuration
This rule accepts a configuration object with the following properties:
### allow
type: `"always" | "as-needed"`
default: `"always"`
When to allow a JSX filename extension. By default all files may have a JSX extension.
Set this to `as-needed` to only allow JSX file extensions in files that contain JSX syntax.
### extensions
type: `string[]`
default: `["jsx"]`
The set of allowed file extensions.
### ignoreFilesWithoutCode
type: `boolean`
default: `false`
If enabled, files that do not contain code (i.e. are empty, contain only whitespaces or comments) will not be rejected.
```
```md
## Configuration
This rule accepts a configuration object with the following properties:
### children
type: `"always" | "never" | "ignore"`
default: `"never"`
### propElementValues
type: `"always" | "never" | "ignore"`
default: `"ignore"`
### props
type: `"always" | "never" | "ignore"`
default: `"never"`
```
```md
## Configuration
This rule accepts a configuration object with the following properties:
### components
type: `Record<string, array>`
default: `{}`
Additional components to check.
### includeFromSettings
type: `boolean`
default: `false`
Whether to include components from settings.
```
```md
## Configuration
This rule accepts a configuration object with the following properties:
### allowAllCaps
type: `boolean`
default: `false`
Whether to allow all-caps component names.
### allowLeadingUnderscore
type: `boolean`
default: `false`
Whether to allow leading underscores in component names.
### allowNamespace
type: `boolean`
default: `false`
Whether to allow namespaced component names.
### ignore
type: `string[]`
default: `[]`
List of component names to ignore.
```
```md
## Configuration
This rule accepts a configuration object with the following properties:
### mode
type: `"syntax" | "element"`
default: `"syntax"`
`syntax` mode:
This is the default mode. It will enforce the shorthand syntax for React fragments, with one exception.
Keys or attributes are not supported by the shorthand syntax, so the rule will not warn on standard-form fragments that use those.
Examples of **incorrect** code for this rule:
\```jsx
<React.Fragment><Foo /></React.Fragment>
\```
Examples of **correct** code for this rule:
\```jsx
<><Foo /></>
\```
\```jsx
<React.Fragment key="key"><Foo /></React.Fragment>
\```
`element` mode:
This mode enforces the standard form for React fragments.
Examples of **incorrect** code for this rule:
\```jsx
<><Foo /></>
\```
Examples of **correct** code for this rule:
\```jsx
<React.Fragment><Foo /></React.Fragment>
\```
\```jsx
<React.Fragment key="key"><Foo /></React.Fragment>
\```
```
```md
## Configuration
This rule accepts a configuration object with the following properties:
### allow
type: `string[]`
default: `[]`
List of component names on which to allow style prop values of any type.
```1 parent 51c8724 commit ab46187
File tree
6 files changed
+76
-102
lines changed- crates/oxc_linter/src/rules/react
6 files changed
+76
-102
lines changedLines changed: 9 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| |||
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
35 | | - | |
| 37 | + | |
| 38 | + | |
36 | 39 | | |
37 | 40 | | |
38 | 41 | | |
| |||
64 | 67 | | |
65 | 68 | | |
66 | 69 | | |
67 | | - | |
| 70 | + | |
| 71 | + | |
68 | 72 | | |
69 | 73 | | |
70 | 74 | | |
| |||
82 | 86 | | |
83 | 87 | | |
84 | 88 | | |
85 | | - | |
| 89 | + | |
86 | 90 | | |
87 | 91 | | |
88 | 92 | | |
89 | | - | |
90 | | - | |
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
| |||
300 | 302 | | |
301 | 303 | | |
302 | 304 | | |
303 | | - | |
| 305 | + | |
| 306 | + | |
304 | 307 | | |
305 | 308 | | |
306 | 309 | | |
| |||
Lines changed: 12 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
25 | | - | |
| 27 | + | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
41 | 44 | | |
42 | 45 | | |
43 | 46 | | |
44 | | - | |
| 47 | + | |
| 48 | + | |
45 | 49 | | |
| 50 | + | |
| 51 | + | |
46 | 52 | | |
| 53 | + | |
47 | 54 | | |
| 55 | + | |
48 | 56 | | |
49 | 57 | | |
50 | 58 | | |
| |||
92 | 100 | | |
93 | 101 | | |
94 | 102 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | 103 | | |
123 | 104 | | |
124 | 105 | | |
125 | | - | |
| 106 | + | |
| 107 | + | |
126 | 108 | | |
127 | 109 | | |
128 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
23 | | - | |
| 25 | + | |
| 26 | + | |
24 | 27 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
| 28 | + | |
51 | 29 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | 30 | | |
56 | 31 | | |
57 | 32 | | |
| |||
69 | 44 | | |
70 | 45 | | |
71 | 46 | | |
72 | | - | |
| 47 | + | |
73 | 48 | | |
74 | 49 | | |
75 | 50 | | |
| |||
85 | 60 | | |
86 | 61 | | |
87 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
| 92 | + | |
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | | - | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
| 31 | + | |
31 | 32 | | |
| 33 | + | |
32 | 34 | | |
| 35 | + | |
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
| |||
66 | 69 | | |
67 | 70 | | |
68 | 71 | | |
69 | | - | |
| 72 | + | |
| 73 | + | |
70 | 74 | | |
71 | 75 | | |
72 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | | - | |
| 27 | + | |
| 28 | + | |
27 | 29 | | |
| 30 | + | |
28 | 31 | | |
| 32 | + | |
29 | 33 | | |
| 34 | + | |
30 | 35 | | |
| 36 | + | |
31 | 37 | | |
32 | 38 | | |
33 | 39 | | |
| |||
92 | 98 | | |
93 | 99 | | |
94 | 100 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | 101 | | |
123 | 102 | | |
124 | | - | |
| 103 | + | |
| 104 | + | |
125 | 105 | | |
126 | 106 | | |
127 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | | - | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
| 31 | + | |
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
| |||
77 | 80 | | |
78 | 81 | | |
79 | 82 | | |
80 | | - | |
| 83 | + | |
| 84 | + | |
81 | 85 | | |
82 | 86 | | |
83 | 87 | | |
| |||
0 commit comments