|
| 1 | +import eslint from '@eslint/js'; |
| 2 | +import tseslint from 'typescript-eslint'; |
| 3 | +import importPlugin from 'eslint-plugin-import'; |
| 4 | + |
| 5 | +export default [ |
| 6 | + { |
| 7 | + ignores: [ |
| 8 | + 'node_modules/**', |
| 9 | + 'dist/**', |
| 10 | + 'build/**', |
| 11 | + '.next/**', |
| 12 | + 'coverage/**', |
| 13 | + '*.min.js', |
| 14 | + '.turbo/**', |
| 15 | + '.vercel/**', |
| 16 | + 'packages/*/dist/**', |
| 17 | + 'packages/*/build/**', |
| 18 | + 'packages/*/node_modules/**' |
| 19 | + ] |
| 20 | + }, |
| 21 | + eslint.configs.recommended, |
| 22 | + ...tseslint.configs.recommended, |
| 23 | + { |
| 24 | + files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.js', '**/*.jsx'], |
| 25 | + plugins: { |
| 26 | + import: importPlugin |
| 27 | + }, |
| 28 | + languageOptions: { |
| 29 | + parser: tseslint.parser, |
| 30 | + parserOptions: { |
| 31 | + ecmaVersion: 2022, |
| 32 | + sourceType: 'module' |
| 33 | + }, |
| 34 | + globals: { |
| 35 | + console: 'readonly', |
| 36 | + process: 'readonly', |
| 37 | + Buffer: 'readonly', |
| 38 | + __dirname: 'readonly', |
| 39 | + __filename: 'readonly', |
| 40 | + exports: 'writable', |
| 41 | + module: 'readonly', |
| 42 | + require: 'readonly', |
| 43 | + window: 'readonly', |
| 44 | + document: 'readonly', |
| 45 | + navigator: 'readonly', |
| 46 | + fetch: 'readonly' |
| 47 | + } |
| 48 | + }, |
| 49 | + settings: { |
| 50 | + 'import/resolver': { |
| 51 | + typescript: true |
| 52 | + } |
| 53 | + }, |
| 54 | + rules: { |
| 55 | + 'array-callback-return': 'error', |
| 56 | + 'default-case': ['error', { commentPattern: '^no default$' }], |
| 57 | + 'dot-location': ['error', 'property'], |
| 58 | + 'eqeqeq': ['error', 'smart'], |
| 59 | + 'new-parens': 'error', |
| 60 | + 'no-array-constructor': 'error', |
| 61 | + 'no-caller': 'error', |
| 62 | + 'no-cond-assign': ['error', 'except-parens'], |
| 63 | + 'no-const-assign': 'error', |
| 64 | + 'no-control-regex': 'error', |
| 65 | + 'no-delete-var': 'error', |
| 66 | + 'no-dupe-args': 'error', |
| 67 | + 'no-dupe-class-members': 'error', |
| 68 | + 'no-dupe-keys': 'error', |
| 69 | + 'no-duplicate-case': 'error', |
| 70 | + 'no-empty-character-class': 'error', |
| 71 | + 'no-empty-pattern': 'error', |
| 72 | + 'no-eval': 'error', |
| 73 | + 'no-ex-assign': 'error', |
| 74 | + 'no-extend-native': 'error', |
| 75 | + 'no-extra-bind': 'error', |
| 76 | + 'no-extra-label': 'error', |
| 77 | + 'no-fallthrough': 'error', |
| 78 | + 'no-func-assign': 'error', |
| 79 | + 'no-implied-eval': 'error', |
| 80 | + 'no-invalid-regexp': 'error', |
| 81 | + 'no-iterator': 'error', |
| 82 | + 'no-label-var': 'error', |
| 83 | + 'no-labels': ['error', { allowLoop: true, allowSwitch: false }], |
| 84 | + 'no-lone-blocks': 'error', |
| 85 | + 'no-loop-func': 'error', |
| 86 | + 'no-multi-str': 'error', |
| 87 | + 'no-new-func': 'error', |
| 88 | + 'no-new-object': 'error', |
| 89 | + 'no-new-symbol': 'error', |
| 90 | + 'no-new-wrappers': 'error', |
| 91 | + 'no-obj-calls': 'error', |
| 92 | + 'no-octal': 'error', |
| 93 | + 'no-octal-escape': 'error', |
| 94 | + 'no-regex-spaces': 'error', |
| 95 | + 'no-restricted-syntax': [ |
| 96 | + 'error', |
| 97 | + 'WithStatement', |
| 98 | + { |
| 99 | + message: "substr() is deprecated, use slice() or substring() instead", |
| 100 | + selector: "MemberExpression > Identifier[name='substr']" |
| 101 | + } |
| 102 | + ], |
| 103 | + 'no-script-url': 'error', |
| 104 | + 'no-self-assign': 'error', |
| 105 | + 'no-self-compare': 'error', |
| 106 | + 'no-sequences': 'error', |
| 107 | + 'no-shadow': 'warn', |
| 108 | + 'no-shadow-restricted-names': 'error', |
| 109 | + 'no-sparse-arrays': 'error', |
| 110 | + 'no-template-curly-in-string': 'error', |
| 111 | + 'no-this-before-super': 'error', |
| 112 | + 'no-throw-literal': 'error', |
| 113 | + 'no-undef': 'error', |
| 114 | + 'no-unexpected-multiline': 'error', |
| 115 | + 'no-unreachable': 'error', |
| 116 | + 'no-unused-expressions': [ |
| 117 | + 'error', |
| 118 | + { |
| 119 | + allowShortCircuit: true, |
| 120 | + allowTernary: true, |
| 121 | + allowTaggedTemplates: true |
| 122 | + } |
| 123 | + ], |
| 124 | + 'no-unused-labels': 'error', |
| 125 | + 'no-unused-vars': 'off', |
| 126 | + 'no-useless-computed-key': 'error', |
| 127 | + 'no-useless-concat': 'error', |
| 128 | + 'no-useless-constructor': 'off', |
| 129 | + 'no-useless-escape': 'error', |
| 130 | + 'no-useless-rename': [ |
| 131 | + 'error', |
| 132 | + { |
| 133 | + ignoreDestructuring: false, |
| 134 | + ignoreImport: false, |
| 135 | + ignoreExport: false |
| 136 | + } |
| 137 | + ], |
| 138 | + 'no-with': 'error', |
| 139 | + 'no-whitespace-before-property': 'error', |
| 140 | + 'require-yield': 'error', |
| 141 | + 'rest-spread-spacing': ['error', 'never'], |
| 142 | + 'strict': ['error', 'never'], |
| 143 | + 'unicode-bom': ['error', 'never'], |
| 144 | + 'use-isnan': 'error', |
| 145 | + 'valid-typeof': 'error', |
| 146 | + 'getter-return': 'error', |
| 147 | + 'prefer-const': 'error', |
| 148 | + '@typescript-eslint/prefer-as-const': 'error', |
| 149 | + '@typescript-eslint/no-redeclare': [ |
| 150 | + 'error', |
| 151 | + { builtinGlobals: false, ignoreDeclarationMerge: true } |
| 152 | + ], |
| 153 | + '@typescript-eslint/no-explicit-any': 'off', |
| 154 | + '@typescript-eslint/no-unused-vars': [ |
| 155 | + 'error', |
| 156 | + { |
| 157 | + args: 'none', |
| 158 | + ignoreRestSiblings: true, |
| 159 | + argsIgnorePattern: '^_', |
| 160 | + caughtErrors: 'none', |
| 161 | + caughtErrorsIgnorePattern: '^_', |
| 162 | + destructuredArrayIgnorePattern: '^_', |
| 163 | + varsIgnorePattern: '^_' |
| 164 | + } |
| 165 | + ], |
| 166 | + '@typescript-eslint/no-empty-function': 'off', |
| 167 | + '@typescript-eslint/no-namespace': 'off', |
| 168 | + '@typescript-eslint/no-var-requires': 'off', |
| 169 | + '@typescript-eslint/ban-ts-comment': 'off', |
| 170 | + '@typescript-eslint/consistent-type-imports': [ |
| 171 | + 'error', |
| 172 | + { |
| 173 | + disallowTypeAnnotations: false |
| 174 | + } |
| 175 | + ], |
| 176 | + '@typescript-eslint/no-import-type-side-effects': 'error', |
| 177 | + 'no-use-before-define': 'off', |
| 178 | + '@typescript-eslint/no-use-before-define': 'off', |
| 179 | + 'no-case-declarations': 'warn', |
| 180 | + 'no-constant-condition': 'warn' |
| 181 | + } |
| 182 | + }, |
| 183 | + { |
| 184 | + files: ['packages/cli/**/*.ts', 'packages/create-mcp-use-app/**/*.ts'], |
| 185 | + rules: { |
| 186 | + 'no-console': 'off', |
| 187 | + 'no-process-exit': 'off' |
| 188 | + } |
| 189 | + }, |
| 190 | + { |
| 191 | + files: ['packages/mcp-use/**/*.ts'], |
| 192 | + rules: { |
| 193 | + 'import/no-extraneous-dependencies': [ |
| 194 | + 'error', |
| 195 | + { devDependencies: false } |
| 196 | + ] |
| 197 | + } |
| 198 | + }, |
| 199 | + { |
| 200 | + files: ['**/*.test.ts', '**/*.test.tsx', 'tests/**/*.ts'], |
| 201 | + languageOptions: { |
| 202 | + globals: { |
| 203 | + jest: 'readonly' |
| 204 | + } |
| 205 | + }, |
| 206 | + rules: { |
| 207 | + 'import/no-extraneous-dependencies': 'off' |
| 208 | + } |
| 209 | + }, |
| 210 | + { |
| 211 | + files: ['examples/**/*', 'packages/*/examples/**/*'], |
| 212 | + rules: { |
| 213 | + 'import/no-extraneous-dependencies': 'off', |
| 214 | + 'no-console': 'off', |
| 215 | + '@typescript-eslint/no-unused-vars': 'off', |
| 216 | + 'no-constant-condition': 'off', |
| 217 | + 'default-case': 'off', |
| 218 | + 'no-new-func': 'off', |
| 219 | + 'no-useless-escape': 'off', |
| 220 | + 'no-case-declarations': 'off', |
| 221 | + 'require-yield': 'off' |
| 222 | + } |
| 223 | + }, |
| 224 | + { |
| 225 | + files: ['**/*.test.ts', '**/*.test.tsx', '**/*.spec.ts', '**/*.spec.tsx', '**/vitest.config.ts', '**/vitest.config.mts'], |
| 226 | + languageOptions: { |
| 227 | + globals: { |
| 228 | + jest: 'readonly' |
| 229 | + } |
| 230 | + }, |
| 231 | + rules: { |
| 232 | + 'no-unused-vars': 'off', |
| 233 | + '@typescript-eslint/no-unused-vars': 'off', |
| 234 | + 'no-unreachable-loop': 'off', |
| 235 | + 'no-console': 'off', |
| 236 | + 'import/no-extraneous-dependencies': 'off', |
| 237 | + '@typescript-eslint/no-explicit-any': 'off', |
| 238 | + 'no-shadow': 'off', |
| 239 | + '@typescript-eslint/no-shadow': 'off', |
| 240 | + 'no-constant-condition': 'off', |
| 241 | + 'require-yield': 'off' |
| 242 | + } |
| 243 | + } |
| 244 | +]; |
| 245 | + |
0 commit comments