eslint.config.js
Rama main · réplica de lectura del repositorio original.
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
import { defineConfig, globalIgnores } from 'eslint/config'
export default defineConfig([
globalIgnores(['dist', 'build', 'html', 'coverage', 'aStableBuild']),
// ── CommonJS config files (Node.js) ──
{
files: ['postcss.config.js', 'tailwind.config.js'],
extends: [js.configs.recommended],
languageOptions: {
ecmaVersion: 2020,
globals: globals.node,
sourceType: 'commonjs',
},
},
// ── Node.js scripts (ESM with __dirname via import.meta) ──
{
files: ['scripts/**/*.js'],
extends: [js.configs.recommended],
languageOptions: {
ecmaVersion: 2022,
globals: globals.node,
sourceType: 'module',
},
rules: {
'no-console': 'off',
},
},
// ── Test files ──
{
files: ['src/__tests__/**/*.{js,jsx}', 'src/i18n/test-*.js'],
extends: [js.configs.recommended],
languageOptions: {
ecmaVersion: 2020,
globals: { ...globals.browser, ...globals.node },
parserOptions: {
ecmaVersion: 'latest',
ecmaFeatures: { jsx: true },
sourceType: 'module',
},
},
rules: {
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]', argsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }],
'no-console': 'off',
},
},
// ── Main source code ──
{
files: ['src/**/*.{js,jsx}'],
ignores: ['src/__tests__/**', 'src/i18n/test-*.js'],
extends: [
js.configs.recommended,
reactHooks.configs['recommended-latest'],
reactRefresh.configs.vite,
],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parserOptions: {
ecmaVersion: 'latest',
ecmaFeatures: { jsx: true },
sourceType: 'module',
},
},
rules: {
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z]', argsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }],
'no-alert': 'error',
'no-debugger': 'error',
'eqeqeq': ['warn', 'smart'],
'no-console': ['warn', { allow: ['warn', 'error'] }],
'react-refresh/only-export-components': 'off',
},
},
// ── TypeScript source code ──
{
files: ['src/**/*.{ts,tsx}', 'scripts/**/*.ts'],
extends: [
js.configs.recommended,
...tseslint.configs.recommended,
reactHooks.configs['recommended-latest'],
],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: { ...globals.browser, ...globals.node },
parserOptions: {
ecmaFeatures: { jsx: true },
},
},
rules: {
// Permissive baseline during the gradual migration. Tightened in Phase 6.
'no-unused-vars': 'off', // handled by @typescript-eslint version
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }],
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-empty-object-type': 'off',
'no-alert': 'error',
'no-debugger': 'error',
'eqeqeq': ['warn', 'smart'],
'no-console': ['warn', { allow: ['warn', 'error'] }],
},
},
// ── Server (Express, deployed as Vercel serverless functions) ──
{
files: ['server/**/*.ts', 'api/**/*.ts'],
extends: [
js.configs.recommended,
...tseslint.configs.recommended,
],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: globals.node,
},
rules: {
'no-unused-vars': 'off', // handled by @typescript-eslint version
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }],
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-empty-object-type': 'off',
'eqeqeq': ['warn', 'smart'],
'no-console': 'off', // console.* is the actual logging mechanism (Vercel function logs)
},
},
])