Skip to content

Commit 9382f03

Browse files
authored
chore: replace ESLint with oxlint and run lint in CI (#845)
Replace ESLint 8, @typescript-eslint v5, eslint-plugin-react, eslint-plugin-react-hooks and eslint-plugin-no-only-tests with oxlint, including type-aware rules via oxlint-tsgolint. - .oxlintrc.json ports the current recommended presets (ESLint, typescript-eslint, eslint-plugin-react, eslint-plugin-react-hooks v7 including the React Compiler rules) rule by rule, keeping the existing warn-level overrides. Categories are off so oxlint upgrades don't change what's enforced. - Add typescript-eslint's recommended-type-checked rules. Rules with existing findings are warnings for now; the no-unsafe-* rules and require-await stay off. typescript/no-deprecated (warn) replaces react/no-deprecated. - vitest/no-focused-tests replaces eslint-plugin-no-only-tests. - Add test/tsconfig.json so type-aware rules (which use the nearest tsconfig.json) resolve test files with the test compiler settings. - Fix findings: require -> import in test/setupTests.ts (already failing lint on main), and await deleteApp in two afterEach hooks. - Suppress react/static-components in SuspenseWithPerf with a TODO (fixing it changes runtime behavior), plus one intentional pattern in a test and one only-throw-error false positive. - Run `npm run lint` in the test workflow before the tests. - Fix the `npm run lint -- --fix` instruction in CONTRIBUTING.md. - Regenerate reference docs (line number shift).
1 parent c0b6301 commit 9382f03

16 files changed

Lines changed: 845 additions & 1922 deletions

‎.eslintrc.json‎

Lines changed: 0 additions & 36 deletions
This file was deleted.

‎.github/CONTRIBUTING.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,6 @@ set up.
8383
1. run `npm run build` to confirm that the source builds
8484
2. run `npm run test` to confirm that tests pass
8585
3. run `npm run lint` to confirm that code meets our style guide
86-
> If the lint check fails, run `npm run lint --fix` to automatically fix any issues.
86+
> If the lint check fails, run `npm run lint -- --fix` to automatically fix any issues.
8787
5. run `npm run docs` to rebuild the reference docs
8888
> If you've forked the repo, run `npm run docs:fork` instead. This will ensure the reference docs link to the firebaseextended/reactfire repository.

‎.github/workflows/test.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ jobs:
109109
cache: 'npm'
110110
- name: Install deps
111111
run: npm ci
112+
- name: Lint
113+
run: npm run lint
112114
# Only the 19 leg swaps the runtime; the 18 leg runs the lockfile's React
113115
# as-is. --no-save keeps the lockfile out of the diff. Note this differs
114116
# from the type-check job, which installs on both legs and also installs

‎.oxlintrc.json‎

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"plugins": ["typescript", "react", "vitest"],
4+
// Rules are listed explicitly instead of enabling oxlint's categories, so upgrading oxlint
5+
// doesn't change what gets enforced.
6+
"categories": {
7+
"correctness": "off"
8+
},
9+
"options": {
10+
// Type-aware rules (run by oxlint-tsgolint) use the nearest tsconfig.json for each file.
11+
// test/tsconfig.json exists so that test files are checked with the test compiler settings.
12+
"typeAware": true
13+
},
14+
"rules": {
15+
// ESLint recommended, minus the rules that TypeScript already checks
16+
"for-direction": "error",
17+
"no-async-promise-executor": "error",
18+
"no-case-declarations": "error",
19+
"no-compare-neg-zero": "error",
20+
"no-cond-assign": "error",
21+
"no-constant-binary-expression": "error",
22+
"no-constant-condition": "error",
23+
"no-control-regex": "error",
24+
"no-debugger": "error",
25+
"no-delete-var": "error",
26+
"no-dupe-else-if": "error",
27+
"no-duplicate-case": "error",
28+
"no-empty": "error",
29+
"no-empty-character-class": "error",
30+
"no-empty-pattern": "error",
31+
"no-empty-static-block": "error",
32+
"no-ex-assign": "error",
33+
"no-extra-boolean-cast": "error",
34+
"no-fallthrough": "error",
35+
"no-global-assign": "error",
36+
"no-invalid-regexp": "error",
37+
"no-irregular-whitespace": "error",
38+
"no-loss-of-precision": "error",
39+
"no-misleading-character-class": "error",
40+
"no-nonoctal-decimal-escape": "error",
41+
"no-prototype-builtins": "warn",
42+
"no-regex-spaces": "error",
43+
"no-self-assign": "error",
44+
"no-shadow-restricted-names": "error",
45+
"no-sparse-arrays": "error",
46+
"no-unassigned-vars": "error",
47+
"no-unexpected-multiline": "error",
48+
"no-unsafe-finally": "error",
49+
"no-unsafe-optional-chaining": "error",
50+
"no-unused-labels": "error",
51+
"no-unused-private-class-members": "error",
52+
"no-useless-backreference": "error",
53+
"no-useless-catch": "error",
54+
"no-useless-escape": "error",
55+
"preserve-caught-error": "error",
56+
"require-yield": "error",
57+
"use-isnan": "error",
58+
"valid-typeof": "error",
59+
"no-var": "error",
60+
"prefer-const": "warn",
61+
"prefer-rest-params": "error",
62+
"prefer-spread": "error",
63+
64+
// typescript-eslint recommended
65+
"no-array-constructor": "error",
66+
"no-empty-function": "warn",
67+
"no-unused-expressions": "error",
68+
"no-unused-vars": "error",
69+
"typescript/ban-ts-comment": "error",
70+
"typescript/no-duplicate-enum-values": "error",
71+
"typescript/no-empty-object-type": "warn",
72+
"typescript/no-explicit-any": "warn",
73+
"typescript/no-extra-non-null-assertion": "error",
74+
"typescript/no-inferrable-types": "warn",
75+
"typescript/no-misused-new": "error",
76+
"typescript/no-namespace": "error",
77+
"typescript/no-non-null-asserted-optional-chain": "error",
78+
"typescript/no-require-imports": "error",
79+
"typescript/no-this-alias": "error",
80+
"typescript/no-unnecessary-type-constraint": "error",
81+
"typescript/no-unsafe-declaration-merging": "error",
82+
"typescript/no-unsafe-function-type": "warn",
83+
"typescript/no-wrapper-object-types": "warn",
84+
"typescript/prefer-as-const": "error",
85+
"typescript/prefer-namespace-keyword": "error",
86+
"typescript/triple-slash-reference": "error",
87+
88+
// typescript-eslint recommended-type-checked (type-aware)
89+
"typescript/await-thenable": "error",
90+
"typescript/no-array-delete": "error",
91+
"typescript/no-base-to-string": "error",
92+
"typescript/no-duplicate-type-constituents": "error",
93+
"typescript/no-floating-promises": "error",
94+
"typescript/no-for-in-array": "error",
95+
"typescript/no-implied-eval": "error",
96+
"typescript/no-misused-promises": "error",
97+
"typescript/no-unsafe-enum-comparison": "error",
98+
"typescript/no-unsafe-unary-minus": "error",
99+
// Suspense works by throwing promises
100+
"typescript/only-throw-error": ["error", { "allow": [{ "from": "lib", "name": "Promise" }] }],
101+
"typescript/prefer-promise-reject-errors": "error",
102+
"typescript/restrict-plus-operands": "error",
103+
"typescript/unbound-method": "error",
104+
// These have existing findings. Change them to "error" once those are cleaned up.
105+
"typescript/no-redundant-type-constituents": "warn",
106+
"typescript/no-unnecessary-type-assertion": "warn",
107+
"typescript/restrict-template-expressions": "warn",
108+
// Not in recommended-type-checked. Replaces react/no-deprecated by flagging anything marked
109+
// @deprecated in its type definitions (React, Firebase, RxJS, ...).
110+
"typescript/no-deprecated": "warn",
111+
// Intentionally left off: the no-unsafe-* rules (they flag every use of the `any` values that
112+
// no-explicit-any already allows as a warning) and require-await (stylistic).
113+
114+
// eslint-plugin-react recommended (JSX uses the classic runtime, see "jsx" in tsconfig.json)
115+
"react/display-name": "error",
116+
"react/jsx-key": "error",
117+
"react/jsx-no-comment-textnodes": "error",
118+
"react/jsx-no-duplicate-props": "error",
119+
"react/jsx-no-target-blank": "error",
120+
"react/jsx-no-undef": "error",
121+
"react/no-children-prop": "error",
122+
"react/no-danger-with-children": "error",
123+
"react/no-direct-mutation-state": "error",
124+
"react/no-find-dom-node": "error",
125+
"react/no-is-mounted": "error",
126+
"react/no-render-return-value": "error",
127+
"react/no-string-refs": "error",
128+
"react/no-unescaped-entities": "warn",
129+
"react/no-unknown-property": "error",
130+
"react/react-in-jsx-scope": "error",
131+
132+
// eslint-plugin-react-hooks recommended, including the React Compiler rules
133+
"react/rules-of-hooks": "error",
134+
"react/exhaustive-deps": "warn",
135+
"react/static-components": "error",
136+
"react/use-memo": "error",
137+
"react/preserve-manual-memoization": "error",
138+
"react/incompatible-library": "warn",
139+
"react/immutability": "error",
140+
"react/globals": "error",
141+
"react/refs": "error",
142+
"react/set-state-in-effect": "error",
143+
"react/error-boundaries": "error",
144+
"react/purity": "error",
145+
"react/set-state-in-render": "error",
146+
"react/unsupported-syntax": "warn",
147+
148+
// Tests
149+
"vitest/no-focused-tests": "error"
150+
}
151+
}

‎docs/reference/functions/AuthCheck.md‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)