eslint.config.js•2.64 kB
import js from '@eslint/js';
import tsParser from '@typescript-eslint/parser';
import tsPlugin from '@typescript-eslint/eslint-plugin';
import unusedImports from 'eslint-plugin-unused-imports';
import importPlugin from 'eslint-plugin-import';
import nodePlugin from 'eslint-plugin-node';
export default [
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module',
},
globals: {
console: 'readonly',
process: 'readonly',
Buffer: 'readonly',
__dirname: 'readonly',
__filename: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
setInterval: 'readonly',
clearInterval: 'readonly',
fetch: 'readonly',
RequestInit: 'readonly',
AbortController: 'readonly',
TextDecoder: 'readonly',
TextEncoder: 'readonly',
NodeJS: 'readonly',
global: 'readonly',
},
},
plugins: {
'@typescript-eslint': tsPlugin,
'unused-imports': unusedImports,
import: importPlugin,
node: nodePlugin,
},
rules: {
...js.configs.recommended.rules,
...tsPlugin.configs.recommended.rules,
// Unused imports
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': [
'warn',
{ vars: 'all', varsIgnorePattern: '^_', args: 'after-used', argsIgnorePattern: '^_' },
],
// Import order
'import/order': [
'error',
{
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
],
'newlines-between': 'always',
},
],
// TypeScript specific
'@typescript-eslint/no-unused-vars': 'off', // Handled by unused-imports
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
},
},
{
files: ['**/*.test.ts', '**/*.test.tsx'],
languageOptions: {
globals: {
vi: 'readonly',
describe: 'readonly',
it: 'readonly',
test: 'readonly',
expect: 'readonly',
beforeEach: 'readonly',
afterEach: 'readonly',
beforeAll: 'readonly',
afterAll: 'readonly',
},
},
rules: {
'@typescript-eslint/no-explicit-any': 'off',
},
},
{
ignores: ['dist/**', 'node_modules/**', 'coverage/**'],
},
];