Repository navigation
Expand file tree
/
Copy patheslint.config.js
More file actions
121 lines (114 loc) · 3.46 KB
/
Copy patheslint.config.js
File metadata and controls
121 lines (114 loc) · 3.46 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
121
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import tseslint from "typescript-eslint";
import reactPlugin from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import prettierPlugin from "eslint-plugin-prettier";
import prettierConfig from "eslint-config-prettier";
import globals from "globals";
// Load .prettierrc explicitly instead of letting eslint-plugin-prettier
// resolve it via its own cosmiconfig search, so eslint --fix always agrees
// with the prettier CLI.
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const prettierOptions = JSON.parse(fs.readFileSync(path.join(__dirname, ".prettierrc"), "utf8"));
export default tseslint.config(
{
ignores: [
"src/generated",
"dist",
"build",
"server/dist",
"server/public",
"playwright-report",
"test-results",
],
},
{
extends: [...tseslint.configs.recommended],
files: ["src/**/*.{ts,tsx}"],
languageOptions: {
globals: globals.browser,
},
plugins: {
react: reactPlugin,
"react-hooks": reactHooks,
prettier: prettierPlugin,
},
rules: {
...reactPlugin.configs.recommended.rules,
...reactHooks.configs.recommended.rules,
...prettierConfig.rules,
// Prettier integration
"prettier/prettier": ["error", prettierOptions],
// Security: ban dangerouslySetInnerHTML — XSS vector
"react/no-danger": "error",
// Security: ban eval() — blocked by CSP too, but belt-and-suspenders
"no-eval": "error",
"no-implied-eval": "error",
// Security: ban Function constructor — equivalent to eval
"no-new-func": "error",
"react/react-in-jsx-scope": "off",
"react/prop-types": "off",
// Allow `_`-prefixed locals to signal intentional discard (destructured
// rest patterns that strip a key, unused catch bindings, etc).
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
destructuredArrayIgnorePattern: "^_",
},
],
},
settings: {
react: { version: "detect" },
},
},
{
extends: [...tseslint.configs.recommended],
files: ["e2e/**/*.ts", "playwright.config.ts"],
languageOptions: {
globals: { ...globals.node, ...globals.browser },
},
plugins: {
prettier: prettierPlugin,
},
rules: {
...prettierConfig.rules,
"prettier/prettier": ["error", prettierOptions],
"no-eval": "error",
"no-implied-eval": "error",
"no-new-func": "error",
},
},
{
extends: [...tseslint.configs.recommended],
files: ["server/**/*.ts"],
languageOptions: {
globals: globals.node,
},
plugins: {
prettier: prettierPlugin,
},
rules: {
...prettierConfig.rules,
"prettier/prettier": ["error", prettierOptions],
"no-eval": "error",
"no-implied-eval": "error",
"no-new-func": "error",
// Allow `_`-prefixed locals to signal intentional discard (destructured
// rest patterns that strip a key, unused catch bindings, etc).
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
destructuredArrayIgnorePattern: "^_",
},
],
},
},
);