const js = require('@eslint/js');
const tsParser = require('@typescript-eslint/parser');
const tsPlugin = require('@typescript-eslint/eslint-plugin');
module.exports = [
js.configs.recommended,
{
files: ['**/*.ts'],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: './tsconfig.json'
},
globals: {
console: 'readonly',
process: 'readonly',
Buffer: 'readonly',
__dirname: 'readonly',
__filename: 'readonly',
module: 'readonly',
require: 'readonly',
exports: 'readonly',
global: 'readonly'
}
},
plugins: {
'@typescript-eslint': tsPlugin
},
rules: {
// Basic ESLint rules
'no-unused-vars': 'off', // Turned off in favor of TypeScript version
'no-console': 'warn',
'no-debugger': 'warn',
'prefer-const': 'off',
'no-var': 'error',
'no-undef': 'off', // TypeScript handles this
'no-case-declarations': 'warn',
'no-useless-catch': 'warn',
// TypeScript-specific rules
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-inferrable-types': 'warn',
'@typescript-eslint/prefer-as-const': 'warn',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-empty-function': 'warn',
'@typescript-eslint/no-empty-interface': 'warn',
'@typescript-eslint/no-namespace': 'warn',
'@typescript-eslint/prefer-namespace-keyword': 'warn',
'@typescript-eslint/adjacent-overload-signatures': 'warn',
'@typescript-eslint/array-type': 'warn',
'@typescript-eslint/consistent-type-assertions': 'warn',
'@typescript-eslint/consistent-type-definitions': 'warn',
'@typescript-eslint/no-misused-new': 'warn',
'@typescript-eslint/no-require-imports': 'warn',
'@typescript-eslint/prefer-for-of': 'warn',
'@typescript-eslint/prefer-function-type': 'warn'
}
},
{
files: ['**/*.js'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
console: 'readonly',
process: 'readonly',
Buffer: 'readonly',
__dirname: 'readonly',
__filename: 'readonly',
module: 'readonly',
require: 'readonly',
exports: 'readonly',
global: 'readonly'
}
},
rules: {
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'no-console': 'warn',
'no-debugger': 'warn',
'prefer-const': 'error',
'no-var': 'error'
}
},
{
files: ['test/**/*.js'],
languageOptions: {
globals: {
describe: 'readonly',
it: 'readonly',
before: 'readonly',
after: 'readonly',
beforeEach: 'readonly',
afterEach: 'readonly',
expect: 'readonly',
assert: 'readonly',
suite: 'readonly',
test: 'readonly',
setup: 'readonly',
teardown: 'readonly'
}
},
rules: {
'no-console': 'off',
'@typescript-eslint/no-explicit-any': 'off'
}
}
];