|
| 1 | +// https://github.com/super-linter/super-linter/blob/0d8f7aad449c1dc8ecaf2362684de5d379d2cd7d/TEMPLATES/eslint.config.mjs |
| 2 | +import { defineConfig, globalIgnores } from "eslint/config"; |
| 3 | +import n from "eslint-plugin-n"; |
| 4 | +import prettier from "eslint-plugin-prettier"; |
| 5 | +import globals from "globals"; |
| 6 | +import jsoncParser from "jsonc-eslint-parser"; |
| 7 | +import typescriptEslint from "@typescript-eslint/eslint-plugin"; |
| 8 | +import tsParser from "@typescript-eslint/parser"; |
| 9 | +import vueParser from "vue-eslint-parser"; |
| 10 | +import path from "node:path"; |
| 11 | +import { fileURLToPath } from "node:url"; |
| 12 | +import js from "@eslint/js"; |
| 13 | +import { FlatCompat } from "@eslint/eslintrc"; |
| 14 | + |
| 15 | +const __filename = fileURLToPath(import.meta.url); |
| 16 | +const __dirname = path.dirname(__filename); |
| 17 | +const compat = new FlatCompat({ |
| 18 | + baseDirectory: __dirname, |
| 19 | + recommendedConfig: js.configs.recommended, |
| 20 | + allConfig: js.configs.all, |
| 21 | +}); |
| 22 | + |
| 23 | +export default defineConfig([ |
| 24 | + globalIgnores(["!**/.*", "**/node_modules/.*", "**/dist/*"]), |
| 25 | + { |
| 26 | + extends: compat.extends("eslint:recommended"), |
| 27 | + |
| 28 | + plugins: { |
| 29 | + n, |
| 30 | + prettier, |
| 31 | + }, |
| 32 | + |
| 33 | + languageOptions: { |
| 34 | + globals: { |
| 35 | + ...globals.browser, |
| 36 | + ...globals.jest, |
| 37 | + ...globals.node, |
| 38 | + }, |
| 39 | + }, |
| 40 | + }, |
| 41 | + { |
| 42 | + files: ["**/*.json"], |
| 43 | + extends: compat.extends("plugin:jsonc/recommended-with-json"), |
| 44 | + |
| 45 | + languageOptions: { |
| 46 | + parser: jsoncParser, |
| 47 | + ecmaVersion: "latest", |
| 48 | + sourceType: "script", |
| 49 | + |
| 50 | + parserOptions: { |
| 51 | + jsonSyntax: "JSON", |
| 52 | + }, |
| 53 | + }, |
| 54 | + }, |
| 55 | + { |
| 56 | + files: ["**/*.jsonc"], |
| 57 | + extends: compat.extends("plugin:jsonc/recommended-with-jsonc"), |
| 58 | + |
| 59 | + languageOptions: { |
| 60 | + parser: jsoncParser, |
| 61 | + ecmaVersion: "latest", |
| 62 | + sourceType: "script", |
| 63 | + |
| 64 | + parserOptions: { |
| 65 | + jsonSyntax: "JSONC", |
| 66 | + }, |
| 67 | + }, |
| 68 | + }, |
| 69 | + { |
| 70 | + files: ["**/*.json5"], |
| 71 | + extends: compat.extends("plugin:jsonc/recommended-with-json5"), |
| 72 | + |
| 73 | + languageOptions: { |
| 74 | + parser: jsoncParser, |
| 75 | + ecmaVersion: "latest", |
| 76 | + sourceType: "script", |
| 77 | + |
| 78 | + parserOptions: { |
| 79 | + jsonSyntax: "JSON5", |
| 80 | + }, |
| 81 | + }, |
| 82 | + }, |
| 83 | + { |
| 84 | + files: ["**/*.js", "**/*.mjs", "**/*.cjs", "**/*.jsx"], |
| 85 | + // extends: compat.extends("plugin:react/recommended"), |
| 86 | + |
| 87 | + languageOptions: { |
| 88 | + ecmaVersion: "latest", |
| 89 | + sourceType: "module", |
| 90 | + |
| 91 | + parserOptions: { |
| 92 | + ecmaFeatures: { |
| 93 | + jsx: true, |
| 94 | + modules: true, |
| 95 | + }, |
| 96 | + }, |
| 97 | + }, |
| 98 | + }, |
| 99 | + { |
| 100 | + files: ["**/*.ts", "**/*.cts", "**/*.mts", "**/*.tsx"], |
| 101 | + |
| 102 | + extends: compat.extends( |
| 103 | + "plugin:@typescript-eslint/recommended", |
| 104 | + "plugin:n/recommended", |
| 105 | + // "plugin:react/recommended", |
| 106 | + "prettier", |
| 107 | + ), |
| 108 | + |
| 109 | + plugins: { |
| 110 | + "@typescript-eslint": typescriptEslint, |
| 111 | + }, |
| 112 | + |
| 113 | + languageOptions: { |
| 114 | + parser: tsParser, |
| 115 | + ecmaVersion: "latest", |
| 116 | + sourceType: "module", |
| 117 | + }, |
| 118 | + }, |
| 119 | + { |
| 120 | + files: ["**/*.vue"], |
| 121 | + extends: compat.extends("plugin:vue/recommended"), |
| 122 | + |
| 123 | + languageOptions: { |
| 124 | + parser: vueParser, |
| 125 | + ecmaVersion: "latest", |
| 126 | + sourceType: "module", |
| 127 | + |
| 128 | + parserOptions: { |
| 129 | + ecmaFeatures: { |
| 130 | + modules: true, |
| 131 | + }, |
| 132 | + }, |
| 133 | + }, |
| 134 | + }, |
| 135 | +]); |
0 commit comments