Tracking issue for #38.
The following Sonar rules are mechanical / auto-fixable. Most can be addressed by a codemod or ESLint autofix pass. Total: ~1,200 issues.
| Rule |
Count |
Description |
| typescript:S7735 |
347 |
Negated conditions should be avoided when an else clause is present |
| typescript:S1128 |
97 |
Unnecessary imports should be removed |
| typescript:S7767 |
94 |
Bitwise operators should not be used to round numbers |
| typescript:S4325 |
90 |
Redundant casts and non-null assertions should be avoided |
| typescript:S7773 |
86 |
Number static methods and properties should be preferred over global equivalents |
| typescript:S6582 |
74 |
Optional chaining should be preferred |
| typescript:S6606 |
70 |
Nullish coalescing should be preferred |
| typescript:S7741 |
56 |
typeof should not be used to check for undefined |
| typescript:S7755 |
46 |
Complex index access patterns should be replaced with .at() method |
| typescript:S7772 |
38 |
Node.js built-in modules should be imported using the node: protocol |
| typescript:S2933 |
46 |
Fields that are only assigned in the constructor should be readonly |
| typescript:S6759 |
24 |
Mark React props as read-only |
| typescript:S6564 |
29 |
Redundant type aliases |
| typescript:S6660 |
21 |
if-else-if should end with else |
| typescript:S1940 |
24 |
Boolean expressions should not be inverted |
| typescript:S101 |
20 |
Class names should comply with naming convention |
| typescript:S107 |
18 |
Functions should not have too many parameters |
| typescript:S7778 |
73 |
Multiple consecutive method calls should be combined |
| typescript:S7786 |
111 |
Generic Error should be TypeError when thrown after type checking |
| typescript:S6571 |
76 |
Type constituents of unions and intersections should not be redundant |
Suggested approach
- Run ESLint with @typescript-eslint/unicorn rules enabled on a feature branch - many of these have autofixers (S1128, S6582, S6606, S7741, S7773, S7772, S2933).
- For S7735 (~347) and S7755 (~46), write a small jscodeshift transform.
- For S7786 (~111 - TypeError for type-checked throws), case-by-case but mostly mechanical.
- Land per-rule PRs to keep diffs reviewable.
Refs: #38
Tracking issue for #38.
The following Sonar rules are mechanical / auto-fixable. Most can be addressed by a codemod or ESLint autofix pass. Total: ~1,200 issues.
Suggested approach
Refs: #38