|
| 1 | +import tsEslintPlugin from '@typescript-eslint/eslint-plugin'; |
| 2 | +import globals from 'globals'; |
| 3 | +import tsParser from '@typescript-eslint/parser'; |
| 4 | +import path from 'node:path'; |
| 5 | +import { fileURLToPath } from 'node:url'; |
| 6 | +import js from '@eslint/js'; |
| 7 | +import { FlatCompat } from '@eslint/eslintrc'; |
| 8 | + |
| 9 | +const __filename = fileURLToPath(import.meta.url); |
| 10 | +const __dirname = path.dirname(__filename); |
| 11 | +const compat = new FlatCompat({ |
| 12 | + baseDirectory: __dirname, |
| 13 | + recommendedConfig: js.configs.recommended, |
| 14 | + allConfig: js.configs.all, |
| 15 | +}); |
| 16 | + |
| 17 | +export default [ |
| 18 | + ...compat.extends( |
| 19 | + 'plugin:@typescript-eslint/recommended', |
| 20 | + 'plugin:prettier/recommended', |
| 21 | + ), |
| 22 | + { |
| 23 | + plugins: { |
| 24 | + '@typescript-eslint': tsEslintPlugin, |
| 25 | + }, |
| 26 | + languageOptions: { |
| 27 | + globals: { |
| 28 | + ...globals.node, |
| 29 | + ...globals.jest, |
| 30 | + }, |
| 31 | + parser: tsParser, |
| 32 | + ecmaVersion: 5, |
| 33 | + sourceType: 'module', |
| 34 | + parserOptions: { |
| 35 | + project: 'tsconfig.json', |
| 36 | + tsconfigRootDir: __dirname, |
| 37 | + }, |
| 38 | + }, |
| 39 | + rules: { |
| 40 | + '@typescript-eslint/interface-name-prefix': 'off', |
| 41 | + '@typescript-eslint/explicit-function-return-type': 'off', |
| 42 | + '@typescript-eslint/explicit-module-boundary-types': 'off', |
| 43 | + '@typescript-eslint/no-explicit-any': 'off', |
| 44 | + 'no-unused-vars': 'off', |
| 45 | + '@typescript-eslint/no-unused-vars': ['error'], |
| 46 | + 'require-await': 'off', |
| 47 | + '@typescript-eslint/require-await': 'error', |
| 48 | + '@typescript-eslint/no-floating-promises': 'error', |
| 49 | + 'no-restricted-syntax': [ |
| 50 | + 'error', |
| 51 | + { |
| 52 | + selector: |
| 53 | + 'CallExpression[callee.object.name=configService][callee.property.name=/^(get|getOrThrow)$/]:not(:has([arguments.1] Property[key.name=infer][value.value=true])), CallExpression[callee.object.property.name=configService][callee.property.name=/^(get|getOrThrow)$/]:not(:has([arguments.1] Property[key.name=infer][value.value=true]))', |
| 54 | + message: |
| 55 | + 'Add "{ infer: true }" to configService.get() for correct typechecking. Example: configService.get("database.port", { infer: true })', |
| 56 | + }, |
| 57 | + { |
| 58 | + selector: |
| 59 | + 'CallExpression[callee.name=it][arguments.0.value!=/^should/]', |
| 60 | + message: '"it" should start with "should"', |
| 61 | + }, |
| 62 | + ], |
| 63 | + }, |
| 64 | + }, |
| 65 | +]; |
0 commit comments