mirror of
https://github.com/stablyai/orca.git
synced 2026-10-17 08:03:14 +00:00
Enable three unicorn rules — one correctness, two performance — and fix every existing violation repo-wide so the rules pass as errors. prefer-number-properties (76 sites) - parseInt/parseFloat/NaN -> Number.* : safe aliases (autofixed). - isNaN -> Number.isNaN (12 sites, hand-converted): global isNaN coerces its argument, Number.isNaN does not. Verified every call site already passes a number (Number.parseInt results, number-typed fields, Date.getTime()), so the conversion is behavior-preserving today and guards against a future non-numeric argument silently coercing. prefer-array-find (26 sites) - .filter(pred)[0] -> .find(pred); .filter(pred).at(-1) / .pop() -> .findLast(pred). Drops the intermediate array and short-circuits. prefer-array-index-of (5 sites) - .findIndex(x => x === v) -> .indexOf(v). Verified: typecheck (node/cli/web) clean, 53 affected suites pass (1679 tests), oxlint clean repo-wide. mobile/ uses findLast safely (already ships ES2023 .toReversed()); config scripts and e2e helpers run on Node 24.
104 lines
3.9 KiB
JSON
104 lines
3.9 KiB
JSON
{
|
|
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
"plugins": ["typescript", "react", "react-hooks", "react-perf", "unicorn"],
|
|
"categories": {
|
|
"correctness": "error"
|
|
},
|
|
"rules": {
|
|
"react/jsx-no-duplicate-props": "error",
|
|
"react/jsx-no-undef": "error",
|
|
"react/no-children-prop": "error",
|
|
"react/no-danger-with-children": "error",
|
|
"react/no-direct-mutation-state": "error",
|
|
"react/no-find-dom-node": "error",
|
|
"react/no-render-return-value": "error",
|
|
"react/no-string-refs": "error",
|
|
"react/no-unescaped-entities": "error",
|
|
"react/require-render-return": "error",
|
|
"react/jsx-curly-brace-presence": [
|
|
"error",
|
|
{ "props": "never", "children": "never", "propElementValues": "always" }
|
|
],
|
|
"react/jsx-filename-extension": ["error", { "extensions": [".tsx", ".jsx"] }],
|
|
"react/jsx-fragments": "error",
|
|
"react/jsx-key": "error",
|
|
"react/jsx-no-constructed-context-values": "error",
|
|
"react/jsx-no-target-blank": "error",
|
|
"react/jsx-no-useless-fragment": ["error", { "allowExpressions": true }],
|
|
"react/jsx-pascal-case": "error",
|
|
"react/no-object-type-as-default-prop": "error",
|
|
"react/self-closing-comp": "error",
|
|
"react-hooks/rules-of-hooks": "error",
|
|
"react-hooks/exhaustive-deps": "warn",
|
|
"typescript/array-type": "error",
|
|
"typescript/consistent-indexed-object-style": "error",
|
|
"typescript/consistent-type-assertions": "error",
|
|
"typescript/consistent-type-definitions": ["error", "type"],
|
|
"typescript/consistent-type-imports": "error",
|
|
"typescript/no-explicit-any": ["error", { "ignoreRestArgs": true }],
|
|
"typescript/no-import-type-side-effects": "error",
|
|
"typescript/no-unnecessary-boolean-literal-compare": "error",
|
|
"typescript/no-unnecessary-template-expression": "error",
|
|
"typescript/no-unsafe-function-type": "warn",
|
|
"typescript/prefer-function-type": "error",
|
|
"typescript/prefer-includes": "error",
|
|
"typescript/prefer-optional-chain": "error",
|
|
"typescript/switch-exhaustiveness-check": [
|
|
"error",
|
|
{ "allowDefaultCaseForExhaustiveSwitch": false }
|
|
],
|
|
"curly": "error",
|
|
"no-unneeded-ternary": "error",
|
|
"no-useless-return": "error",
|
|
"prefer-template": "error",
|
|
"unicorn/consistent-empty-array-spread": "error",
|
|
"unicorn/error-message": "error",
|
|
"unicorn/no-array-fill-with-reference-type": "warn",
|
|
"unicorn/no-array-reverse": "error",
|
|
"unicorn/no-instanceof-builtins": "error",
|
|
"unicorn/no-useless-promise-resolve-reject": "error",
|
|
"unicorn/prefer-array-find": "error",
|
|
"unicorn/prefer-array-flat-map": "warn",
|
|
"unicorn/prefer-array-index-of": "error",
|
|
"unicorn/prefer-at": "error",
|
|
"unicorn/prefer-date-now": "error",
|
|
"unicorn/prefer-includes": "error",
|
|
"unicorn/prefer-import-meta-properties": "error",
|
|
"unicorn/prefer-math-min-max": "error",
|
|
"unicorn/prefer-negative-index": "error",
|
|
"unicorn/prefer-node-protocol": "error",
|
|
"unicorn/prefer-number-properties": "error",
|
|
"unicorn/prefer-object-from-entries": "error",
|
|
"unicorn/prefer-regexp-test": "warn",
|
|
"unicorn/prefer-ternary": "error",
|
|
"unicorn/throw-new-error": "error"
|
|
},
|
|
"overrides": [
|
|
{
|
|
"files": ["**/*.ts"],
|
|
"rules": {
|
|
"max-lines": ["error", { "max": 300, "skipBlankLines": true, "skipComments": true }]
|
|
}
|
|
},
|
|
{
|
|
"files": ["**/*.tsx"],
|
|
"rules": {
|
|
"max-lines": ["error", { "max": 400, "skipBlankLines": true, "skipComments": true }]
|
|
}
|
|
},
|
|
{
|
|
"files": ["**/*.mjs"],
|
|
"rules": {
|
|
"max-lines": ["error", { "max": 600, "skipBlankLines": true, "skipComments": true }]
|
|
}
|
|
},
|
|
{
|
|
"files": ["**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx"],
|
|
"rules": {
|
|
"max-lines": ["error", { "max": 800, "skipBlankLines": true, "skipComments": true }]
|
|
}
|
|
}
|
|
],
|
|
"ignorePatterns": ["**/node_modules", "**/dist", "**/out"]
|
|
}
|