-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
163 lines (148 loc) · 4.4 KB
/
eslint.config.mjs
File metadata and controls
163 lines (148 loc) · 4.4 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import eslint from "@eslint/js";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import promisePlugin from "eslint-plugin-promise";
import reactPlugin from "eslint-plugin-react";
import reactHooksPlugin from "eslint-plugin-react-hooks";
export default [
// Ignore patterns
{
ignores: ["dist/**", "node_modules/**", "*.d.ts"],
},
// ESLint recommended baseline for all files
eslint.configs.recommended,
// TypeScript and TSX files configuration
{
files: ["**/*.ts", "**/*.tsx"],
plugins: {
"@typescript-eslint": typescriptEslint,
promise: promisePlugin,
react: reactPlugin,
"react-hooks": reactHooksPlugin,
},
settings: {
react: {
version: "19.2",
},
},
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: 2022,
sourceType: "module",
projectService: true,
ecmaFeatures: {
jsx: true,
},
},
globals: {
// Browser API globals (for webview/React components)
window: "readonly",
document: "readonly",
MessageEvent: "readonly",
navigator: "readonly",
fetch: "readonly",
console: "readonly",
// Node.js globals (for extension backend code)
process: "readonly",
Buffer: "readonly",
global: "readonly",
__dirname: "readonly",
__filename: "readonly",
setImmediate: "readonly",
clearImmediate: "readonly",
setInterval: "readonly",
clearInterval: "readonly",
setTimeout: "readonly",
clearTimeout: "readonly",
// Mocha test globals
describe: "readonly",
it: "readonly",
before: "readonly",
after: "readonly",
beforeEach: "readonly",
afterEach: "readonly",
suite: "readonly",
test: "readonly",
setup: "readonly",
teardown: "readonly",
suiteSetup: "readonly",
suiteTeardown: "readonly",
React: "readonly",
},
},
rules: {
"no-unused-vars": "off",
// TypeScript ESLint recommended rules (non-type-checked)
"@typescript-eslint/no-unused-vars": [
"warn",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
},
],
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-inferrable-types": "warn",
"@typescript-eslint/no-empty-interface": "warn",
"@typescript-eslint/no-var-requires": "warn",
"@typescript-eslint/prefer-as-const": "warn",
// Naming conventions
"@typescript-eslint/naming-convention": [
"warn",
{
selector: "import",
format: ["camelCase", "PascalCase"],
},
],
// Code quality and consistency rules
curly: "warn",
eqeqeq: "warn",
"no-throw-literal": "warn",
"prefer-promise-reject-errors": "warn",
"no-unsafe-finally": "warn",
"no-async-promise-executor": "warn",
"@typescript-eslint/only-throw-error": "warn",
"@typescript-eslint/no-floating-promises": "warn",
"@typescript-eslint/no-misused-promises": [
"warn",
{
checksVoidReturn: false,
},
],
"@typescript-eslint/use-unknown-in-catch-callback-variable": "warn",
"promise/catch-or-return": "warn",
"promise/always-return": "warn",
"promise/param-names": "warn",
"promise/no-return-wrap": "warn",
"no-useless-catch": "warn",
semi: "warn",
"no-console": [
"warn",
{
allow: ["warn", "error"],
},
],
"no-var": "warn",
"prefer-const": "warn",
"prefer-arrow-callback": "warn",
"no-empty-function": "warn",
// React rules
"react/react-in-jsx-scope": "off",
"react/prop-types": "off", // Using TypeScript for prop validation
"react/no-unescaped-entities": "warn",
"react/display-name": "warn",
"react-hooks/rules-of-hooks": "warn",
"react-hooks/exhaustive-deps": "warn",
},
},
// Test files - slightly relaxed
{
files: ["**/*.test.ts", "**/*.spec.ts", "src/test/**"],
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"no-console": "off",
},
},
];