Configuraciones finales de eslint, formateo y scripts de package.json

This commit is contained in:
2025-12-19 15:53:51 -06:00
parent ad197c9aad
commit b38fe2d8b4
7 changed files with 231 additions and 94 deletions

View File

@@ -1,20 +1,52 @@
// @ts-check
// @ts-check
import { tanstackConfig } from '@tanstack/eslint-config'
import eslintConfigPrettier from 'eslint-config-prettier'
import importPlugin from 'eslint-plugin-import'
import jsxA11y from 'eslint-plugin-jsx-a11y'
import unusedImports from 'eslint-plugin-unused-imports'
export default [
// 1. IGNORAR ARCHIVOS (Global ignores)
{
ignores: [
'**/node_modules/**',
'**/dist/**',
'**/.vite/**',
'**/pnpm-lock.yaml',
'**/package-lock.json',
'**/bun.lock', // Agregado bun.lock
'src/routeTree.gen.ts',
],
},
// 2. CONFIGURACIÓN BASE
...tanstackConfig,
// Local overrides to avoid rule overlap and Prettier conflicts
// 3. TUS REGLAS Y CONFIGURACIÓN "PRO"
{
plugins: {
import: importPlugin, // <--- Registramos el plugin
'jsx-a11y': jsxA11y,
'unused-imports': unusedImports,
},
// Configuración robusta del Resolver (La versión de Copilot)
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true, // Busca definiciones @types aunque no importes el archivo
project: ['./tsconfig.json'],
},
node: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
},
},
},
rules: {
// Let import/order handle ordering; disable native sort-imports to prevent conflicts
'sort-imports': 'off',
// Ensure consistent grouping and alphabetical ordering
// --- REGLAS DE ACCESIBILIDAD (A11Y) ---
// Activamos las recomendadas manualmente
...jsxA11y.configs.recommended.rules,
// --- ORDEN DE IMPORTS ---
'sort-imports': 'off', // Apagamos el nativo
'import/order': [
'error',
{
@@ -28,13 +60,65 @@ export default [
'object',
'type',
],
// No blank lines inside or between import groups to avoid multi-save fixes
'newlines-between': 'never',
'newlines-between': 'always',
alphabetize: { order: 'asc', caseInsensitive: true },
},
],
// --- LIMPIEZA DE IMPORTS NO USADOS ---
'no-unused-vars': 'off', // Apagamos la regla base de ESLint para que no choque
'unused-imports/no-unused-imports': 'error', // Si no se usa, marca error (y --fix lo borra)
'unused-imports/no-unused-vars': [
'warn',
{
vars: 'all',
varsIgnorePattern: '^_', // Ignora variables que empiecen con _
args: 'after-used',
argsIgnorePattern: '^_',
},
],
},
},
// Turn off any ESLint rules that might conflict with Prettier
// 4. PARCHE PARA ARCHIVOS DE CONFIGURACIÓN
{
files: [
'eslint.config.js',
'vite.config.ts',
'prettier.config.js',
'*.config.js',
],
languageOptions: {
parserOptions: {
project: null,
},
},
rules: {
// --- LA LISTA NUCLEAR (Apagamos todo lo que pida tipos) ---
'@typescript-eslint/await-thenable': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/prefer-optional-chain': 'off',
'@typescript-eslint/prefer-promise-reject-errors': 'off',
'@typescript-eslint/prefer-reduce-type-parameter': 'off',
'@typescript-eslint/prefer-string-starts-ends-with': 'off',
'@typescript-eslint/require-await': 'off', // <--- La culpable de este último error
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/strict-boolean-expressions': 'off',
'@typescript-eslint/unbound-method': 'off',
},
},
// 5. PRETTIER AL FINAL
eslintConfigPrettier,
]