|
| 1 | +import js from "@eslint/js" |
| 2 | +import tseslint from "typescript-eslint" |
| 3 | +import prettier from "eslint-plugin-prettier" |
| 4 | +import prettierConfig from "eslint-config-prettier" |
| 5 | +import globals from "globals" |
| 6 | +import { Linter } from "eslint" |
| 7 | + |
| 8 | +export default [ |
| 9 | + { |
| 10 | + ignores: ["dist/", "node_modules/", "eslint.config.ts", "src/parser/cst-types.d.ts"], |
| 11 | + }, |
| 12 | + { |
| 13 | + files: ["**/*.{js,ts}"], |
| 14 | + languageOptions: { |
| 15 | + globals: { |
| 16 | + ...globals.node, |
| 17 | + ...globals.es2020, |
| 18 | + }, |
| 19 | + ecmaVersion: 2020, |
| 20 | + sourceType: "module", |
| 21 | + }, |
| 22 | + plugins: { |
| 23 | + prettier, |
| 24 | + }, |
| 25 | + rules: { |
| 26 | + "prettier/prettier": "warn", |
| 27 | + }, |
| 28 | + }, |
| 29 | + { |
| 30 | + files: ["src/**/*.ts"], |
| 31 | + languageOptions: { |
| 32 | + parser: tseslint.parser, |
| 33 | + parserOptions: { |
| 34 | + project: "./tsconfig.json", |
| 35 | + tsconfigRootDir: import.meta.dirname, |
| 36 | + }, |
| 37 | + }, |
| 38 | + plugins: { |
| 39 | + "@typescript-eslint": tseslint.plugin, |
| 40 | + }, |
| 41 | + rules: { |
| 42 | + ...js.configs.recommended.rules, |
| 43 | + ...tseslint.configs.recommended.reduce( |
| 44 | + (acc, config) => ({ ...acc, ...config.rules }), |
| 45 | + {} as Linter.RulesRecord, |
| 46 | + ), |
| 47 | + ...tseslint.configs.recommendedTypeChecked.reduce( |
| 48 | + (acc, config) => ({ ...acc, ...config.rules }), |
| 49 | + {} as Linter.RulesRecord, |
| 50 | + ), |
| 51 | + |
| 52 | + "@typescript-eslint/explicit-function-return-type": "off", |
| 53 | + "@typescript-eslint/explicit-module-boundary-types": "off", |
| 54 | + "@typescript-eslint/no-unused-vars": [ |
| 55 | + "error", |
| 56 | + { |
| 57 | + caughtErrors: "none", |
| 58 | + argsIgnorePattern: "^_", |
| 59 | + }, |
| 60 | + ], |
| 61 | + "@typescript-eslint/strict-boolean-expressions": "off", |
| 62 | + "@typescript-eslint/consistent-type-definitions": "off", |
| 63 | + "@typescript-eslint/no-misused-promises": [ |
| 64 | + "error", |
| 65 | + { |
| 66 | + checksVoidReturn: false, |
| 67 | + }, |
| 68 | + ], |
| 69 | + |
| 70 | + "quote-props": ["error", "as-needed"], |
| 71 | + "object-shorthand": ["error", "always"], |
| 72 | + "no-unused-vars": "off", |
| 73 | + "no-var": ["error"], |
| 74 | + "no-console": [ |
| 75 | + "warn", |
| 76 | + { |
| 77 | + allow: ["warn", "error", "info"], |
| 78 | + }, |
| 79 | + ], |
| 80 | + // NaN is used as a Chevrotain token name (SQL NaN keyword) |
| 81 | + "no-shadow-restricted-names": "off", |
| 82 | + }, |
| 83 | + }, |
| 84 | + |
| 85 | + prettierConfig, |
| 86 | +] satisfies Linter.Config[] |
0 commit comments