|
| 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([ |
| 19 | + globalIgnores(['src/antlr', '**/dist']), |
| 20 | + { |
| 21 | + extends: compat.extends('eslint:recommended'), |
| 22 | + |
| 23 | + plugins: { |
| 24 | + '@typescript-eslint': typescriptEslint, |
| 25 | + }, |
| 26 | + |
| 27 | + languageOptions: { |
| 28 | + globals: { |
| 29 | + ...globals.mocha, |
| 30 | + ...globals.node, |
| 31 | + }, |
| 32 | + |
| 33 | + parser: tsParser, |
| 34 | + }, |
| 35 | + |
| 36 | + rules: { |
| 37 | + 'no-var': 'error', |
| 38 | + 'object-curly-spacing': ['error', 'always'], |
| 39 | + 'object-shorthand': 'error', |
| 40 | + 'prefer-const': 'error', |
| 41 | + 'max-len': 'off', |
| 42 | + }, |
| 43 | + }, |
| 44 | + { |
| 45 | + files: ['**/*.ts'], |
| 46 | + |
| 47 | + extends: compat.extends( |
| 48 | + 'eslint:recommended', |
| 49 | + 'plugin:@typescript-eslint/recommended', |
| 50 | + 'plugin:@typescript-eslint/recommended-requiring-type-checking' |
| 51 | + ), |
| 52 | + |
| 53 | + plugins: { |
| 54 | + '@typescript-eslint': typescriptEslint, |
| 55 | + }, |
| 56 | + |
| 57 | + languageOptions: { |
| 58 | + parser: tsParser, |
| 59 | + ecmaVersion: 5, |
| 60 | + sourceType: 'script', |
| 61 | + |
| 62 | + parserOptions: { |
| 63 | + project: ['./tsconfig.json'], |
| 64 | + }, |
| 65 | + }, |
| 66 | + |
| 67 | + rules: { |
| 68 | + '@typescript-eslint/no-explicit-any': 'off', |
| 69 | + '@typescript-eslint/strict-boolean-expressions': 'off', |
| 70 | + '@typescript-eslint/no-unsafe-call': 'off', |
| 71 | + '@typescript-eslint/no-unsafe-member-access': 'off', |
| 72 | + '@typescript-eslint/no-unsafe-assignment': 'off', |
| 73 | + '@typescript-eslint/explicit-module-boundary-types': 'off', |
| 74 | + '@typescript-eslint/no-unsafe-return': 'off', |
| 75 | + '@typescript-eslint/no-empty-interface': 'off', |
| 76 | + '@typescript-eslint/no-non-null-assertion': 'off', |
| 77 | + }, |
| 78 | + }, |
| 79 | +]) |
0 commit comments