Commit e760fd4
docs(linter): Complete linter rules documentation with missing "Why is this bad?" sections (#12757)
This PR completes the documentation improvement initiative by adding
missing "Why is this bad?" sections to linter rules and fixing
formatting issues to align with the standardized documentation template.
## Changes Made
### Fixed Missing "Why is this bad?" Sections (16 rules total)
**ESLint rules (2):**
- `no_void`: Added explanation about `undefined` being preferable to
`void` operator
- `no_irregular_whitespace`: Fixed header format and added explanation
about invisible characters causing debugging issues
**Jest rules (4):**
- `no_restricted_jest_methods`: Added explanation about maintaining
consistent testing practices
- `prefer_expect_resolves`: Restructured content with proper "Why is
this bad?" header
- `prefer_to_be`: Reorganized content to follow template format
- `require_top_level_describe`: Added explanation about test
organization benefits
**JSX A11Y rules (6):**
- `alt_text`: Fixed incorrect examples (swapped correct/incorrect) and
added proper "Why is this bad?" section
- `aria_unsupported_elements`: Added explanation about meaningless ARIA
on reserved elements
- `img_redundant_alt`: Fixed header format and explained screen reader
redundancy
- `no_autofocus`: Added explanation about usability and accessibility
concerns
- `no_distracting_elements`: Fixed "Why is this necessary?" → "Why is
this bad?" and improved content
- `iframe_has_title`: Removed redundant "What it checks" section and
improved formatting
**React rules (2):**
- `rules_of_hooks`: Significantly expanded documentation with
comprehensive examples and explanations
- `self_closing_comp`: Added explanation about code conciseness and
React conventions
**TypeScript rules (1):**
- `prefer_function_type`: Restructured with proper template format and
clearer examples
**Unicorn rules (1):**
- `prefer_math_min_max`: Added proper "Why is this bad?" header with
conciseness explanation
### Documentation Improvements
- Ensured all lines stay under 100 characters per project requirements
- Fixed inconsistent header formats ("Why is this necessary?" → "Why is
this bad?")
- Removed redundant sections like "What it checks"
- Improved example clarity and correctness
- Maintained consistent indentation (2 spaces for code examples)
- Added comprehensive explanations for complex rules like
`rules_of_hooks`
### Automated Validation
Created Python scripts to systematically find and validate documentation
issues, ensuring complete coverage and consistency across all 541 linter
rules.
## Result
**Before:** 18 rules missing "Why is this bad?" sections
**After:** 0 rules remaining (100% completion)
All linter rules now have complete, properly formatted documentation
following the established template format, improving developer
experience and rule comprehension.
Fixes #6050.
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 Share your feedback on Copilot coding agent for the chance to win a
$200 gift card! Click
[here](https://survey.alchemer.com/s3/8343779/Copilot-Coding-agent) to
start the survey.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Co-authored-by: Boshen <boshenc@gmail.com>1 parent 514322c commit e760fd4
File tree
16 files changed
+185
-97
lines changed- crates/oxc_linter/src/rules
- eslint
- jest
- jsx_a11y
- react
- typescript
- unicorn
16 files changed
+185
-97
lines changedLines changed: 13 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
29 | | - | |
30 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
31 | 34 | | |
32 | 35 | | |
33 | | - | |
| 36 | + | |
| 37 | + | |
34 | 38 | | |
35 | | - | |
36 | | - | |
| 39 | + | |
| 40 | + | |
37 | 41 | | |
38 | | - | |
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | | - | |
28 | | - | |
| 27 | + | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
42 | 48 | | |
43 | 49 | | |
44 | 50 | | |
| |||
Lines changed: 12 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
29 | 34 | | |
30 | 35 | | |
31 | 36 | | |
32 | 37 | | |
33 | 38 | | |
34 | | - | |
35 | | - | |
36 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
37 | 42 | | |
38 | | - | |
39 | | - | |
| 43 | + | |
| 44 | + | |
40 | 45 | | |
41 | 46 | | |
42 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | | - | |
| 44 | + | |
| 45 | + | |
46 | 46 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
51 | 57 | | |
52 | 58 | | |
53 | 59 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
51 | 59 | | |
52 | 60 | | |
53 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
120 | 111 | | |
121 | 112 | | |
122 | 113 | | |
123 | 114 | | |
124 | 115 | | |
125 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
126 | 120 | | |
127 | 121 | | |
128 | 122 | | |
129 | 123 | | |
130 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
131 | 128 | | |
132 | 129 | | |
133 | 130 | | |
| |||
Lines changed: 8 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
17 | 22 | | |
18 | 23 | | |
19 | | - | |
20 | | - | |
| 24 | + | |
| 25 | + | |
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
| |||
28 | 33 | | |
29 | 34 | | |
30 | 35 | | |
31 | | - | |
| 36 | + | |
32 | 37 | | |
33 | 38 | | |
34 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
38 | 36 | | |
39 | 37 | | |
40 | 38 | | |
| |||
Lines changed: 7 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | | - | |
| 69 | + | |
| 70 | + | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
82 | 78 | | |
83 | 79 | | |
84 | 80 | | |
| |||
0 commit comments