|
1 |
| -/* eslint-env node, commonjs */ |
2 |
| - |
3 |
| -exports.ecmaFeatures = { |
4 |
| - impliedStrict: true, |
5 |
| -}; |
6 |
| - |
7 |
| -// Our ES5 projects are exclusively browser-focused |
8 |
| -exports.env = { |
9 |
| - browser: true, |
10 |
| - node: false, |
11 |
| - commonjs: false, |
12 |
| -}; |
13 |
| - |
14 |
| -exports.extends = 'airbnb-base/legacy'; |
15 |
| - |
16 |
| -exports.rules = { |
17 |
| - // Overrides of airbnb-base/legacy |
18 |
| - |
19 |
| - // IE8 is dead, we can require trailing commas safely |
20 |
| - 'comma-dangle': ['error', 'always-multiline'], |
21 |
| - |
22 |
| - // block-scoped-var and no-use-before-define cover the use cases here |
23 |
| - // no need to manually hoist as well |
24 |
| - 'vars-on-top': ['off'], |
25 |
| - |
26 |
| - // Style guidance left to the programmer |
27 |
| - 'no-else-return': ['off'], |
28 |
| - 'func-names': ['off'], |
29 |
| - |
30 |
| - // Function hoisting is always safe |
31 |
| - 'no-use-before-define': ['error', { |
32 |
| - functions: false, |
33 |
| - }], |
34 |
| - |
35 |
| - // Allow conditionals in loops (but only if you promise that you know what you're doing) |
36 |
| - 'no-cond-assign': ['error', 'except-parens'], |
37 |
| - |
38 |
| - // Unconditionally require curly braces |
39 |
| - curly: ['error', 'all'], |
40 |
| - |
41 |
| - // Additional rules |
42 |
| - |
43 |
| - // Don't leak globals |
44 |
| - 'no-implicit-globals': 'error', |
45 |
| - |
46 |
| - // Disallow superfluous parentheses, unless you need to disambiguate precedence |
47 |
| - 'no-extra-parens': ['error', 'all', { |
48 |
| - conditionalAssign: false, |
49 |
| - nestedBinaryExpressions: false, |
50 |
| - }], |
51 |
| - |
52 |
| - // Eventually, this will be an error (and also require parameter descriptions) |
53 |
| - 'valid-jsdoc': ['warn', { |
54 |
| - requireReturn: false, |
55 |
| - requireParamDescription: false, |
56 |
| - requireReturnDescription: false, |
57 |
| - |
58 |
| - prefer: { |
59 |
| - arg: 'param', |
60 |
| - argument: 'param', |
61 |
| - |
62 |
| - returns: 'return', |
| 1 | +// @ts-check |
| 2 | + |
| 3 | +import eslint from "@eslint/js"; |
| 4 | +import tseslint from "typescript-eslint"; |
| 5 | +import prettier from "eslint-config-prettier"; |
| 6 | +import prettierPlugin from "eslint-plugin-prettier"; |
| 7 | +import globals from "globals"; |
| 8 | + |
| 9 | +/** |
| 10 | + * @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigFile} |
| 11 | + */ |
| 12 | +const config = tseslint.config( |
| 13 | + eslint.configs.recommended, |
| 14 | + tseslint.configs.recommendedTypeChecked, |
| 15 | + prettier, |
| 16 | + { |
| 17 | + languageOptions: { |
| 18 | + ecmaVersion: "latest", |
| 19 | + globals: { |
| 20 | + ...globals.node, |
| 21 | + ...globals.browser, |
| 22 | + }, |
| 23 | + parserOptions: { |
| 24 | + projectService: true, |
| 25 | + }, |
| 26 | + sourceType: "module", |
| 27 | + }, |
| 28 | + plugins: { |
| 29 | + "@typescript-eslint": tseslint.plugin, |
| 30 | + prettier: prettierPlugin, |
| 31 | + }, |
| 32 | + rules: { |
| 33 | + "@typescript-eslint/explicit-module-boundary-types": "off", |
| 34 | + "@typescript-eslint/no-unused-vars": [ |
| 35 | + "error", |
| 36 | + { |
| 37 | + ignoreRestSiblings: true, |
| 38 | + varsIgnorePattern: "^_", |
| 39 | + argsIgnorePattern: "^_", |
| 40 | + caughtErrorsIgnorePattern: "^_", |
| 41 | + }, |
| 42 | + ], |
| 43 | + "@typescript-eslint/no-explicit-any": "error", |
| 44 | + "@typescript-eslint/no-empty-interface": [ |
| 45 | + "error", |
| 46 | + { |
| 47 | + allowSingleExtends: true, |
| 48 | + }, |
| 49 | + ], |
| 50 | + "@typescript-eslint/no-use-before-define": ["error"], |
| 51 | + "no-param-reassign": [ |
| 52 | + // Allow modifying props, esp. for DOM Nodes |
| 53 | + "error", |
| 54 | + { |
| 55 | + props: false, |
| 56 | + }, |
| 57 | + ], |
| 58 | + "prettier/prettier": "error", |
63 | 59 | },
|
64 |
| - }], |
65 |
| -}; |
| 60 | + overrides: [ |
| 61 | + { |
| 62 | + // enable the rule specifically for TypeScript files |
| 63 | + files: ["*.ts", "*.tsx"], |
| 64 | + rules: { |
| 65 | + "@typescript-eslint/explicit-module-boundary-types": ["error"], |
| 66 | + }, |
| 67 | + }, |
| 68 | + ], |
| 69 | + }, |
| 70 | +); |
| 71 | +export default config; |
0 commit comments