@drimo/eslint-config
v1.0.0
Published
Configuración ESLint compartida para todos los proyectos frontend de Drimo
Maintainers
Readme
@drimo/eslint-config
Configuración ESLint oficial para todos los proyectos frontend de Drimo. Requiere ESLint 9 con flat config.
Incluye reglas para TypeScript, React, Next.js, React Query y dos reglas custom que detectan anti-patrones recurrentes en la organización.
Instalación
yarn add -D @drimo/eslint-config \
eslint \
@typescript-eslint/eslint-plugin \
@typescript-eslint/parser \
eslint-plugin-react \
eslint-plugin-react-hooks
# Solo si el proyecto usa Next.js:
yarn add -D @next/eslint-plugin-nextUso
Proyecto Next.js + React Query (stack completo Drimo)
// eslint.config.js
import { base, nextjs, reactQuery } from '@drimo/eslint-config'
export default [
...base,
...nextjs,
...reactQuery,
{
ignores: ['node_modules/', '.next/', 'dist/', 'build/', 'public/'],
},
]Crear también src/libs/queryClient.ts con la factory estándar:
import { QueryClient } from 'react-query'
export function createQueryClient() {
return new QueryClient({
defaultOptions: {
queries: {
staleTime: 5 * 60 * 1000,
cacheTime: 10 * 60 * 1000,
refetchOnWindowFocus: false,
refetchOnReconnect: 'stale',
retry: 1,
retryDelay: 1000,
},
},
})
}Solo TypeScript / NestJS (sin React)
import { base } from '@drimo/eslint-config'
export default [
...base,
{ ignores: ['node_modules/', 'dist/'] },
]Configs disponibles
| Config | Contenido |
|---|---|
| base | Reglas TypeScript generales: unused-vars, no-explicit-any, prefer-const, no-console, no-empty, max-lines |
| nextjs | React hooks, jsx-key, no-img-element, setTimeout cleanup, new QueryClient() con opciones |
| reactQuery | Plugin custom con reglas no-zero-query-cache y no-limit-hack |
Reglas custom
drimo-react-query/no-zero-query-cache — error
Detecta staleTime: 0 y cacheTime: 0 / gcTime: 0 en QueryClient y en hooks (useQuery, useInfiniteQuery, etc.).
// ❌ Error
const queryClient = new QueryClient({
defaultOptions: { queries: { staleTime: 0 } }
})
// ✅ Correcto
import { createQueryClient } from '@/libs/queryClient'
const queryClient = createQueryClient()drimo-react-query/no-limit-hack — warning
Detecta limit > 200 en argumentos de funciones. Indica paginación fingida.
// ⚠️ Warning
api.getRooms({ page: 1, limit: 1000 })
// ✅ Correcto — paginación real o endpoint /options
api.getRoomOptions()Integración CI/CD
// package.json
{
"scripts": {
"lint": "next lint",
"lint:ci": "next lint --max-warnings 0"
}
}Usar lint en PRs y lint:ci en merge a main.
Documentación completa
Ver RULES.md para la documentación técnica de cada regla con ejemplos reales de código encontrado en producción.
Contribuir
Si identificás un anti-patrón recurrente en más de un proyecto, abrí un issue con el ejemplo real (proyecto + archivo + línea) para evaluar agregarlo al paquete.
Versionado semver: patch para nuevos warn, minor para nuevos error, major para breaking changes en la API de configuración.
