From 51bf3781783698e8c0295aba9e1b0a606867a557 Mon Sep 17 00:00:00 2001 From: David Crespo Date: Mon, 20 Oct 2025 21:40:12 -0500 Subject: [PATCH] make oxlint do more of the eslint stuff --- .husky/pre-commit | 2 +- .oxlintrc.json | 24 +++- .prettierrc.js | 1 + app/forms/firewall-rules-common.tsx | 1 + mock-api/json-type.type-spec.ts | 3 +- package-lock.json | 186 ++++++++++++++++++++++------ package.json | 7 +- 7 files changed, 181 insertions(+), 43 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index edbaf3d6ff..b900ea94e7 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,2 +1,2 @@ # use path directly instead of npx or npm run because it's way faster -node_modules/.bin/oxlint --deny-warnings +node_modules/.bin/oxlint --type-aware --deny-warnings diff --git a/.oxlintrc.json b/.oxlintrc.json index f0e3cc7dbc..11adad5894 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -31,7 +31,29 @@ "react-hooks/exhaustive-deps": "error", "react-hooks/rules-of-hooks": "error", "import/no-default-export": "error", - "consistent-type-imports": "error" + "consistent-type-imports": "error", + + // Missing ESLint core rules + "eqeqeq": ["error", "always", { "null": "ignore" }], + "no-param-reassign": "error", + "no-return-assign": "error", + "no-restricted-imports": [ + "error", + { + // prevent confusion due to auto-imports and barrel files + "paths": ["."], + "patterns": [ + // import all CSS except index.css at top level through CSS @import statements + // to avoid bad ordering situations. See https://github.com/oxidecomputer/console/pull/2035 + "*.css" + ] + } + ], + "radix": "error", + + // TypeScript rules (currently disabled but available) + "@typescript-eslint/no-floating-promises": "off", + "@typescript-eslint/unbound-method": "off" }, "overrides": [ { diff --git a/.prettierrc.js b/.prettierrc.js index 73997802c7..899aa78c16 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -6,6 +6,7 @@ * Copyright Oxide Computer Company */ +// eslint-disable-next-line no-default-export export default { // note: it seems like tailwind has to be last for it to work plugins: ['@ianvs/prettier-plugin-sort-imports', 'prettier-plugin-tailwindcss'], diff --git a/app/forms/firewall-rules-common.tsx b/app/forms/firewall-rules-common.tsx index 595f8f8657..2fcb18bc15 100644 --- a/app/forms/firewall-rules-common.tsx +++ b/app/forms/firewall-rules-common.tsx @@ -68,6 +68,7 @@ import { type FirewallRuleValues } from './firewall-rules-util' type TargetAndHostFilterType = | VpcFirewallRuleTarget['type'] + // eslint-disable-next-line @typescript-eslint/no-duplicate-type-constituents | VpcFirewallRuleHostFilter['type'] type TargetAndHostFormValues = { diff --git a/mock-api/json-type.type-spec.ts b/mock-api/json-type.type-spec.ts index dae4dbda80..0ed23f37e3 100644 --- a/mock-api/json-type.type-spec.ts +++ b/mock-api/json-type.type-spec.ts @@ -15,7 +15,8 @@ import type { Json } from './json-type' // are not equal. There's no point in wrapping this in a real test because it // will always pass. -let val: any // eslint-disable-line @typescript-eslint/no-explicit-any +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const val: any = undefined // just checking :) assertType<1>(val as 1) diff --git a/package-lock.json b/package-lock.json index 7aca50f5b6..8961b8831d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -89,7 +89,8 @@ "ip-num": "^1.5.1", "jsdom": "^25.0.1", "msw": "^2.7.5", - "oxlint": "^1.6.0", + "oxlint": "^1.23.0", + "oxlint-tsgolint": "^0.2.0", "patch-package": "^8.0.0", "postcss": "^8.4.49", "postcss-import": "^16.1.0", @@ -1572,10 +1573,94 @@ "react-dom": ">=18.0.0" } }, + "node_modules/@oxlint-tsgolint/darwin-arm64": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@oxlint-tsgolint/darwin-arm64/-/darwin-arm64-0.2.0.tgz", + "integrity": "sha512-ayJO9SmiJ15oV3+svIw8bqun0ySdjiD7L+ddwNB4vOAgUX/rdX1KTBnDb/ZEk6MOFBnFgbbiEiLRJLlGtuFYVQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@oxlint-tsgolint/darwin-x64": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@oxlint-tsgolint/darwin-x64/-/darwin-x64-0.2.0.tgz", + "integrity": "sha512-iCrcjkqqyy3zq+yXOmNsjt/DiSU4u9yJ00hEr4oGSrrk7V0ju6eqrmsh8VGS74YLY3MCskTjeTyVDRR7huc3WQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@oxlint-tsgolint/linux-arm64": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@oxlint-tsgolint/linux-arm64/-/linux-arm64-0.2.0.tgz", + "integrity": "sha512-Kne4mrJGCZ0O+/ukcvWftCmDAEFUpMQ4q4wZdWVlnmNdTbtICIay3ofk/rzX0QoZmEZh0jy/G7p+5P0t9Bg5Sg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@oxlint-tsgolint/linux-x64": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@oxlint-tsgolint/linux-x64/-/linux-x64-0.2.0.tgz", + "integrity": "sha512-DKGFSR71fnExWpJXvN32SqWuEcT1XXeI1CKpO63jgXTAUpVl9H/BXG3+gNptSoZqzqeFTj8jOgiaX6VkOABqGA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@oxlint-tsgolint/win32-arm64": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@oxlint-tsgolint/win32-arm64/-/win32-arm64-0.2.0.tgz", + "integrity": "sha512-Grbkva1YH0eTRtv3MkVTFAycVwQSytcl8N52zNs1YresWwOlnNvNZ5EeLIaQaudcxwsbpZWR2Bdsfa467zDJTw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@oxlint-tsgolint/win32-x64": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@oxlint-tsgolint/win32-x64/-/win32-x64-0.2.0.tgz", + "integrity": "sha512-asfPqgu7r1H8NmBNxfMpZER6WvrUTH8BDMPIcChBhrUjuSmt4UMyiyul3CEPZLPQcPlaWCeGnConTu3BabK4Fw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@oxlint/darwin-arm64": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@oxlint/darwin-arm64/-/darwin-arm64-1.6.0.tgz", - "integrity": "sha512-m3wyqBh1TOHjpr/dXeIZY7OoX+MQazb+bMHQdDtwUvefrafUx+5YHRvulYh1sZSQ449nQ3nk3qj5qj535vZRjg==", + "version": "1.23.0", + "resolved": "https://registry.npmjs.org/@oxlint/darwin-arm64/-/darwin-arm64-1.23.0.tgz", + "integrity": "sha512-sbxoftgEMKmZQO7O4wHR9Rs7MfiHa2UH2x4QJDoc4LXqSCsI4lUIJbFQ05vX+zOUbt7CQMPdxEzExd4DqeKY2w==", "cpu": [ "arm64" ], @@ -1587,9 +1672,9 @@ ] }, "node_modules/@oxlint/darwin-x64": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@oxlint/darwin-x64/-/darwin-x64-1.6.0.tgz", - "integrity": "sha512-75fJfF/9xNypr7cnOYoZBhfmG1yP7ex3pUOeYGakmtZRffO9z1i1quLYhjZsmaDXsAIZ3drMhenYHMmFKS3SRg==", + "version": "1.23.0", + "resolved": "https://registry.npmjs.org/@oxlint/darwin-x64/-/darwin-x64-1.23.0.tgz", + "integrity": "sha512-PjByWr1TlwHQiOqEc8CPyXCT4wnujSK3n9l1m4un0Eh0uLJEDG5WM9tyDWOGuakC0Ika9/SMp0HDRg3ySchRRA==", "cpu": [ "x64" ], @@ -1601,9 +1686,9 @@ ] }, "node_modules/@oxlint/linux-arm64-gnu": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@oxlint/linux-arm64-gnu/-/linux-arm64-gnu-1.6.0.tgz", - "integrity": "sha512-YhXGf0FXa72bEt4F7eTVKx5X3zWpbAOPnaA/dZ6/g8tGhw1m9IFjrabVHFjzcx3dQny4MgA59EhyElkDvpUe8A==", + "version": "1.23.0", + "resolved": "https://registry.npmjs.org/@oxlint/linux-arm64-gnu/-/linux-arm64-gnu-1.23.0.tgz", + "integrity": "sha512-sWlCwQ6xKeKC08qU3SfozqpRGCLJiO/onPYFJKEHbjzHkFp+OubOacFaT4ePcka28jCU1TvQ7Gi5BVQRncr0Xg==", "cpu": [ "arm64" ], @@ -1615,9 +1700,9 @@ ] }, "node_modules/@oxlint/linux-arm64-musl": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@oxlint/linux-arm64-musl/-/linux-arm64-musl-1.6.0.tgz", - "integrity": "sha512-T3JDhx8mjGjvh5INsPZJrlKHmZsecgDYvtvussKRdkc1Nnn7WC+jH9sh5qlmYvwzvmetlPVNezAoNvmGO9vtMg==", + "version": "1.23.0", + "resolved": "https://registry.npmjs.org/@oxlint/linux-arm64-musl/-/linux-arm64-musl-1.23.0.tgz", + "integrity": "sha512-MPkmSiezuVgjMbzDSkRhENdnb038JOI+OTpBrOho2crbCAuqSRvyFwkMRhncJGZskzo1yeKxrKXB8T83ofmSXw==", "cpu": [ "arm64" ], @@ -1629,9 +1714,9 @@ ] }, "node_modules/@oxlint/linux-x64-gnu": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@oxlint/linux-x64-gnu/-/linux-x64-gnu-1.6.0.tgz", - "integrity": "sha512-Dx7ghtAl8aXBdqofJpi338At6lkeCtTfoinTYQXd9/TEJx+f+zCGNlQO6nJz3ydJBX48FDuOFKkNC+lUlWrd8w==", + "version": "1.23.0", + "resolved": "https://registry.npmjs.org/@oxlint/linux-x64-gnu/-/linux-x64-gnu-1.23.0.tgz", + "integrity": "sha512-F6H9wmLfjBoNqtsgyg3P9abLnkVjNbCAnISKdRtDl7HvkMs4s/eU8np9+tSnqPeKOTBhkS+h/VSWgPGZTqIWQA==", "cpu": [ "x64" ], @@ -1643,9 +1728,9 @@ ] }, "node_modules/@oxlint/linux-x64-musl": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@oxlint/linux-x64-musl/-/linux-x64-musl-1.6.0.tgz", - "integrity": "sha512-7KvMGdWmAZtAtg6IjoEJHKxTXdAcrHnUnqfgs0JpXst7trquV2mxBeRZusQXwxpu4HCSomKMvJfsp1qKaqSFDg==", + "version": "1.23.0", + "resolved": "https://registry.npmjs.org/@oxlint/linux-x64-musl/-/linux-x64-musl-1.23.0.tgz", + "integrity": "sha512-Xra0Cow35mAku8mbUbviPRalTU4Ct6MXQ1Eue8GmN4HFkjosrNa5qfy7QkJBqzjiI+JdnHxPXwackGn92/XOQw==", "cpu": [ "x64" ], @@ -1657,9 +1742,9 @@ ] }, "node_modules/@oxlint/win32-arm64": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@oxlint/win32-arm64/-/win32-arm64-1.6.0.tgz", - "integrity": "sha512-iSGC9RwX+dl7o5KFr5aH7Gq3nFbkq/3Gda6mxNPMvNkWrgXdIyiINxpyD8hJu566M+QSv1wEAu934BZotFDyoQ==", + "version": "1.23.0", + "resolved": "https://registry.npmjs.org/@oxlint/win32-arm64/-/win32-arm64-1.23.0.tgz", + "integrity": "sha512-FR+I+uGD3eFzTfBw87QRr+Y1jBYil3TqPM0wkSvuf3gOJTEXAfSkh9QHCgQqrseW3HDW7YJJ8ty1+sU31H/N4g==", "cpu": [ "arm64" ], @@ -1671,9 +1756,9 @@ ] }, "node_modules/@oxlint/win32-x64": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@oxlint/win32-x64/-/win32-x64-1.6.0.tgz", - "integrity": "sha512-jOj3L/gfLc0IwgOTkZMiZ5c673i/hbAmidlaylT0gE6H18hln9HxPgp5GCf4E4y6mwEJlW8QC5hQi221+9otdA==", + "version": "1.23.0", + "resolved": "https://registry.npmjs.org/@oxlint/win32-x64/-/win32-x64-1.23.0.tgz", + "integrity": "sha512-/oX0b26YIC1OgS5B+G8Ux1Vs/PIjOP4CBRzsPpYr0T+RoboJ3ZuV32bztLRggJKQqIlozcqiRo9fl/UMOMp8kQ==", "cpu": [ "x64" ], @@ -12052,9 +12137,9 @@ } }, "node_modules/oxlint": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/oxlint/-/oxlint-1.6.0.tgz", - "integrity": "sha512-jtaD65PqzIa1udvSxxscTKBxYKuZoFXyKGLiU1Qjo1ulq3uv/fQDtoV1yey1FrQZrQjACGPi1Widsy1TucC7Jg==", + "version": "1.23.0", + "resolved": "https://registry.npmjs.org/oxlint/-/oxlint-1.23.0.tgz", + "integrity": "sha512-cLVdSE7Bza8npm+PffU0oufs15+M5uSMbQn0k2fJCayWU0xqQ3dyA3w9tEk8lgNOk1j1VJEdYctz64Vik8VG1w==", "dev": true, "license": "MIT", "bin": { @@ -12062,20 +12147,47 @@ "oxlint": "bin/oxlint" }, "engines": { - "node": ">=8.*" + "node": "^20.19.0 || >=22.12.0" }, "funding": { "url": "https://github.com/sponsors/Boshen" }, "optionalDependencies": { - "@oxlint/darwin-arm64": "1.6.0", - "@oxlint/darwin-x64": "1.6.0", - "@oxlint/linux-arm64-gnu": "1.6.0", - "@oxlint/linux-arm64-musl": "1.6.0", - "@oxlint/linux-x64-gnu": "1.6.0", - "@oxlint/linux-x64-musl": "1.6.0", - "@oxlint/win32-arm64": "1.6.0", - "@oxlint/win32-x64": "1.6.0" + "@oxlint/darwin-arm64": "1.23.0", + "@oxlint/darwin-x64": "1.23.0", + "@oxlint/linux-arm64-gnu": "1.23.0", + "@oxlint/linux-arm64-musl": "1.23.0", + "@oxlint/linux-x64-gnu": "1.23.0", + "@oxlint/linux-x64-musl": "1.23.0", + "@oxlint/win32-arm64": "1.23.0", + "@oxlint/win32-x64": "1.23.0" + }, + "peerDependencies": { + "oxlint-tsgolint": ">=0.2.0" + }, + "peerDependenciesMeta": { + "oxlint-tsgolint": { + "optional": true + } + } + }, + "node_modules/oxlint-tsgolint": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/oxlint-tsgolint/-/oxlint-tsgolint-0.2.0.tgz", + "integrity": "sha512-37Hy+FT1sz8hHUo31JIgFDA8NcFndexrg5okutWRPXNejJwB9hKN+pyInaQQIv4XDsgNcQsSR2VJoq99eaGk9g==", + "dev": true, + "license": "MIT", + "peer": true, + "bin": { + "tsgolint": "bin/tsgolint.js" + }, + "optionalDependencies": { + "@oxlint-tsgolint/darwin-arm64": "0.2.0", + "@oxlint-tsgolint/darwin-x64": "0.2.0", + "@oxlint-tsgolint/linux-arm64": "0.2.0", + "@oxlint-tsgolint/linux-x64": "0.2.0", + "@oxlint-tsgolint/win32-arm64": "0.2.0", + "@oxlint-tsgolint/win32-x64": "0.2.0" } }, "node_modules/p-limit": { diff --git a/package.json b/package.json index 8e2d5cf7bd..c561ed1207 100644 --- a/package.json +++ b/package.json @@ -24,8 +24,8 @@ "e2ec": "playwright test --project=chrome", "visual:baseline": "./tools/generate-visual-baseline.sh", "visual:compare": "./tools/compare-visual-changes.sh", - "lint": "oxlint && eslint --ext .js,.ts,.tsx app test mock-api", - "oxlint": "oxlint", + "lint": "oxlint --type-aware && eslint --ext .js,.ts,.tsx app test mock-api", + "oxlint": "oxlint --type-aware", "fmt": "prettier --cache --write . && npm run lint -- --fix", "openapi-gen-ts": "openapi-gen-ts", "prettier": "prettier", @@ -114,7 +114,8 @@ "ip-num": "^1.5.1", "jsdom": "^25.0.1", "msw": "^2.7.5", - "oxlint": "^1.6.0", + "oxlint": "^1.23.0", + "oxlint-tsgolint": "^0.2.0", "patch-package": "^8.0.0", "postcss": "^8.4.49", "postcss-import": "^16.1.0",