|
1 | | -const importOrderConfig = require("./rule-configs/import-order/base.js"); |
2 | | -const namingConventionConfig = require("./rule-configs/naming-convention/base.js"); |
| 1 | +//@ts-check |
| 2 | +import importOrderConfig from "./rule-configs/import-order/base.js"; |
| 3 | +import namingConventionConfig from "./rule-configs/naming-convention/base.js"; |
| 4 | +import typescriptEslintPlugin from "@typescript-eslint/eslint-plugin"; |
| 5 | +import prettierPlugin from "eslint-plugin-prettier"; |
| 6 | +import sortExportAllPlugin from "eslint-plugin-sort-export-all"; |
| 7 | +import js from "@eslint/js"; |
| 8 | +import globals from "globals"; |
| 9 | +import tseslint from "typescript-eslint"; |
| 10 | +import eslintConfigPrettier from "eslint-config-prettier"; |
3 | 11 |
|
4 | | -module.exports = { |
5 | | - env: { |
6 | | - browser: true, |
7 | | - es2021: true, |
8 | | - node: true, |
| 12 | +//@ts-ignore -- Package provides no types. |
| 13 | +import reactRefresh from "eslint-plugin-react-refresh"; |
| 14 | +//@ts-ignore -- Package provides no types. |
| 15 | +import importPlugin from "eslint-plugin-import"; |
| 16 | + |
| 17 | +export default tseslint.config( |
| 18 | + { |
| 19 | + ignores: ["dist"], |
9 | 20 | }, |
10 | | - extends: ["airbnb-base", "airbnb-typescript/base", "prettier"], |
11 | | - parser: "@typescript-eslint/parser", |
12 | | - parserOptions: { |
13 | | - ecmaFeatures: { |
14 | | - jsx: true, |
| 21 | + { |
| 22 | + extends: [js.configs.recommended, ...tseslint.configs.recommended], |
| 23 | + files: ["**/*.{ts,tsx,js,jsx,mjs}"], |
| 24 | + languageOptions: { |
| 25 | + ecmaVersion: 2020, |
| 26 | + parserOptions: { |
| 27 | + projectService: true, |
| 28 | + }, |
| 29 | + globals: { |
| 30 | + ...globals.browser, |
| 31 | + ...globals.node, |
| 32 | + }, |
| 33 | + }, |
| 34 | + plugins: { |
| 35 | + "react-refresh": reactRefresh, |
| 36 | + }, |
| 37 | + rules: { |
| 38 | + "react-refresh/only-export-components": [ |
| 39 | + "warn", |
| 40 | + { allowConstantExport: true }, |
| 41 | + ], |
15 | 42 | }, |
16 | | - ecmaVersion: 12, |
17 | | - sourceType: "module", |
18 | | - project: ["./tsconfig.json"], |
19 | 43 | }, |
20 | | - plugins: [ |
21 | | - "@typescript-eslint", |
22 | | - "prettier", |
23 | | - "import", |
24 | | - "sort-export-all", |
25 | | - "deprecation", |
26 | | - ], |
27 | | - rules: { |
28 | | - // Prettier handles indent, whitespace and empty lines |
29 | | - "prettier/prettier": 2, |
| 44 | + { |
| 45 | + plugins: { |
| 46 | + "@typescript-eslint": typescriptEslintPlugin, |
| 47 | + prettier: prettierPlugin, |
| 48 | + import: importPlugin, |
| 49 | + "sort-export-all": sortExportAllPlugin, |
| 50 | + }, |
| 51 | + rules: { |
| 52 | + // Prettier rules |
| 53 | + "prettier/prettier": 2, |
30 | 54 |
|
31 | | - // Warn about deprecated methods and properties |
32 | | - "deprecation/deprecation": "warn", |
| 55 | + // Warn about deprecated methods and properties |
| 56 | + "@typescript-eslint/no-deprecated": "warn", |
33 | 57 |
|
34 | | - // Import rules |
35 | | - "sort-export-all/sort-export-all": [ |
36 | | - "error", |
37 | | - "asc", |
38 | | - { |
39 | | - caseSensitive: false, |
40 | | - natural: false, |
41 | | - }, |
42 | | - ], |
43 | | - "import/extensions": [ |
44 | | - "error", |
45 | | - "never", |
46 | | - { svg: "always", json: "always", css: "always", scss: "always" }, |
47 | | - ], |
48 | | - "import/order": ["error", importOrderConfig], |
49 | | - "import/prefer-default-export": "off", |
50 | | - "import/no-default-export": "error", |
51 | | - "import/no-extraneous-dependencies": "error", |
52 | | - "sort-imports": [ |
53 | | - "error", |
54 | | - { |
55 | | - ignoreCase: true, |
56 | | - ignoreDeclarationSort: true, |
57 | | - ignoreMemberSort: false, |
58 | | - memberSyntaxSortOrder: ["none", "all", "multiple", "single"], |
59 | | - }, |
60 | | - ], |
| 58 | + // Import rules |
| 59 | + "sort-export-all/sort-export-all": [ |
| 60 | + "error", |
| 61 | + "asc", |
| 62 | + { |
| 63 | + caseSensitive: false, |
| 64 | + natural: false, |
| 65 | + }, |
| 66 | + ], |
| 67 | + "import/extensions": [ |
| 68 | + "error", |
| 69 | + "never", |
| 70 | + { |
| 71 | + svg: "always", |
| 72 | + json: "always", |
| 73 | + css: "always", |
| 74 | + scss: "always", |
| 75 | + }, |
| 76 | + ], |
| 77 | + "import/order": ["error", importOrderConfig], |
| 78 | + "import/prefer-default-export": "off", |
| 79 | + "import/no-default-export": "error", |
| 80 | + "import/no-extraneous-dependencies": "error", |
| 81 | + "sort-imports": [ |
| 82 | + "error", |
| 83 | + { |
| 84 | + ignoreCase: true, |
| 85 | + ignoreDeclarationSort: true, |
| 86 | + ignoreMemberSort: false, |
| 87 | + memberSyntaxSortOrder: [ |
| 88 | + "none", |
| 89 | + "all", |
| 90 | + "multiple", |
| 91 | + "single", |
| 92 | + ], |
| 93 | + }, |
| 94 | + ], |
61 | 95 |
|
62 | | - // General code-style rules |
63 | | - "@typescript-eslint/naming-convention": namingConventionConfig, |
64 | | - "id-blacklist": [ |
65 | | - 2, |
66 | | - "arr", |
67 | | - "cb", |
68 | | - "e", |
69 | | - "el", |
70 | | - "err", |
71 | | - "idx", |
72 | | - "num", |
73 | | - "str", |
74 | | - "tmp", |
75 | | - "val", |
76 | | - ], |
77 | | - "no-return-assign": ["error", "except-parens"], |
78 | | - "no-unused-vars": "off", |
79 | | - "@typescript-eslint/no-unused-vars": [ |
80 | | - "error", |
81 | | - { argsIgnorePattern: "^_", ignoreRestSiblings: true }, |
82 | | - ], |
83 | | - "@typescript-eslint/consistent-type-imports": "error", |
84 | | - "@typescript-eslint/no-import-type-side-effects": "error", |
| 96 | + // General code-style rules |
| 97 | + // @ts-ignore |
| 98 | + "@typescript-eslint/naming-convention": namingConventionConfig, |
| 99 | + "id-blacklist": [ |
| 100 | + 2, |
| 101 | + "arr", |
| 102 | + "cb", |
| 103 | + "e", |
| 104 | + "el", |
| 105 | + "err", |
| 106 | + "idx", |
| 107 | + "num", |
| 108 | + "str", |
| 109 | + "tmp", |
| 110 | + "val", |
| 111 | + ], |
| 112 | + "no-return-assign": ["error", "except-parens"], |
| 113 | + "no-unused-vars": "off", |
| 114 | + "@typescript-eslint/no-unused-vars": [ |
| 115 | + "error", |
| 116 | + { argsIgnorePattern: "^_", ignoreRestSiblings: true }, |
| 117 | + ], |
| 118 | + "@typescript-eslint/consistent-type-imports": "error", |
| 119 | + "@typescript-eslint/no-import-type-side-effects": "error", |
85 | 120 |
|
86 | | - "prefer-destructuring": "warn", |
87 | | - "no-nested-ternary": "warn", |
| 121 | + "prefer-destructuring": "warn", |
| 122 | + "no-nested-ternary": "warn", |
88 | 123 |
|
89 | | - "func-style": ["error", "declaration"], |
| 124 | + "func-style": ["error", "declaration"], |
90 | 125 |
|
91 | | - // Extra rules |
92 | | - radix: "off", |
| 126 | + radix: "off", |
| 127 | + }, |
93 | 128 | }, |
94 | | -}; |
| 129 | + eslintConfigPrettier, |
| 130 | +); |
0 commit comments