|
| 1 | +import stylistic from "@stylistic/eslint-plugin"; |
| 2 | +import typescriptEslint from "@typescript-eslint/eslint-plugin"; |
| 3 | +import testingLibrary from "eslint-plugin-testing-library"; |
| 4 | +import globals from "globals"; |
| 5 | +import path from "node:path"; |
| 6 | +import { fileURLToPath } from "node:url"; |
| 7 | +import js from "@eslint/js"; |
| 8 | +import { FlatCompat } from "@eslint/eslintrc"; |
| 9 | + |
| 10 | +const __filename = fileURLToPath(import.meta.url); |
| 11 | +const __dirname = path.dirname(__filename); |
| 12 | +const compat = new FlatCompat({ |
| 13 | + baseDirectory: __dirname, |
| 14 | + recommendedConfig: js.configs.recommended, |
| 15 | + allConfig: js.configs.all, |
| 16 | +}); |
| 17 | + |
| 18 | +export default [{ |
| 19 | + ignores: [ |
| 20 | + ".yarn/", |
| 21 | + ".pnp.*", |
| 22 | + "**/node_modules/", |
| 23 | + "**/dist/", |
| 24 | + "docs/pages/", |
| 25 | + "**/lib/", |
| 26 | + "**/samples/", |
| 27 | + ], |
| 28 | +}, ...compat.extends("eslint:recommended", "plugin:testing-library/dom"), { |
| 29 | + plugins: { |
| 30 | + "@typescript-eslint": typescriptEslint, |
| 31 | + "@stylistic": stylistic, |
| 32 | + "testing-library": testingLibrary, |
| 33 | + }, |
| 34 | + |
| 35 | + languageOptions: { |
| 36 | + globals: { |
| 37 | + ...globals.browser, |
| 38 | + ...globals.node, |
| 39 | + }, |
| 40 | + |
| 41 | + ecmaVersion: 2020, |
| 42 | + sourceType: "module", |
| 43 | + }, |
| 44 | + |
| 45 | + rules: { |
| 46 | + "comma-dangle": ["error", "always-multiline"], |
| 47 | + "consistent-return": "error", |
| 48 | + |
| 49 | + indent: ["error", 4, { |
| 50 | + SwitchCase: 1, |
| 51 | + }], |
| 52 | + |
| 53 | + quotes: "error", |
| 54 | + semi: "error", |
| 55 | + "keyword-spacing": "error", |
| 56 | + "space-before-blocks": "error", |
| 57 | + |
| 58 | + "no-multiple-empty-lines": ["error", { |
| 59 | + max: 1, |
| 60 | + maxBOF: 0, |
| 61 | + maxEOF: 0, |
| 62 | + }], |
| 63 | + |
| 64 | + "no-multi-spaces": "error", |
| 65 | + }, |
| 66 | +}, ...compat.extends( |
| 67 | + "plugin:@typescript-eslint/recommended", |
| 68 | + "plugin:@typescript-eslint/recommended-requiring-type-checking", |
| 69 | +).map(config => ({ |
| 70 | + ...config, |
| 71 | + files: ["**/*.ts", "**/*.tsx"], |
| 72 | +})), { |
| 73 | + files: ["**/*.ts", "**/*.tsx"], |
| 74 | + |
| 75 | + languageOptions: { |
| 76 | + parserOptions: { |
| 77 | + project: ["./tsconfig.json"], |
| 78 | + }, |
| 79 | + }, |
| 80 | + |
| 81 | + rules: { |
| 82 | + indent: "off", |
| 83 | + semi: "off", |
| 84 | + "no-return-await": "off", |
| 85 | + |
| 86 | + "@stylistic/indent": ["error", 4, { |
| 87 | + SwitchCase: 1, |
| 88 | + }], |
| 89 | + |
| 90 | + "@stylistic/member-delimiter-style": "error", |
| 91 | + "@stylistic/object-curly-spacing": ["error", "always"], |
| 92 | + "@stylistic/semi": "error", |
| 93 | + |
| 94 | + "@typescript-eslint/return-await": ["error", "always"], |
| 95 | + "@typescript-eslint/require-await": "off", |
| 96 | + "@typescript-eslint/no-unsafe-argument": "off", |
| 97 | + "@typescript-eslint/no-unsafe-assignment": "off", |
| 98 | + }, |
| 99 | +}, { |
| 100 | + files: ["src/**/*"], |
| 101 | + |
| 102 | + languageOptions: { |
| 103 | + globals: { |
| 104 | + ...Object.fromEntries(Object.entries(globals.node).map(([key]) => [key, "off"])), |
| 105 | + }, |
| 106 | + }, |
| 107 | +}, { |
| 108 | + files: ["src/**/*.test.*", "test/**/*"], |
| 109 | + |
| 110 | + languageOptions: { |
| 111 | + globals: { |
| 112 | + ...globals.jest, |
| 113 | + }, |
| 114 | + }, |
| 115 | + |
| 116 | + rules: { |
| 117 | + "@typescript-eslint/no-non-null-assertion": "off", |
| 118 | + "@typescript-eslint/unbound-method": "off", |
| 119 | + }, |
| 120 | +}]; |
0 commit comments