|
| 1 | +import { defineConfig, globalIgnores } from 'eslint/config'; |
| 2 | +import typescriptEslint from '@typescript-eslint/eslint-plugin'; |
| 3 | +import jest from 'eslint-plugin-jest'; |
| 4 | +import prettier from 'eslint-plugin-prettier'; |
| 5 | +import globals from 'globals'; |
| 6 | +import tsParser from '@typescript-eslint/parser'; |
| 7 | +import path from 'node:path'; |
| 8 | +import { fileURLToPath } from 'node:url'; |
| 9 | +import js from '@eslint/js'; |
| 10 | +import { FlatCompat } from '@eslint/eslintrc'; |
| 11 | + |
| 12 | +const __filename = fileURLToPath(import.meta.url); |
| 13 | +const __dirname = path.dirname(__filename); |
| 14 | +const compat = new FlatCompat({ |
| 15 | + baseDirectory: __dirname, |
| 16 | + recommendedConfig: js.configs.recommended, |
| 17 | + allConfig: js.configs.all, |
| 18 | +}); |
| 19 | + |
| 20 | +export default defineConfig([ |
| 21 | + globalIgnores([ |
| 22 | + 'coverage/**/*', |
| 23 | + 'dist/**/*', |
| 24 | + 'scripts/**/*', |
| 25 | + '**/*.sh', |
| 26 | + 'coverage/**/*', |
| 27 | + 'dist/**/*', |
| 28 | + 'scripts/**/*', |
| 29 | + '**/*.sh', |
| 30 | + '**/rollup.config.js', |
| 31 | + '**/populate-readme.cjs', |
| 32 | + ]), |
| 33 | + { |
| 34 | + extends: compat.extends( |
| 35 | + 'eslint:recommended', |
| 36 | + 'plugin:@typescript-eslint/eslint-recommended', |
| 37 | + 'plugin:@typescript-eslint/recommended', |
| 38 | + 'plugin:jest/recommended', |
| 39 | + 'plugin:prettier/recommended', |
| 40 | + ), |
| 41 | + |
| 42 | + plugins: { |
| 43 | + '@typescript-eslint': typescriptEslint, |
| 44 | + jest, |
| 45 | + prettier, |
| 46 | + }, |
| 47 | + |
| 48 | + languageOptions: { |
| 49 | + globals: { |
| 50 | + ...globals.node, |
| 51 | + }, |
| 52 | + |
| 53 | + parser: tsParser, |
| 54 | + ecmaVersion: 5, |
| 55 | + sourceType: 'commonjs', |
| 56 | + |
| 57 | + parserOptions: { |
| 58 | + project: './tsconfig.json', |
| 59 | + tsconfigRootDir: './', |
| 60 | + }, |
| 61 | + }, |
| 62 | + |
| 63 | + rules: { |
| 64 | + '@typescript-eslint/explicit-function-return-type': [ |
| 65 | + 'error', |
| 66 | + { |
| 67 | + allowExpressions: true, |
| 68 | + allowConciseArrowFunctionExpressionsStartingWithVoid: true, |
| 69 | + }, |
| 70 | + ], |
| 71 | + |
| 72 | + '@typescript-eslint/no-floating-promises': ['error'], |
| 73 | + '@typescript-eslint/no-shadow': ['error'], |
| 74 | + '@typescript-eslint/explicit-member-accessibility': ['error'], |
| 75 | + 'no-console': ['error'], |
| 76 | + 'no-return-await': ['error'], |
| 77 | + |
| 78 | + 'padding-line-between-statements': [ |
| 79 | + 'error', |
| 80 | + { |
| 81 | + blankLine: 'always', |
| 82 | + prev: '*', |
| 83 | + next: 'function', |
| 84 | + }, |
| 85 | + ], |
| 86 | + |
| 87 | + 'prettier/prettier': [ |
| 88 | + 'error', |
| 89 | + {}, |
| 90 | + { |
| 91 | + usePrettierrc: true, |
| 92 | + }, |
| 93 | + ], |
| 94 | + |
| 95 | + 'require-await': ['error'], |
| 96 | + }, |
| 97 | + }, |
| 98 | + { |
| 99 | + files: ['test/**/*.js'], |
| 100 | + |
| 101 | + rules: { |
| 102 | + '@typescript-eslint/explicit-function-return-type': 'off', |
| 103 | + }, |
| 104 | + }, |
| 105 | +]); |
0 commit comments