-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
108 lines (107 loc) · 3.38 KB
/
Copy patheslint.config.js
File metadata and controls
108 lines (107 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import js from "@eslint/js";
import globals from "globals";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import jsxA11y from "eslint-plugin-jsx-a11y";
import { importX } from "eslint-plugin-import-x";
import testingLibrary from "eslint-plugin-testing-library";
import tseslint from "typescript-eslint";
import { globalIgnores } from "eslint/config";
import eslintConfigPrettier from "eslint-config-prettier";
export default tseslint.config([
globalIgnores(["dist", "coverage"]),
{
files: ["**/*.{ts,tsx}"],
extends: [
js.configs.recommended,
tseslint.configs.recommendedTypeChecked,
// Only the two core rules — react-hooks v7 "recommended-latest" adds React Compiler
// rules (refs, set-state-in-effect, purity, etc.) that don't apply without the compiler.
{
plugins: { "react-hooks": reactHooks },
rules: {
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
},
},
reactRefresh.configs.vite,
jsxA11y.flatConfigs.recommended,
importX.flatConfigs.recommended,
importX.flatConfigs.typescript,
],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
settings: {
"import-x/resolver": {
typescript: true,
},
},
rules: {
// Enforce strict equality
eqeqeq: ["error", "always"],
// Disallow console.log (allow warn/error for intentional logging)
"no-console": ["warn", { allow: ["warn", "error"] }],
// Prefer const over let when variable is never reassigned
"prefer-const": "error",
// Require consistent type imports (type-only imports use `import type`)
"@typescript-eslint/consistent-type-imports": [
"error",
{ prefer: "type-imports", fixStyle: "separate-type-imports" },
],
// Tighten unused vars: error on unused vars, allow underscore-prefixed args
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
// TypeScript already catches unresolved imports; this rule has false positives with bundler moduleResolution
"import-x/no-unresolved": "off",
// Project uses allowImportingTsExtensions
"import-x/extensions": "off",
},
},
// Node environment for config and e2e files
{
files: [
"playwright.config.{ts,js}",
"tests-e2e/**",
"vite.config.{ts,js}",
"vitest.config.{ts,js}",
"eslint.config.js",
],
languageOptions: {
globals: {
...globals.node,
},
},
},
// Testing Library rules — scoped to unit test files only
{
files: ["**/*.test.{ts,tsx}", "src/test/**"],
extends: [testingLibrary.configs["flat/react"]],
},
// Disable type-aware rules for files not covered by a tsconfig
{
files: [
"**/*.test.{ts,tsx}",
"src/test/**",
"tests-e2e/**",
"knip.config.ts",
"playwright.config.{ts,js}",
"vite.config.{ts,js}",
"vitest.config.{ts,js}",
],
extends: [tseslint.configs.disableTypeChecked],
},
// Disable formatting rules that conflict with Prettier
eslintConfigPrettier,
]);