|
| 1 | +const { defineConfig, globalIgnores } = require("eslint/config"); |
| 2 | + |
| 3 | +const globals = require("globals"); |
| 4 | +const tsParser = require("@typescript-eslint/parser"); |
| 5 | +const typescriptEslint = require("@typescript-eslint/eslint-plugin"); |
| 6 | +const js = require("@eslint/js"); |
| 7 | + |
| 8 | +const { FlatCompat } = require("@eslint/eslintrc"); |
| 9 | + |
| 10 | +const compat = new FlatCompat({ |
| 11 | + baseDirectory: __dirname, |
| 12 | + recommendedConfig: js.configs.recommended, |
| 13 | + allConfig: js.configs.all, |
| 14 | +}); |
| 15 | + |
| 16 | +module.exports = defineConfig([ |
| 17 | + { |
| 18 | + languageOptions: { |
| 19 | + globals: { |
| 20 | + ...globals.browser, |
| 21 | + ...globals.node, |
| 22 | + }, |
| 23 | + |
| 24 | + ecmaVersion: 2022, |
| 25 | + sourceType: "module", |
| 26 | + parserOptions: {}, |
| 27 | + }, |
| 28 | + |
| 29 | + extends: compat.extends("eslint:recommended"), |
| 30 | + |
| 31 | + rules: {}, |
| 32 | + |
| 33 | + settings: { |
| 34 | + "import/resolver": { |
| 35 | + node: { |
| 36 | + extensions: [".js", ".jsx", ".ts", ".tsx"], |
| 37 | + moduleDirectory: ["node_modules", "./src/"], |
| 38 | + }, |
| 39 | + |
| 40 | + webpack: { |
| 41 | + config: require.resolve("./.erb/configs/webpack.config.eslint.ts"), |
| 42 | + }, |
| 43 | + |
| 44 | + typescript: {}, |
| 45 | + }, |
| 46 | + |
| 47 | + "import/parsers": { |
| 48 | + "@typescript-eslint/parser": [".ts", ".tsx"], |
| 49 | + }, |
| 50 | + }, |
| 51 | + }, |
| 52 | + { |
| 53 | + files: ["**/*.ts", "**/*.tsx"], |
| 54 | + extends: compat.extends( |
| 55 | + "eslint:recommended", |
| 56 | + "plugin:@typescript-eslint/recommended" |
| 57 | + ), |
| 58 | + |
| 59 | + languageOptions: { |
| 60 | + parser: tsParser, |
| 61 | + ecmaVersion: 2020, |
| 62 | + sourceType: "module", |
| 63 | + |
| 64 | + parserOptions: { |
| 65 | + project: "./tsconfig.json", |
| 66 | + tsconfigRootDir: __dirname, |
| 67 | + createDefaultProgram: true, |
| 68 | + }, |
| 69 | + }, |
| 70 | + |
| 71 | + plugins: { |
| 72 | + "@typescript-eslint": typescriptEslint, |
| 73 | + }, |
| 74 | + |
| 75 | + rules: { |
| 76 | + "@typescript-eslint/no-unused-vars": [ |
| 77 | + "warn", |
| 78 | + { |
| 79 | + argsIgnorePattern: "^_", |
| 80 | + varsIgnorePattern: "^_", |
| 81 | + }, |
| 82 | + ], |
| 83 | + }, |
| 84 | + }, |
| 85 | + { |
| 86 | + files: ["**/*.js", "**/*.jsx"], |
| 87 | + |
| 88 | + languageOptions: { |
| 89 | + ecmaVersion: 2022, |
| 90 | + sourceType: "module", |
| 91 | + parserOptions: {}, |
| 92 | + }, |
| 93 | + }, |
| 94 | + globalIgnores([ |
| 95 | + "**/logs", |
| 96 | + "**/*.log", |
| 97 | + "**/pids", |
| 98 | + "**/*.pid", |
| 99 | + "**/*.seed", |
| 100 | + "**/coverage", |
| 101 | + "**/.eslintcache", |
| 102 | + "**/node_modules", |
| 103 | + "**/.DS_Store", |
| 104 | + "release/app/dist", |
| 105 | + "release/build", |
| 106 | + ".erb/dll", |
| 107 | + "**/.idea", |
| 108 | + "**/npm-debug.log.*", |
| 109 | + "**/*.css.d.ts", |
| 110 | + "**/*.sass.d.ts", |
| 111 | + "**/*.scss.d.ts", |
| 112 | + ]), |
| 113 | +]); |
0 commit comments