
ESLint configuration with: - TypeScript-first rules with strict type checking - Import/export organization and validation - Node.js environment optimizations - Monorepo-aware path resolution - Security and performance rules - Prettier integration for code formatting - Environment-specific overrides (frontend, api, worker) - Test file specific configurations - Comprehensive rule set for code quality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
204 lines
No EOL
5.6 KiB
JavaScript
204 lines
No EOL
5.6 KiB
JavaScript
module.exports = {
|
|
root: true,
|
|
parser: '@typescript-eslint/parser',
|
|
parserOptions: {
|
|
ecmaVersion: 2022,
|
|
sourceType: 'module',
|
|
project: ['./tsconfig.json', './packages/*/tsconfig.json'],
|
|
tsconfigRootDir: __dirname,
|
|
},
|
|
plugins: [
|
|
'@typescript-eslint',
|
|
'import',
|
|
'node',
|
|
'prettier'
|
|
],
|
|
extends: [
|
|
'eslint:recommended',
|
|
'@typescript-eslint/recommended',
|
|
'@typescript-eslint/recommended-requiring-type-checking',
|
|
'plugin:import/recommended',
|
|
'plugin:import/typescript',
|
|
'plugin:node/recommended',
|
|
'prettier'
|
|
],
|
|
env: {
|
|
node: true,
|
|
es2022: true,
|
|
jest: true
|
|
},
|
|
settings: {
|
|
'import/resolver': {
|
|
typescript: {
|
|
alwaysTryTypes: true,
|
|
project: ['./tsconfig.json', './packages/*/tsconfig.json']
|
|
},
|
|
node: {
|
|
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json']
|
|
}
|
|
},
|
|
'import/parsers': {
|
|
'@typescript-eslint/parser': ['.ts', '.tsx']
|
|
}
|
|
},
|
|
rules: {
|
|
// TypeScript specific rules
|
|
'@typescript-eslint/no-unused-vars': ['error', {
|
|
argsIgnorePattern: '^_',
|
|
varsIgnorePattern: '^_'
|
|
}],
|
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
'@typescript-eslint/no-explicit-any': 'warn',
|
|
'@typescript-eslint/no-non-null-assertion': 'warn',
|
|
'@typescript-eslint/prefer-const': 'error',
|
|
'@typescript-eslint/no-var-requires': 'error',
|
|
'@typescript-eslint/ban-ts-comment': 'warn',
|
|
'@typescript-eslint/no-empty-function': 'warn',
|
|
'@typescript-eslint/no-inferrable-types': 'off',
|
|
'@typescript-eslint/consistent-type-imports': ['error', {
|
|
prefer: 'type-imports',
|
|
disallowTypeAnnotations: false
|
|
}],
|
|
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
|
|
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
|
|
'@typescript-eslint/prefer-nullish-coalescing': 'error',
|
|
'@typescript-eslint/prefer-optional-chain': 'error',
|
|
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
|
|
'@typescript-eslint/no-floating-promises': 'error',
|
|
'@typescript-eslint/await-thenable': 'error',
|
|
'@typescript-eslint/require-await': 'error',
|
|
'@typescript-eslint/no-misused-promises': 'error',
|
|
|
|
// Import/Export rules
|
|
'import/order': ['error', {
|
|
groups: [
|
|
'builtin',
|
|
'external',
|
|
'internal',
|
|
'parent',
|
|
'sibling',
|
|
'index'
|
|
],
|
|
'newlines-between': 'always',
|
|
alphabetize: {
|
|
order: 'asc',
|
|
caseInsensitive: true
|
|
}
|
|
}],
|
|
'import/no-unresolved': 'error',
|
|
'import/no-cycle': 'error',
|
|
'import/no-self-import': 'error',
|
|
'import/no-useless-path-segments': 'error',
|
|
'import/prefer-default-export': 'off',
|
|
'import/no-default-export': 'off',
|
|
'import/no-duplicates': 'error',
|
|
|
|
// Node.js specific rules
|
|
'node/no-missing-import': 'off', // Handled by TypeScript
|
|
'node/no-unsupported-features/es-syntax': 'off', // We use Babel/TypeScript
|
|
'node/no-unpublished-import': 'off',
|
|
'node/no-extraneous-import': 'off', // Handled by import plugin
|
|
'node/prefer-global/process': 'error',
|
|
'node/prefer-global/console': 'error',
|
|
'node/prefer-global/buffer': 'error',
|
|
'node/prefer-global/url': 'error',
|
|
|
|
// General JavaScript/TypeScript rules
|
|
'no-console': 'warn',
|
|
'no-debugger': 'error',
|
|
'no-alert': 'error',
|
|
'no-var': 'error',
|
|
'prefer-const': 'error',
|
|
'prefer-template': 'error',
|
|
'prefer-arrow-callback': 'error',
|
|
'arrow-spacing': 'error',
|
|
'object-shorthand': 'error',
|
|
'prefer-destructuring': ['error', {
|
|
array: false,
|
|
object: true
|
|
}],
|
|
'no-duplicate-imports': 'error',
|
|
'no-useless-constructor': 'error',
|
|
'no-useless-rename': 'error',
|
|
'no-useless-return': 'error',
|
|
'no-unreachable': 'error',
|
|
'no-trailing-spaces': 'error',
|
|
'eol-last': 'error',
|
|
'comma-dangle': ['error', 'always-multiline'],
|
|
'semi': ['error', 'always'],
|
|
'quotes': ['error', 'single', { avoidEscape: true }],
|
|
|
|
// Security rules
|
|
'no-eval': 'error',
|
|
'no-implied-eval': 'error',
|
|
'no-new-func': 'error',
|
|
'no-script-url': 'error',
|
|
|
|
// Performance rules
|
|
'no-async-promise-executor': 'error',
|
|
'no-await-in-loop': 'warn',
|
|
'no-promise-executor-return': 'error',
|
|
|
|
// Prettier integration
|
|
'prettier/prettier': 'error'
|
|
},
|
|
overrides: [
|
|
// Configuration files
|
|
{
|
|
files: [
|
|
'*.config.js',
|
|
'*.config.ts',
|
|
'.eslintrc.js',
|
|
'jest.config.js',
|
|
'vite.config.ts'
|
|
],
|
|
rules: {
|
|
'node/no-unpublished-require': 'off',
|
|
'@typescript-eslint/no-var-requires': 'off'
|
|
}
|
|
},
|
|
// Test files
|
|
{
|
|
files: ['**/*.test.ts', '**/*.spec.ts', '**/__tests__/**/*'],
|
|
env: {
|
|
jest: true
|
|
},
|
|
rules: {
|
|
'@typescript-eslint/no-explicit-any': 'off',
|
|
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
'no-console': 'off'
|
|
}
|
|
},
|
|
// Frontend specific rules
|
|
{
|
|
files: ['packages/frontend/**/*'],
|
|
env: {
|
|
browser: true,
|
|
node: false
|
|
},
|
|
rules: {
|
|
'node/prefer-global/process': 'off'
|
|
}
|
|
},
|
|
// API and Worker specific rules
|
|
{
|
|
files: ['packages/api/**/*', 'packages/worker/**/*'],
|
|
env: {
|
|
node: true,
|
|
browser: false
|
|
},
|
|
rules: {
|
|
'no-console': 'off' // Allow console in server code
|
|
}
|
|
}
|
|
],
|
|
ignorePatterns: [
|
|
'node_modules/',
|
|
'dist/',
|
|
'build/',
|
|
'coverage/',
|
|
'*.min.js',
|
|
'*.bundle.js'
|
|
]
|
|
}; |