|
| 1 | +import { defineConfig, globalIgnores } from "eslint/config"; |
| 2 | +import typescriptEslint from "@typescript-eslint/eslint-plugin"; |
| 3 | +import globals from "globals"; |
| 4 | +import tsParser from "@typescript-eslint/parser"; |
| 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 defineConfig([globalIgnores([ |
| 19 | + "node_modules/**", |
| 20 | + "dist/**", |
| 21 | + "dist-esm/**", |
| 22 | + "types/**", |
| 23 | + "*.min.js", |
| 24 | + "coverage/**" |
| 25 | +]), { |
| 26 | + extends: compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"), |
| 27 | + |
| 28 | + plugins: { |
| 29 | + "@typescript-eslint": typescriptEslint, |
| 30 | + }, |
| 31 | + |
| 32 | + languageOptions: { |
| 33 | + globals: { |
| 34 | + ...globals.browser, |
| 35 | + ...globals.commonjs, |
| 36 | + ...globals.node, |
| 37 | + ...globals.mocha, |
| 38 | + }, |
| 39 | + |
| 40 | + parser: tsParser, |
| 41 | + ecmaVersion: "latest", |
| 42 | + sourceType: "commonjs", |
| 43 | + }, |
| 44 | + |
| 45 | + rules: { |
| 46 | + "keyword-spacing": ["error", { |
| 47 | + before: true, |
| 48 | + after: true, |
| 49 | + }], |
| 50 | + |
| 51 | + quotes: ["error", "double", { |
| 52 | + avoidEscape: true, |
| 53 | + }], |
| 54 | + |
| 55 | + "@typescript-eslint/no-explicit-any": "off", |
| 56 | + "eol-last": ["error", "always"], |
| 57 | + "no-trailing-spaces": "error", |
| 58 | + "space-before-blocks": ["error", "always"], |
| 59 | + "no-multi-spaces": "error", |
| 60 | + |
| 61 | + "no-multiple-empty-lines": ["error", { |
| 62 | + max: 1, |
| 63 | + }], |
| 64 | + |
| 65 | + semi: ["error", "always"], |
| 66 | + }, |
| 67 | +}, { |
| 68 | + files: ["**/.eslintrc.{js,cjs}"], |
| 69 | + |
| 70 | + languageOptions: { |
| 71 | + globals: { |
| 72 | + ...globals.node, |
| 73 | + }, |
| 74 | + |
| 75 | + ecmaVersion: 5, |
| 76 | + sourceType: "commonjs", |
| 77 | + }, |
| 78 | +}]); |
0 commit comments