Skip to content

oxlint: add unicorn rules - #4157

Merged
nstepien merged 11 commits into
mainfrom
unicornrules
Aug 28, 2026
Merged

nstepien merged 11 commits into
mainfrom
unicornrules

Conversation

@nstepien

Copy link
Copy Markdown
Collaborator

@nstepien nstepien self-assigned this Aug 27, 2026
nstepien and others added 5 commits August 27, 2026 18:19
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
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-commenter

codecov-commenter commented Aug 27, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.73%. Comparing base (985eda8) to head (cd27285).

Files with missing lines Patch % Lines
src/utils/index.ts 0.00% 1 Missing ⚠️
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     
Files with missing lines Coverage Δ
src/DataGrid.tsx 98.88% <100.00%> (ø)
src/EditCell.tsx 96.29% <100.00%> (ø)
src/HeaderCell.tsx 95.12% <ø> (-1.18%) ⬇️
src/TreeDataGrid.tsx 94.41% <100.00%> (+0.03%) ⬆️
src/hooks/useCalculatedColumns.ts 100.00% <100.00%> (ø)
src/hooks/useRovingTabIndex.ts 100.00% <100.00%> (ø)
src/hooks/useViewportColumns.ts 100.00% <100.00%> (ø)
src/utils/index.ts 90.90% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nstepien
nstepien marked this pull request as ready for review August 28, 2026 01:55
@nstepien
nstepien requested a review from amanmahajan7 as a code owner August 28, 2026 01:55
@nstepien
nstepien enabled auto-merge (squash) August 28, 2026 01:55

@amanmahajan7 amanmahajan7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I will review soon. What is your take on unicorn rules? Also, do we need to disable correctness?

@nstepien

Copy link
Copy Markdown
Collaborator Author

What is your take on unicorn rules?

Most are good rules, reminds me of the sonarjs rules.
Some other rules may be a bit too pedantic though. I've kept them enabled since they don't affect the repo as it stands, but I wonder if it'd be better to disable them.

Also, do we need to disable correctness?

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.

@nstepien
nstepien merged commit ac0a1c5 into main Aug 28, 2026
2 checks passed
@nstepien
nstepien deleted the unicornrules branch August 28, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants