UNPKG

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