-
Notifications
You must be signed in to change notification settings - Fork 116
Expand file tree
/
Copy patheslint.config.mjs
More file actions
237 lines (217 loc) · 7.09 KB
/
Copy patheslint.config.mjs
File metadata and controls
237 lines (217 loc) · 7.09 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat'
import { FlatCompat } from '@eslint/eslintrc'
import js from '@eslint/js'
import typescriptEslint from '@typescript-eslint/eslint-plugin'
import tsParser from '@typescript-eslint/parser'
import cssModules from 'eslint-plugin-css-modules'
import jsxA11Y from 'eslint-plugin-jsx-a11y'
import react from 'eslint-plugin-react'
import reactHooks from 'eslint-plugin-react-hooks'
import reactPerf from 'eslint-plugin-react-perf'
import suggestNoThrow from 'eslint-plugin-suggest-no-throw'
import { defineConfig, globalIgnores } from 'eslint/config'
import noCodemirrorPrintableKeymapKeystrokes from './src/eslint/rules/no-codemirror-printable-keymap-keystrokes.mjs'
const compat = new FlatCompat({
baseDirectory: import.meta.dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
})
export default defineConfig([
globalIgnores([
'rust/**/*.ts',
'!rust/kcl-language-server/client/src/**/*.ts',
'**/*.typegen.ts',
'packages/codemirror-lsp-client/dist/*',
'**/.vscode-test',
]),
{
files: ['**/*.ts', '**/*.tsx'],
linterOptions: {
reportUnusedDisableDirectives: false,
},
extends: fixupConfigRules(
compat.extends(
'plugin:css-modules/recommended',
'plugin:jsx-a11y/recommended',
'plugin:react-hooks/recommended'
)
),
plugins: {
'react-perf': reactPerf,
'css-modules': fixupPluginRules(cssModules),
'jsx-a11y': fixupPluginRules(jsxA11Y),
react,
'react-hooks': fixupPluginRules(reactHooks),
'suggest-no-throw': suggestNoThrow,
'@typescript-eslint': typescriptEslint,
zds: {
rules: {
'no-codemirror-printable-keymap-keystrokes':
noCodemirrorPrintableKeymapKeystrokes,
},
},
},
languageOptions: {
parser: tsParser,
ecmaVersion: 5,
sourceType: 'script',
parserOptions: {
project: './tsconfig.json',
},
},
settings: {
react: {
version: 'detect',
},
},
rules: {
'no-array-constructor': 'off',
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/no-array-delete': 'error',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/no-duplicate-enum-values': 'error',
'@typescript-eslint/no-duplicate-type-constituents': 'error',
'@typescript-eslint/no-empty-object-type': 'error',
'@typescript-eslint/no-extra-non-null-assertion': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'no-implied-eval': 'off',
'@typescript-eslint/no-implied-eval': 'error',
'@typescript-eslint/no-invalid-void-type': [
'error',
{
allowAsThisParameter: true,
},
],
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
'@typescript-eslint/no-redundant-type-constituents': 'error',
'@typescript-eslint/no-this-alias': 'warn',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
'@typescript-eslint/no-unnecessary-type-parameters': 'error',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
varsIgnorePattern: '^_',
argsIgnorePattern: '^_',
ignoreRestSiblings: true,
vars: 'all',
args: 'none',
},
],
'@typescript-eslint/no-unsafe-unary-minus': 'error',
'@typescript-eslint/no-unused-expressions': 'error',
'@typescript-eslint/no-wrapper-object-types': 'error',
'no-throw-literal': 'off',
'@typescript-eslint/only-throw-error': 'error',
'@typescript-eslint/prefer-as-const': 'warn',
'@typescript-eslint/prefer-namespace-keyword': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/restrict-plus-operands': 'error',
'@typescript-eslint/unbound-method': 'error',
'jsx-a11y/click-events-have-key-events': 'off',
'jsx-a11y/no-autofocus': 'off',
'jsx-a11y/no-noninteractive-element-interactions': 'off',
'react/no-unknown-property': 'error',
'no-restricted-globals': [
'error',
{
name: 'isNaN',
message: 'Use Number.isNaN() instead.',
},
],
'no-restricted-syntax': [
'error',
{
selector:
"CallExpression[callee.object.name='Array'][callee.property.name='isArray']",
message: 'Use isArray() in lib/utils.ts instead of Array.isArray().',
},
{
selector:
"CallExpression[callee.object.name='TOML'][callee.property.name='stringify']",
message:
'Do not use TOML.stringify directly. Use the wrappers in test-utils instead like settingsToToml.',
},
{
selector:
"CallExpression[callee.object.name='TOML'][callee.property.name='parse']",
message:
'Do not use TOML.parse directly. Use the wrappers in test-utils instead like tomlToSettings.',
},
{
selector:
"CallExpression[callee.property.name='split'] > Literal[value='/']",
message: "Avoid using split with '/'.",
},
{
selector:
"CallExpression[callee.property.name='join'] > Literal[value='/']",
message: "Avoid using join with '/'.",
},
],
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['./*', '../*', '!./*.css', '!../*.css'],
message: 'Use absolute imports instead.',
},
],
},
],
'no-warning-comments': [
'error',
{
terms: ['Menu.setApplicationMenu(null)'],
},
],
semi: ['error', 'never'],
'react-hooks/exhaustive-deps': 'error',
'suggest-no-throw/suggest-no-throw': 'error',
'zds/no-codemirror-printable-keymap-keystrokes': 'error',
},
},
{
files: ['e2e/**/*.ts'],
extends: compat.extends('plugin:testing-library/react'),
rules: {
'suggest-no-throw/suggest-no-throw': 'off',
'testing-library/prefer-screen-queries': 'off',
},
},
{
files: ['src/**/*.test.ts', 'src/**/*.spec.ts'],
extends: compat.extends('plugin:testing-library/react'),
rules: {
'suggest-no-throw/suggest-no-throw': 'off',
},
},
{
files: [
'src/registry/extensions/**/*.{ts,tsx}',
'src/registry/plugins/**/*.{ts,tsx}',
],
rules: {
'no-restricted-imports': 'off',
},
},
{
files: ['packages/**/*.{ts,tsx}', 'rust/**/*.ts'],
extends: compat.extends(),
rules: {
'no-restricted-imports': 'off',
},
},
{
files: ['packages/registry/src/**/*.{ts,tsx}'],
rules: {
'suggest-no-throw/suggest-no-throw': 'off',
},
},
])