Repository navigation
oxlint: add unicorn rules - #4157
Conversation
Go through every unicorn rule, disable the ones that do not fit this
codebase, tune the options of the ones that do, and fix the code they flag.
Disabled:
- `no-null`, `no-useless-undefined`: `null`/`undefined` literals are required
by the public `Maybe<T>` API, by React (`useRef<T>(undefined)`,
`renderCell: () => null`) and by `noImplicitReturns`
- `prefer-number-coercion`: rewrites `parseFloat('10px')` to `Number('10px')`
- `prefer-at`: `at(-1)` returns `T | undefined` and is suggested for DOM
collections, which have no `at()`
- `no-nested-ternary`, `empty-brace-spaces`, `number-literal-case`: oxfmt
already owns this
- `prefer-includes`, `no-instanceof-array`: duplicate reports
- `no-negated-condition`, `prefer-query-selector`: style
Tuned:
- `filename-case`: camelCase + PascalCase
- `switch-case-braces`: `avoid`
- `prefer-ternary`: `only-single-line`
- `no-array-sort`: `allowAfterSpread`
- `max-nested-calls`: `max: 4`
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01BHDtvyEwsiM6EQJsgdiHt9
…pFn)` Avoids building an intermediate array. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01BHDtvyEwsiM6EQJsgdiHt9
Both call sites built the same `repeat(n, Xpx)`/`Xpx` string. Extracting it removes the duplication and keeps each `gridTemplateRows` append on one line. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01BHDtvyEwsiM6EQJsgdiHt9
`entries()` allocates a `[index, value]` tuple per column. Use an indexed loop instead, matching the other loops in this file. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01BHDtvyEwsiM6EQJsgdiHt9
`expandGroup` re-runs on every expand/collapse and only needed `Object.keys` for `setSize`. Store `setSize` on each group entry instead — it is already known while grouping, in a memo that recomputes far less often — so `expandGroup` can walk the dictionary with `for…in` and no keys array. `groupRows` now uses `Object.keys` + lookup instead of `Object.entries`, which drops one tuple per group. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01BHDtvyEwsiM6EQJsgdiHt9
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4157 +/- ##
==========================================
- Coverage 97.79% 97.73% -0.06%
==========================================
Files 39 39
Lines 1587 1590 +3
Branches 514 515 +1
==========================================
+ Hits 1552 1554 +2
- Misses 35 36 +1
🚀 New features to boost your workflow:
|
amanmahajan7
left a comment
There was a problem hiding this comment.
Nice! I will review soon. What is your take on unicorn rules? Also, do we need to disable correctness?
Most are good rules, reminds me of the sonarjs rules.
Maybe. Since we configure all the rules ourselves, and list all the plugins we use, it doesn't really affect us, until oxlint adds new rules. |
https://oxc.rs/docs/guide/usage/linter/rules.html?sort=name&dir=asc&scope=unicorn