refactor: simplify oxlint config toward defaults - #2729
joyenjoyer wants to merge 1 commit into
Conversation
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
| @@ -1,15 +1,6 @@ | |||
| { | |||
| "$schema": "./node_modules/oxlint/configuration_schema.json", | |||
| "plugins": ["eslint", "typescript", "react"], | |||
There was a problem hiding this comment.
plugins replaces oxlint's defaults rather than extending them. Stock oxlint runs ["unicorn", "typescript", "oxc"]
| { | ||
| "$schema": "./node_modules/oxlint/configuration_schema.json", | ||
| "plugins": ["eslint", "typescript", "react"], | ||
| "categories": { |
There was a problem hiding this comment.
Lines 4-12, the categories block.
All seven categories were set "off". Only correctness is on in stock oxlint anyway, at warn, so six of these lines had no effect at all. The seventh is what forced the 129-rule manual list below.
| "./scripts/oxlint/notice-plugin.mjs" | ||
| ], | ||
| "rules": { | ||
| "constructor-super": "error", |
There was a problem hiding this comment.
Applies to this whole block, roughly lines 49-197.
Every rule here is one oxlint already enables in the correctness category. With the categories block gone they all stay on, at the default warn instead of the error written here.
That severity drop is not observable, because none of these rules reports a single violation anywhere in the repo. The error count is 12 before and after this PR, identical file for file, and all of it comes from no-undef (5, in two ui-icons .cjs config files), notice/notice (5, files whose licence header follows a shebang), and no-redeclare (2, in safeCloneElement.ts). All 12 are pre-existing on master. None is in this block.
17 of these lines also carried an options object that only repeated oxlint's own defaults longhand. Each was tested by running the rule with its options and then bare; the counts matched every time.
Proof that nothing was lost: I generated 94 fixture files, one minimal violation per rule, and ran the old and new configs over the identical set. Old caught 75, new caught 97, and nothing detected by old is missed by new.
| ], | ||
| "no-unused-labels": "error", | ||
| "no-unused-private-class-members": "error", | ||
| "no-unused-vars": [ |
There was a problem hiding this comment.
The one rule in that block whose options were not a harmless repeat. args: "none" is far weaker than oxlint's default, and it was being overridden anyway by the @typescript-eslint alias on line 244, which sits later in the file and wins.
Measured on packages/:
| Config | Hits |
|---|---|
{args: "none", ignoreRestSiblings: true} |
17 |
{args: "after-used", ignoreRestSiblings: true} |
79 |
{args: "after-used"} |
373 |
| bare (oxlint default) | 309 |
Bare matches exactly what the alias was already enforcing, so deleting the line outright preserves behavior. Keeping the old options would have quietly dropped enforcement to 17.
| "ts-ignore": "allow-with-description" | ||
| } | ||
| ], | ||
| "@typescript-eslint/no-array-constructor": "error", |
There was a problem hiding this comment.
I removed it as redundant with unicorn/no-new-array, which this PR turns on, but that's only partly true:
new Array(1,2,3) |
Array(1,2,3) |
new Array(5) |
|
|---|---|---|---|
no-array-constructor |
yes | yes | yes |
unicorn/no-new-array |
no | no | yes |
no-new-array only covers the single-argument form, so multi-argument use is now unchecked. Zero hits in the repo today, so nothing regressed, but this is a genuine narrowing.
| "@typescript-eslint/no-unnecessary-type-constraint": "error", | ||
| "@typescript-eslint/no-unsafe-declaration-merging": "error", | ||
| "@typescript-eslint/no-unsafe-function-type": "error", | ||
| "no-unused-expressions": [ |
There was a problem hiding this comment.
This line, plus the alias at 236 and the one at 244.
no-unused-expressions is written twice under two names. oxlint treats @typescript-eslint/no-unused-expressions as an alias and reports both as eslint(no-unused-expressions).
They were configured with opposite options: the core block here allowed short-circuits, ternaries, and tagged templates, while the TS block at 236 forbade all three. oxlint resolves duplicates last-key-wins, so the strict one governed and this permissive block was dead config. Verified: 3 violations on a test file in this order, 0 when reversed.
Strict is also oxlint's default, so both lines go and the count stays at 68. Those 68 are all the a && a.method() null-guard idiom, which ?. replaces. It's a modernization backlog that is now visible.
Line 244 is the same alias trap for no-unused-vars. See the note on line 168.
| "@typescript-eslint/prefer-namespace-keyword": "error", | ||
| "@typescript-eslint/triple-slash-reference": "error", | ||
| "react/display-name": "error", | ||
| "react/jsx-key": "error", |
There was a problem hiding this comment.
Applies to the remaining typescript and react defaults through line 262.
Same as the main block: all default-on in correctness, all zero-hit, all repeated here at error. react/no-find-dom-node is the one exception worth naming, since it was listed at warn, which is also its default. It still reports the same 41 warnings after removal.
| "requireDataLowercase": false | ||
| } | ||
| ], | ||
| "react-js/prop-types": [ |
There was a problem hiding this comment.
Removed as obsolete. This repo types props with TypeScript, so a runtime propTypes check pushes toward an API the codebase has moved off. Zero hits today, because it ran with skipUndeclared: true.
| ], | ||
| "react-js/forbid-foreign-prop-types": "error", | ||
| "react/no-danger": "error", | ||
| "react-js/require-default-props": "warn", |
There was a problem hiding this comment.
Removed as obsolete. defaultProps is deprecated for function components in React 19, so this rule was actively steering code toward an API being removed. Drops 32 warnings, the only coverage this PR intentionally gives up.
|
Visual regression reportCypress suite: ✅ Passing Visual diff: ✅ No changes.
Accessibility (axe): ✅ No violations. 📊 View full report — click a screenshot's ⚠ badge to see each violation boxed on the image, with the offending element named and contrast failures shown as color swatches. Baselines come from the |
matyasf
left a comment
There was a problem hiding this comment.
nice work, one suggestion, see my comment
| "jsPlugins": [ | ||
| { | ||
| "name": "react-js", | ||
| "specifier": "eslint-plugin-react" | ||
| }, |
There was a problem hiding this comment.
I really dont like that we have this here. This pulls in the whole ESLint (see the root package.json) which adds package.json bloat and makes IDE go a bit crazy because it thinks that this project uses ESLint.
According to Claude we could remove it, which would lead to the following rules dropped (the others are natively in the react oxlint plugin`):
no-typosmostly catches misspelled propTypes, defaultProps, and lifecycle names. TypeScript covers most of that already.forbid-foreign-prop-typesdoes not matter here, we stopped using proptypes.no-deprecatedflags findDOMNode, ReactDOM.render, and the componentWill* methods, but we need a complex support matrix anyway, and I doubt anyone would write code that uses these.
I can you please try to remove this (and then you can remove the dependencies from the package.json too)
Goal
Get
.oxlintrc.jsonas close to stock oxlint as possible for a React/TypeScript codebase, keeping only what InstUI genuinely adds on top: the a11y set, the monorepo and licensing plugins, the import boundaries, and our TypeScript strictness choices. Everything oxlint already does by default comes out.Summary
oxcandunicorninplugins. That array replaces oxlint's defaults instead of extending themcategoriesblock and 77 rule lines that duplicate oxlint defaults, 17 of them carrying options objects that only wrote the defaults out longhand.no-array-constructor, the@typescript-eslint/no-unused-varsalias, and thereact-jsrulesprop-typesandrequire-default-props, which both steer toward deprecated APIs.vitest/require-mock-type-parameters, which the re-enabled category surfaced as 663 stylistic warnings.Test Plan
pnpm run lintexits 1 both before and after this PR, from 12 pre-existing errors:no-undefin twoui-icons.cjs config files,notice/noticein five files whose licence header follows a shebang, andno-redeclareinsafeCloneElement.ts. Confirm that list is unchanged rather than that it passes.Fixes INSTUI-5159
🤖 Generated with Claude Code