|
| 1 | +import eslint from '@eslint/js'; |
| 2 | +import tseslint from 'typescript-eslint'; |
| 3 | +import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; |
| 4 | +import pluginChaiFriendly from 'eslint-plugin-chai-friendly'; |
| 5 | + |
| 6 | +export default tseslint.config( |
| 7 | + eslint.configs.recommended, |
| 8 | + tseslint.configs.recommendedTypeChecked, |
| 9 | + eslintPluginPrettierRecommended, |
| 10 | + { |
| 11 | + languageOptions: { |
| 12 | + parserOptions: { |
| 13 | + projectService: true, |
| 14 | + tsconfigRootDir: import.meta.dirname, |
| 15 | + }, |
| 16 | + }, |
| 17 | + rules: { |
| 18 | + '@typescript-eslint/no-explicit-any': ['off'], |
| 19 | + '@typescript-eslint/no-use-before-define': ['off'], |
| 20 | + '@typescript-eslint/no-empty-object-type': ['off'], |
| 21 | + '@typescript-eslint/no-unsafe-function-type': 'off', |
| 22 | + '@typescript-eslint/no-restricted-types': [ |
| 23 | + 'error', |
| 24 | + { |
| 25 | + types: { |
| 26 | + String: { |
| 27 | + message: 'Use string instead', |
| 28 | + fixWith: 'string', |
| 29 | + }, |
| 30 | + Boolean: { |
| 31 | + message: 'Use boolean instead', |
| 32 | + fixWith: 'boolean', |
| 33 | + }, |
| 34 | + Number: { |
| 35 | + message: 'Use number instead', |
| 36 | + fixWith: 'number', |
| 37 | + }, |
| 38 | + Symbol: { |
| 39 | + message: 'Use symbol instead', |
| 40 | + fixWith: 'symbol', |
| 41 | + }, |
| 42 | + |
| 43 | + // object typing |
| 44 | + Object: { |
| 45 | + message: |
| 46 | + 'The `Object` type actually means "any non-nullish value", so it is marginally better than `unknown`.\n- If you want a type meaning "any object", you probably want `Record<string, unknown>` instead.\n- If you want a type meaning "any value", you probably want `unknown` instead.', |
| 47 | + }, |
| 48 | + object: { |
| 49 | + message: |
| 50 | + 'The `object` type is currently hard to use ([see this issue](https://github.com/microsoft/TypeScript/issues/21732)).\nConsider using `Record<string, unknown>` instead, as it allows you to more easily inspect and use the keys.', |
| 51 | + }, |
| 52 | + }, |
| 53 | + }, |
| 54 | + ], |
| 55 | + }, |
| 56 | + }, |
| 57 | + { |
| 58 | + plugins: { 'chai-friendly': pluginChaiFriendly }, |
| 59 | + files: ['test/**/*.@(ts|js|mts|cts)'], |
| 60 | + rules: { |
| 61 | + 'no-unused-expressions': 'off', // disable original rule |
| 62 | + '@typescript-eslint/no-unused-expressions': 'off', // disable original rule |
| 63 | + 'chai-friendly/no-unused-expressions': 'error', |
| 64 | + }, |
| 65 | + }, |
| 66 | + { |
| 67 | + ignores: [ |
| 68 | + 'testResources/**/*.ts', |
| 69 | + 'reports', |
| 70 | + '.nyc_output', |
| 71 | + 'dist', |
| 72 | + 'eslint.config.js', |
| 73 | + ], |
| 74 | + }, |
| 75 | +); |
0 commit comments