Skip to content

Enable default oxlint correctness rules #1747

@kmcginnes

Description

@kmcginnes

After migrating to oxlint in #1746, the correctness category is set to "off" with rules enabled explicitly. There are 7 default correctness rules that have violations and could not be enabled without code changes.

Goal

Fix the 39 lint violations and flip "correctness": "off" to "correctness": "error" in .oxlintrc.json, then remove the individual rule entries that are redundant with the category default.

Rules to enable (39 violations across ~10 files)

Rule Violations Description
no-unused-expressions 13 Ternaries and && used as statements instead of if
no-useless-fallback-in-spread 13 Unnecessary || {} in spread expressions
no-misused-spread 6 Spreading class instances or iterables in objects
no-meaningless-void-operator 4 void on already-void-returning calls
no-useless-length-check 2 Redundant .length > 0 before .some()
no-useless-default-assignment 1 Default value on non-nullish property
prefer-string-starts-ends-with 1 Use String#endsWith instead of substring comparison

Approach

Most fixes are mechanical:

  • cond ? doA() : doB()if (cond) { doA() } else { doB() }
  • x && doSomething()if (x) { doSomething() }
  • ...(value || {})...value (spreading falsy is safe)
  • void fn()fn() (when fn already returns void)
  • .length > 0 && .some(...).some(...)

Important

If you are interested in working on this issue, please leave a comment.

Tip

Please use a 👍 reaction to provide a +1/vote. This helps the community and maintainers prioritize this request.

Metadata

Metadata

Assignees

Labels

tech debtIssues, typically tasks, that are mainly about cleaning up code that is problematic in some way

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions