Skip to content

Commit 6c55532

Browse files
authored
chore: actually enable eslint (#1611)
It appears that eslint wasn't correctly running against the codebase, I think as a result of an older failed upgrade to eslint 9. Make it apply with our standard settings, and either fix or suppress the 98 errors that were present. Due to the quantity of errors, I've had to take the approach of just suppressing many of them so at least we can ensure we do not add new errors going forward. We should tackle all the eslint ignores over time. Draft because we need to do a fair bit of testing and review that the changes I've made here haven't broken anything.
1 parent 9833b36 commit 6c55532

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+530
-471
lines changed

.eslintignore

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

eslint.config.js

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,62 @@
11
import eslint from "@eslint/js";
2+
import { defineConfig } from "eslint/config";
23
import tseslint from "typescript-eslint";
3-
import reactRecommended from "eslint-plugin-react/configs/recommended.js";
4-
import jsxRuntime from "eslint-plugin-react/configs/jsx-runtime.js";
5-
import prettier from "eslint-config-prettier";
4+
import react from "eslint-plugin-react";
5+
import esLintConfigPrettier from "eslint-config-prettier";
66
import reactHooks from "eslint-plugin-react-hooks";
7-
import * as graphql from "@graphql-eslint/eslint-plugin";
7+
import graphqlPlugin from "@graphql-eslint/eslint-plugin";
88

9-
export default tseslint.config(
9+
export default defineConfig(
1010
eslint.configs.recommended,
11-
...tseslint.configs.recommended,
11+
tseslint.configs.recommended,
12+
react.configs.flat.recommended,
13+
react.configs.flat["jsx-runtime"],
1214
{
15+
name: "ignore generated files",
16+
ignores: [
17+
"**/*.generated.tsx",
18+
"*.json",
19+
"src/graphql-client/*.ts",
20+
"build/**",
21+
],
22+
},
23+
{
24+
name: "react hooks",
1325
plugins: {
14-
prettier,
1526
"react-hooks": reactHooks,
1627
},
17-
},
18-
{
19-
files: ["**/*.{js,cjs,jsx,mjsx,ts,tsx,mtsx}"],
20-
...reactRecommended,
21-
...jsxRuntime,
22-
settings: {
23-
react: {
24-
version: "detect",
25-
},
28+
rules: {
29+
...reactHooks.configs.recommended.rules,
2630
},
2731
},
2832
{
2933
name: "apply graphql processor to all typescript files",
3034
files: ["**/*.{ts,tsx}"],
31-
processor: graphql.processors.graphql,
35+
processor: graphqlPlugin.processor,
3236
},
3337
{
3438
name: "configure graphql linter",
3539
files: ["**/*.graphql"],
3640
plugins: {
37-
"@graphql-eslint": graphql,
41+
"@graphql-eslint": graphqlPlugin,
3842
},
3943
languageOptions: {
40-
parser: graphql,
44+
parser: graphqlPlugin.parser,
4145
},
4246
rules: {
43-
...graphql.configs["operations-recommended"].rules,
47+
...graphqlPlugin.configs["operations-recommended"].rules,
4448
"@graphql-eslint/no-deprecated": "warn",
4549
},
4650
},
4751
{
52+
settings: {
53+
react: {
54+
version: "detect",
55+
},
56+
},
57+
},
58+
{
59+
name: "our specific rules",
4860
rules: {
4961
"@typescript-eslint/explicit-module-boundary-types": "off",
5062
"@typescript-eslint/no-explicit-any": "off",
@@ -55,25 +67,11 @@ export default tseslint.config(
5567
],
5668
"@typescript-eslint/no-empty-function": "off",
5769
"@typescript-eslint/no-require-imports": "error",
58-
},
59-
ignores: [
60-
"**/*.test.ts",
61-
"src/components/TimeZonePicker/useTimeZoneList.ts",
62-
"codegen.ts",
63-
"eslint.config.js",
64-
],
65-
},
66-
{
67-
languageOptions: {
68-
parserOptions: {
69-
ecmaFeatures: {
70-
jsx: true,
71-
},
72-
ecmaVersion: 2020,
73-
project: true,
74-
sourceType: "module",
75-
tsconfigRootDir: import.meta.dirname,
76-
},
70+
"react/react-in-jsx-scope": "off",
71+
"react-hooks/exhaustive-deps": "error",
72+
"no-console": "error",
73+
eqeqeq: "error",
7774
},
7875
},
76+
esLintConfigPrettier,
7977
);

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"lint:fix": "eslint --fix src"
5252
},
5353
"devDependencies": {
54-
"@eslint/js": "8.57.1",
54+
"@eslint/js": "9.39.1",
5555
"@graphql-codegen/cli": "6.1.0",
5656
"@graphql-codegen/client-preset": "5.2.1",
5757
"@graphql-codegen/introspection": "5.0.0",
@@ -64,7 +64,7 @@
6464
"@types/react-router-dom": "5.3.3",
6565
"@vitejs/plugin-basic-ssl": "2.1.0",
6666
"@vitejs/plugin-react": "5.1.2",
67-
"eslint": "8.57.1",
67+
"eslint": "9.39.1",
6868
"eslint-config-prettier": "10.1.8",
6969
"eslint-plugin-react": "7.37.5",
7070
"eslint-plugin-react-hooks": "7.0.1",

0 commit comments

Comments
 (0)