|
| 1 | +import js from '@eslint/js' |
| 2 | +import comments from '@eslint-community/eslint-plugin-eslint-comments/configs' |
| 3 | +import stylistic from '@stylistic/eslint-plugin' |
| 4 | +import importPlugin from 'eslint-plugin-import-x' |
| 5 | +import jestPlugin from 'eslint-plugin-jest' |
| 6 | +import globals from 'globals' |
| 7 | +import tseslint from 'typescript-eslint' |
| 8 | + |
| 9 | + |
| 10 | +export default tseslint.config( |
| 11 | + { |
| 12 | + ignores: [ |
| 13 | + 'dist/**', |
| 14 | + 'dist_bin/**', |
| 15 | + 'coverage/**', |
| 16 | + 'jest-html-reporters-attach/**', |
| 17 | + ], |
| 18 | + }, |
| 19 | + js.configs.recommended, |
| 20 | + ...tseslint.configs.recommended, |
| 21 | + comments.recommended, |
| 22 | + { |
| 23 | + files: ['**/*.ts'], |
| 24 | + plugins: { |
| 25 | + '@stylistic': stylistic, |
| 26 | + import: importPlugin, |
| 27 | + jest: jestPlugin, |
| 28 | + }, |
| 29 | + languageOptions: { |
| 30 | + ecmaVersion: 2023, |
| 31 | + sourceType: 'module', |
| 32 | + parserOptions: { |
| 33 | + project: ['./tsconfig.json'], |
| 34 | + tsconfigRootDir: import.meta.dirname, |
| 35 | + }, |
| 36 | + globals: { |
| 37 | + ...globals.node, |
| 38 | + Atomics: 'readonly', |
| 39 | + SharedArrayBuffer: 'readonly', |
| 40 | + }, |
| 41 | + }, |
| 42 | + rules: { |
| 43 | + indent: 'off', |
| 44 | + '@stylistic/indent': [ |
| 45 | + 'error', |
| 46 | + 'tab', |
| 47 | + { |
| 48 | + FunctionDeclaration: { body: 1, parameters: 2 }, |
| 49 | + FunctionExpression: { body: 1, parameters: 2 }, |
| 50 | + SwitchCase: 1, |
| 51 | + }, |
| 52 | + ], |
| 53 | + 'linebreak-style': ['error', 'unix'], |
| 54 | + '@stylistic/quotes': [ |
| 55 | + 'error', |
| 56 | + 'single', |
| 57 | + { avoidEscape: true }, |
| 58 | + ], |
| 59 | + curly: ['error', 'all'], |
| 60 | + 'comma-dangle': [ |
| 61 | + 'error', |
| 62 | + 'always-multiline', |
| 63 | + ], |
| 64 | + 'no-console': 'off', |
| 65 | + 'no-process-exit': 'error', |
| 66 | + 'no-template-curly-in-string': 'error', |
| 67 | + 'require-await': 'off', |
| 68 | + '@stylistic/semi': ['error', 'never'], |
| 69 | + '@stylistic/member-delimiter-style': [ |
| 70 | + 'error', |
| 71 | + { |
| 72 | + multiline: { |
| 73 | + delimiter: 'none', |
| 74 | + requireLast: true, |
| 75 | + }, |
| 76 | + singleline: { |
| 77 | + delimiter: 'semi', |
| 78 | + requireLast: false, |
| 79 | + }, |
| 80 | + }, |
| 81 | + ], |
| 82 | + '@typescript-eslint/consistent-type-definitions': ['error', 'type'], |
| 83 | + '@typescript-eslint/explicit-function-return-type': ['error', { |
| 84 | + allowExpressions: true, |
| 85 | + }], |
| 86 | + '@typescript-eslint/explicit-module-boundary-types': 'error', |
| 87 | + '@typescript-eslint/no-explicit-any': 'error', |
| 88 | + '@typescript-eslint/no-non-null-assertion': 'error', |
| 89 | + 'no-use-before-define': 'off', |
| 90 | + '@typescript-eslint/no-use-before-define': [ |
| 91 | + 'error', |
| 92 | + { functions: false, classes: false, enums: false, variables: true }, |
| 93 | + ], |
| 94 | + '@typescript-eslint/no-require-imports': 'error', |
| 95 | + '@typescript-eslint/ban-ts-comment': 'error', |
| 96 | + '@typescript-eslint/no-floating-promises': 'error', |
| 97 | + '@stylistic/space-infix-ops': 'error', |
| 98 | + '@stylistic/object-curly-spacing': ['error', 'always'], |
| 99 | + '@stylistic/comma-spacing': ['error'], |
| 100 | + '@stylistic/type-annotation-spacing': 'error', |
| 101 | + |
| 102 | + // disallow non-import statements appearing before import statements |
| 103 | + 'import/first': 'error', |
| 104 | + // Require a newline after the last import/require in a group |
| 105 | + 'import/newline-after-import': ['error', { 'count': 2 }], |
| 106 | + // Forbid import of modules using absolute paths |
| 107 | + 'import/no-absolute-path': 'error', |
| 108 | + // disallow AMD require/define |
| 109 | + 'import/no-amd': 'error', |
| 110 | + // Forbid mutable exports |
| 111 | + 'import/no-mutable-exports': 'error', |
| 112 | + // Prevent importing the default as if it were named |
| 113 | + 'import/no-named-default': 'error', |
| 114 | + // Prohibit named exports |
| 115 | + 'import/no-named-export': 'off', // we want everything to be a named export |
| 116 | + // Forbid a module from importing itself |
| 117 | + 'import/no-self-import': 'error', |
| 118 | + // Require modules with a single export to use a default export |
| 119 | + 'import/prefer-default-export': 'off', // we want everything to be named |
| 120 | + '@typescript-eslint/naming-convention': [ |
| 121 | + 'error', |
| 122 | + { |
| 123 | + selector: 'default', |
| 124 | + format: ['camelCase'], |
| 125 | + leadingUnderscore: 'allow', |
| 126 | + trailingUnderscore: 'allow', |
| 127 | + // interfaces on the Hub are snake_case |
| 128 | + filter: { |
| 129 | + regex: '^(driver_id|driver_name|log_level|driver_id|driver_name|archive_hash)$', |
| 130 | + match: false, |
| 131 | + }, |
| 132 | + }, |
| 133 | + { |
| 134 | + selector: 'variable', |
| 135 | + format: ['camelCase', 'UPPER_CASE'], |
| 136 | + leadingUnderscore: 'allow', |
| 137 | + trailingUnderscore: 'allow', |
| 138 | + }, |
| 139 | + { |
| 140 | + selector: 'typeLike', |
| 141 | + format: ['PascalCase'], |
| 142 | + }, |
| 143 | + { |
| 144 | + selector: 'objectLiteralProperty', |
| 145 | + format: ['camelCase', 'PascalCase'], |
| 146 | + }, |
| 147 | + { |
| 148 | + selector: 'enumMember', |
| 149 | + format: ['PascalCase', 'UPPER_CASE'], |
| 150 | + }, |
| 151 | + { |
| 152 | + selector: 'import', |
| 153 | + format: ['camelCase', 'PascalCase'], |
| 154 | + }, |
| 155 | + ], |
| 156 | + }, |
| 157 | + }, |
| 158 | +) |
0 commit comments