Remove dead code and unused imports, drop useless assignments, and tune rules in eslint.config.js (underscore-prefixed unused names, intentional BOM/NBSP, React Compiler rules from eslint-plugin-react-hooks 7 as warnings).
51 lines
1.9 KiB
JavaScript
51 lines
1.9 KiB
JavaScript
import js from "@eslint/js";
|
|
import globals from "globals";
|
|
import tseslint from "typescript-eslint";
|
|
import reactHooks from "eslint-plugin-react-hooks";
|
|
|
|
export default tseslint.config(
|
|
{
|
|
ignores: ["node_modules/", "dist/", "src-tauri/", "public/", "docs/", "playwright-report/", "test-results/"],
|
|
},
|
|
js.configs.recommended,
|
|
tseslint.configs.recommended,
|
|
reactHooks.configs.flat.recommended,
|
|
{
|
|
rules: {
|
|
// Leading underscore marks an intentionally unused binding (omitting a key via rest, unused
|
|
// override parameters).
|
|
"@typescript-eslint/no-unused-vars": [
|
|
"error",
|
|
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_", caughtErrorsIgnorePattern: "^_", ignoreRestSiblings: true },
|
|
],
|
|
// The BOM and NBSP are written literally on purpose in the CSV exporters and the text sanitiser.
|
|
"no-irregular-whitespace": ["error", { skipStrings: true, skipTemplates: true, skipRegExps: true }],
|
|
},
|
|
},
|
|
{
|
|
// The React Compiler rules shipped in eslint-plugin-react-hooks 7 flag long-standing patterns
|
|
// here (load data on mount, "latest value" refs written during render). They are legitimate
|
|
// design feedback but not bugs, and rewriting them blind risks behaviour changes in an
|
|
// effect-heavy app, so they stay visible as warnings until each site is reworked.
|
|
files: ["src/**/*.{ts,tsx}"],
|
|
rules: {
|
|
"react-hooks/set-state-in-effect": "warn",
|
|
"react-hooks/refs": "warn",
|
|
"react-hooks/immutability": "warn",
|
|
},
|
|
},
|
|
{
|
|
// Test helper that reads react-pdf's untyped internal layout data.
|
|
files: ["src/pdf/testing/**/*.ts"],
|
|
rules: { "@typescript-eslint/no-explicit-any": "warn" },
|
|
},
|
|
{
|
|
files: ["src/**/*.{ts,tsx}"],
|
|
languageOptions: { globals: globals.browser },
|
|
},
|
|
{
|
|
files: ["scripts/**/*.{js,mjs}", "e2e/**/*.ts", "*.config.{js,ts}"],
|
|
languageOptions: { globals: globals.node },
|
|
},
|
|
);
|