-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheslint.config.mjs
More file actions
109 lines (107 loc) · 3.51 KB
/
Copy patheslint.config.mjs
File metadata and controls
109 lines (107 loc) · 3.51 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
import tsParser from "@typescript-eslint/parser";
import tsPlugin from "@typescript-eslint/eslint-plugin";
import reactPlugin from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
const eslintConfig = [
// Global ignores (replaces .eslintignore)
{
ignores: [
"**/node_modules/**",
"**/.next/**",
"**/out/**",
"**/dist/**",
"**/build/**",
"**/storybook-static/**",
"**/coverage/**",
"**/.turbo/**",
"**/public/**",
"**/*.config.js",
"**/*.config.ts",
"**/packages/*/dist/**",
"**/test-installation/**",
"**/packages/ndpr-toolkit/dist/**",
// standalone scaffolds with their own toolchains
"examples/**",
"phase1/**",
".remember/**",
],
},
{
files: ["**/*.{ts,tsx}"],
languageOptions: {
parser: tsParser,
parserOptions: { ecmaFeatures: { jsx: true } },
},
plugins: {
"@typescript-eslint": tsPlugin,
react: reactPlugin,
"react-hooks": reactHooks,
},
settings: { react: { version: "detect" } },
rules: {
...tsPlugin.configs.recommended.rules,
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
// Was "off", which let 45 unused imports and locals accumulate that CodeQL
// then reported as js/unused-local-variable. Enabled so lint is the gate
// and the alerts can't come back. `_`-prefixed names stay allowed for
// deliberately-unused positional args and destructuring holes.
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
"@typescript-eslint/no-empty-object-type": "off",
"react/no-unescaped-entities": "off",
"@typescript-eslint/no-explicit-any": "off",
},
},
// Plain-JS tooling: scripts/, bin/, hooks and config helpers. The TS block
// above only matches **/*.{ts,tsx}, so .mjs/.js files were linted with no
// rules at all — which is how an unused import in scripts/verify-examples.mjs
// reached main and got reported by CodeQL instead of by lint.
{
files: ["**/*.{js,mjs,cjs}"],
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
plugins: { "@typescript-eslint": tsPlugin },
rules: {
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
},
},
// tests exercise the CJS entry points and jest mocks via require()
{
files: ["**/__tests__/**", "**/*.test.{ts,tsx}"],
rules: {
"@typescript-eslint/no-require-imports": "off",
"@typescript-eslint/no-unsafe-function-type": "off",
},
},
// Raw create-ndpr templates are Handlebars sources, not ordinary modules: a
// declaration can be referenced only from inside a {{#if}} branch that a
// given render strips, so "unused" here is not a reliable signal. The CodeQL
// config excludes these same paths for the related reason that mutually
// exclusive branches aren't valid TypeScript until rendered. The rendered
// output is what gets linted and strictly typechecked, by verify:create-ndpr.
{
files: ["packages/create-ndpr/templates/**"],
rules: {
"@typescript-eslint/no-unused-vars": "off",
},
},
];
export default eslintConfig;