-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
120 lines (115 loc) · 3.64 KB
/
eslint.config.js
File metadata and controls
120 lines (115 loc) · 3.64 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
109
110
111
112
113
114
115
116
117
118
119
120
// For more info, see https://github.com/storybookjs/eslint-plugin-storybook#configuration-flat-config-format
// Flat ESLint config for React + TypeScript (ESLint 9+ compatible)
import js from "@eslint/js";
import prettier from "eslint-config-prettier";
import importPlugin from "eslint-plugin-import";
import jsxA11y from "eslint-plugin-jsx-a11y";
import react from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import simpleImportSort from "eslint-plugin-simple-import-sort";
import storybook from "eslint-plugin-storybook";
import unusedImports from "eslint-plugin-unused-imports";
import globals from "globals";
import tseslint from "typescript-eslint";
export default tseslint.config(
// Ignore build artefacts, snapshots, etc.
{
ignores: [
"dist/**",
"build/**",
"node_modules/**",
"playwright-report/**",
"test-results/**",
"e2e/__screenshots__/**",
],
}, // Base JS rules
js.configs.recommended, // TS rules (non-type-checked to keep it fast; switch to recommendedTypeChecked if desired)
...tseslint.configs.recommended, // App rules
{
files: ["**/*.{ts,tsx,js,jsx}"],
languageOptions: {
ecmaVersion: 2023,
sourceType: "module",
globals: { ...globals.browser, ...globals.node },
// For type-aware rules, set parserOptions.project to your tsconfig and use configs.recommendedTypeChecked
parserOptions: { warnOnUnsupportedTypeScriptVersion: false },
},
plugins: {
react,
"react-hooks": reactHooks,
"jsx-a11y": jsxA11y,
import: importPlugin,
"unused-imports": unusedImports,
"simple-import-sort": simpleImportSort,
},
settings: {
react: { version: "detect" },
"import/resolver": {
node: { extensions: [".js", ".jsx", ".ts", ".tsx"] },
},
},
rules: {
// React
"react/react-in-jsx-scope": "off",
"react/prop-types": "off",
"react/jsx-uses-react": "off",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
// Accessibility
"jsx-a11y/anchor-is-valid": "warn",
// Imports
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"import/no-unresolved": "off", // let TS handle it
"import/no-duplicates": "warn",
// Unused code
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
args: "after-used",
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
},
],
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"warn",
{
args: "after-used",
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
},
],
// General hygiene
"no-console": process.env.CI ? "warn" : "off",
"no-debugger": process.env.CI ? "error" : "warn",
},
}, // CommonJS configs (e.g., stylelint.config.cjs)
{
files: ["**/*.cjs", "**/*.config.cjs"],
languageOptions: {
ecmaVersion: 2023,
sourceType: "commonjs",
globals: { ...globals.node, ...globals.commonjs },
},
rules: {
// Config files often log or import dynamically
"no-console": "off",
"import/no-unresolved": "off",
},
}, // Node ESM scripts/utilities (e.g., *.mjs)
{
files: ["**/*.mjs", "**/*.config.mjs"],
languageOptions: {
ecmaVersion: 2023,
sourceType: "module",
globals: { ...globals.node },
},
rules: {
"no-console": "off",
},
}, // Disable stylistic rules that Prettier handles
prettier,
storybook.configs["flat/recommended"]
);