UNPKG

11.2 kBJavaScriptView Raw
1/*!
2 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3 * Licensed under the MIT License.
4 */
5
6module.exports = {
7 env: {
8 browser: true,
9 es6: true,
10 es2024: false,
11 node: true,
12 },
13 extends: [
14 "eslint:recommended",
15 "plugin:eslint-comments/recommended",
16 "plugin:@typescript-eslint/eslint-recommended",
17 "plugin:@typescript-eslint/recommended-type-checked",
18 "plugin:@typescript-eslint/stylistic-type-checked",
19 // import/recommended is the combination of import/errors and import/warnings
20 "plugin:import/recommended",
21 "plugin:import/typescript",
22 ],
23 globals: {
24 Atomics: "readonly",
25 SharedArrayBuffer: "readonly",
26 },
27 parser: "@typescript-eslint/parser",
28 parserOptions: {
29 ecmaFeatures: {
30 jsx: true,
31 },
32 ecmaVersion: 2018,
33 sourceType: "module",
34 project: "./tsconfig.json",
35 },
36 plugins: ["import", "unicorn"],
37 reportUnusedDisableDirectives: true,
38 rules: {
39 // Please keep entries alphabetized within a group
40
41 // @typescript-eslint
42 "@typescript-eslint/adjacent-overload-signatures": "error",
43 "@typescript-eslint/array-type": "error",
44 "@typescript-eslint/await-thenable": "error",
45 "@typescript-eslint/ban-types": "error",
46 "@typescript-eslint/brace-style": "off",
47 "@typescript-eslint/comma-dangle": ["error", "always-multiline"],
48 "@typescript-eslint/comma-spacing": "off",
49 "@typescript-eslint/consistent-type-assertions": [
50 "error",
51 {
52 assertionStyle: "as",
53 objectLiteralTypeAssertions: "never",
54 },
55 ],
56 "@typescript-eslint/consistent-type-definitions": "error",
57 "@typescript-eslint/dot-notation": "error",
58 "@typescript-eslint/explicit-function-return-type": "off",
59 "@typescript-eslint/func-call-spacing": "off",
60 "@typescript-eslint/keyword-spacing": "off",
61 "@typescript-eslint/member-delimiter-style": "off",
62 "@typescript-eslint/no-dynamic-delete": "error",
63 "@typescript-eslint/no-empty-function": "off",
64 "@typescript-eslint/no-empty-interface": "error",
65 "@typescript-eslint/no-explicit-any": "off",
66 "@typescript-eslint/no-extra-semi": "error",
67 "@typescript-eslint/no-extraneous-class": "error",
68 "@typescript-eslint/no-floating-promises": "error",
69 "@typescript-eslint/no-for-in-array": "error",
70 "@typescript-eslint/no-inferrable-types": "off",
71 "@typescript-eslint/no-invalid-this": "off",
72 "@typescript-eslint/no-magic-numbers": "off",
73 "@typescript-eslint/no-misused-new": "error",
74 "@typescript-eslint/no-non-null-assertion": "error",
75 "@typescript-eslint/no-require-imports": "error",
76 "@typescript-eslint/no-shadow": [
77 "error",
78 {
79 hoist: "all",
80 ignoreTypeValueShadow: true,
81 },
82 ],
83 "@typescript-eslint/no-this-alias": "error",
84 "@typescript-eslint/no-throw-literal": "error",
85 "@typescript-eslint/no-unused-expressions": "error",
86 "@typescript-eslint/no-unused-vars": "off",
87 "@typescript-eslint/no-unnecessary-qualifier": "error",
88 "@typescript-eslint/no-unnecessary-type-arguments": "error",
89 "@typescript-eslint/no-unnecessary-type-assertion": "error",
90 "@typescript-eslint/no-var-requires": "error",
91 "@typescript-eslint/object-curly-spacing": "off",
92 "@typescript-eslint/prefer-for-of": "error",
93 "@typescript-eslint/prefer-function-type": "error",
94 "@typescript-eslint/prefer-namespace-keyword": "error",
95 "@typescript-eslint/prefer-readonly": "error",
96 "@typescript-eslint/promise-function-async": "error",
97 "@typescript-eslint/quotes": [
98 "error",
99 "double",
100 {
101 allowTemplateLiterals: true,
102 avoidEscape: true,
103 },
104 ],
105 "@typescript-eslint/require-await": "off",
106 "@typescript-eslint/restrict-plus-operands": "error",
107 "@typescript-eslint/restrict-template-expressions": "off",
108 "@typescript-eslint/return-await": "error",
109 "@typescript-eslint/semi": ["error", "always"],
110 "@typescript-eslint/space-infix-ops": "error",
111 "@typescript-eslint/space-before-function-paren": [
112 "error",
113 {
114 anonymous: "never",
115 asyncArrow: "always",
116 named: "never",
117 },
118 ],
119 "@typescript-eslint/strict-boolean-expressions": "error",
120 "@typescript-eslint/triple-slash-reference": "error",
121 "@typescript-eslint/type-annotation-spacing": "error",
122 "@typescript-eslint/unbound-method": [
123 "error",
124 {
125 ignoreStatic: true,
126 },
127 ],
128 "@typescript-eslint/unified-signatures": "error",
129
130 // eslint-plugin-eslint-comments
131 "eslint-comments/disable-enable-pair": [
132 "error",
133 {
134 allowWholeFile: true,
135 },
136 ],
137
138 // eslint-plugin-import
139 "import/no-default-export": "error",
140 "import/no-deprecated": "off",
141 "import/no-extraneous-dependencies": [
142 "error",
143 {
144 devDependencies: ["**/*.spec.ts", "src/test/**"],
145 },
146 ],
147 "import/no-internal-modules": "error",
148 "import/no-unassigned-import": "error",
149 "import/no-unresolved": [
150 "error",
151 {
152 caseSensitive: true,
153 },
154 ],
155 "import/no-unused-modules": "error",
156 "import/order": [
157 "error",
158 {
159 "newlines-between": "always",
160 "alphabetize": {
161 order: "asc",
162 // Sorting is case-sensitive by default, which is the same as Biome. To avoid
163 // another huge set of changes to order things case-insensitively, we'll just
164 // use the rule with this config for now. This decision should be considered
165 // pragmatic and not a statement of preference, and we should revisit this.
166 caseInsensitive: false,
167 },
168 },
169 ],
170
171 // eslint-plugin-unicorn
172 "unicorn/better-regex": "error",
173 "unicorn/filename-case": [
174 "error",
175 {
176 cases: {
177 camelCase: true,
178 pascalCase: true,
179 },
180 },
181 ],
182 // Rationale: Destructuring of `Array.entries()` in order to get the index variable results in a
183 // significant performance regression [node 14 x64].
184 "unicorn/no-for-loop": "off",
185 "unicorn/no-new-buffer": "error",
186
187 // The rule seems to crash on some of our code
188 "unicorn/expiring-todo-comments": "off",
189
190 // eslint
191 "arrow-body-style": "off",
192 "arrow-parens": ["error", "always"],
193 "camelcase": "off", // Superseded by @typescript-eslint/camelcase
194 "brace-style": "off", // Superseded by @typescript-eslint/brace-style
195 "capitalized-comments": "off",
196 "comma-dangle": "off", // Superseded by @typescript-eslint/comma-dangle
197 "comma-spacing": "off", // Superseded by @typescript-eslint/comma-spacing
198 "complexity": "off",
199 "constructor-super": "error",
200 "curly": "error",
201 "default-case": "error",
202 "dot-notation": "off", // Superseded by @typescript-eslint/dot-notation
203 "eol-last": "error",
204 "eqeqeq": ["error", "smart"],
205 "func-call-spacing": "off", // Superseded by @typescript-eslint/func-call-spacing
206 "guard-for-in": "error",
207 "id-match": "error",
208 "linebreak-style": "off",
209 "keyword-spacing": "off", // Superseded by @typescript-eslint/keyword-spacing
210 "max-classes-per-file": "off",
211 "max-len": [
212 "error",
213 {
214 ignoreRegExpLiterals: false,
215 ignoreStrings: false,
216 code: 120,
217 },
218 ],
219 "max-lines": "off",
220 "new-parens": "error",
221 "newline-per-chained-call": "off",
222 "no-bitwise": "error",
223 "no-caller": "error",
224 "no-cond-assign": "error",
225 "no-constant-condition": "error",
226 "no-control-regex": "error",
227 "no-debugger": "off",
228 "no-duplicate-case": "error",
229 "no-duplicate-imports": "off", // Doesn't work with TypeScript
230 "no-empty": "off",
231 "no-eval": "error",
232 "no-extra-semi": "off", // Superseded by @typescript-eslint/no-extra-semi
233 "no-fallthrough": "off",
234 "no-invalid-regexp": "error",
235 "no-invalid-this": "off", // Superseded by @typescript-eslint/no-invalid-this
236 "no-irregular-whitespace": "error",
237 "no-magic-numbers": "off", // Superseded by @typescript-eslint/no-magic-numbers
238 "no-multi-str": "off",
239 "no-multiple-empty-lines": [
240 "error",
241 {
242 max: 1,
243 maxBOF: 0,
244 maxEOF: 0,
245 },
246 ],
247 "no-nested-ternary": "off", // Superseded by unicorn/no-nested-ternary
248 "no-new-func": "error",
249 "no-new-wrappers": "error",
250 "no-octal": "error",
251 "no-octal-escape": "error",
252 "no-param-reassign": "error",
253 "no-redeclare": "off", // Superseded by @typescript-eslint/no-redeclare
254 "no-regex-spaces": "error",
255 "no-restricted-syntax": [
256 "error",
257 {
258 selector: "ExportAllDeclaration",
259 message:
260 "Exporting * is not permitted. You should export only named items you intend to export.",
261 },
262 "ForInStatement",
263 ],
264 "no-sequences": "error",
265 "no-shadow": "off", // Superseded by @typescript-eslint/no-shadow
266 "no-sparse-arrays": "error",
267 "no-template-curly-in-string": "error",
268 "no-throw-literal": "off", // Superseded by @typescript-eslint/no-throw-literal
269 "no-trailing-spaces": "error",
270 "no-undef-init": "error",
271 "no-underscore-dangle": "off",
272 "no-unsafe-finally": "error",
273 "no-unused-expressions": "off", // Superseded by @typescript-eslint/no-unused-expressions
274 "no-unused-labels": "error",
275 "no-unused-vars": "off",
276 "no-var": "error",
277 "no-void": "off",
278 "no-whitespace-before-property": "error",
279 "object-curly-spacing": "off", // Superseded by @typescript-eslint/no-unused-expressions
280 "object-shorthand": "error",
281 "one-var": ["error", "never"],
282 "padded-blocks": ["error", "never"],
283 "padding-line-between-statements": [
284 "off",
285 {
286 blankLine: "always",
287 prev: "*",
288 next: "return",
289 },
290 ],
291 "prefer-arrow-callback": "error",
292 "prefer-const": "error",
293 "prefer-object-spread": "error",
294 "prefer-promise-reject-errors": "error",
295 "prefer-template": "error",
296 "quote-props": ["error", "consistent-as-needed"],
297 "quotes": "off", // Superseded by @typescript-eslint/quotes
298 "radix": "error",
299 "require-await": "off", // Superseded by @typescript-eslint/require-await
300 "semi": "off", // Superseded by @typescript-eslint/semi
301 "semi-spacing": "error",
302 "space-before-blocks": "error",
303 "space-before-function-paren": "off", // Superseded by @typescript-eslint/space-before-function-paren
304 "space-infix-ops": "off", // Superseded by @typescript-eslint/space-infix-ops
305 "space-in-parens": ["error", "never"],
306 "spaced-comment": [
307 "error",
308 "always",
309 {
310 block: {
311 markers: ["!"],
312 balanced: true,
313 },
314 },
315 ],
316 "use-isnan": "error",
317 "valid-typeof": "off",
318 "yoda": "off",
319 },
320 overrides: [
321 {
322 // Rules only for TypeScript files
323 files: ["*.ts", "*.tsx"],
324 rules: {
325 "@typescript-eslint/indent": "off", // Off because it conflicts with typescript-formatter
326 "func-call-spacing": "off", // Off because it conflicts with typescript-formatter
327
328 // TODO: Enable these ASAP
329 "@typescript-eslint/explicit-module-boundary-types": "off",
330 "@typescript-eslint/no-unsafe-argument": "off",
331 "@typescript-eslint/no-unsafe-assignment": "off",
332 "@typescript-eslint/no-unsafe-call": "off",
333 "@typescript-eslint/no-unsafe-member-access": "off",
334 },
335 },
336 {
337 // Rules only for type validation files
338 files: ["**/types/*validate*Previous*.ts"],
339 rules: {
340 "@typescript-eslint/comma-spacing": "off",
341 },
342 },
343 ],
344 settings: {
345 "import/extensions": [".ts", ".tsx", ".d.ts", ".js", ".jsx"],
346 "import/parsers": {
347 "@typescript-eslint/parser": [".ts", ".tsx", ".d.ts"],
348 },
349 "import/resolver": {
350 // See remark in minimal-deprecated.js on the importance of import/resolver key order.
351 node: {
352 extensions: [".ts", ".tsx", ".d.ts", ".js", ".jsx"],
353 },
354 },
355 },
356};