57 lines
2.5 KiB
JavaScript
57 lines
2.5 KiB
JavaScript
// @ts-check
|
|
import eslint from '@eslint/js';
|
|
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
import globals from 'globals';
|
|
import tseslint from 'typescript-eslint';
|
|
|
|
export default tseslint.config(
|
|
{
|
|
ignores: ['eslint.config.mjs'],
|
|
},
|
|
eslint.configs.recommended,
|
|
...tseslint.configs.recommendedTypeChecked,
|
|
eslintPluginPrettierRecommended,
|
|
{
|
|
languageOptions: {
|
|
globals: {
|
|
...globals.node,
|
|
...globals.jest,
|
|
},
|
|
sourceType: 'commonjs',
|
|
parserOptions: {
|
|
projectService: true,
|
|
tsconfigRootDir: import.meta.dirname,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
rules: {
|
|
'@typescript-eslint/no-explicit-any': 'off',
|
|
'@typescript-eslint/no-floating-promises': 'error', // asegurar manejo de promesas
|
|
'@typescript-eslint/no-unsafe-argument': 'warn',
|
|
'@typescript-eslint/prefer-nullish-coalescing': 'warn', // usar ?? en lugar de ||
|
|
'@typescript-eslint/prefer-optional-chain': 'warn', // usar ?. en lugar de && encadenados
|
|
'@typescript-eslint/no-unnecessary-condition': 'warn', // condiciones que siempre son true/false
|
|
'@typescript-eslint/switch-exhaustiveness-check': 'error', // switch sobre union types debe cubrir todos los casos
|
|
'prettier/prettier': ['error', { endOfLine: 'auto' }],
|
|
'@typescript-eslint/await-thenable': 'error', // no hacer await de algo que no es Promise
|
|
'@typescript-eslint/no-misused-promises': 'error', // pasar promises donde no corresponde
|
|
'@typescript-eslint/explicit-function-return-type': ['off'],
|
|
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }], // ignorar _variables
|
|
'@typescript-eslint/consistent-type-imports': 'error', // import type {} cuando corresponde
|
|
'no-console': 'warn', // evitar console.log olvidados
|
|
|
|
// NestJS específico
|
|
'@typescript-eslint/no-extraneous-class': 'off', // NestJS usa clases vacías (módulos)
|
|
'@typescript-eslint/no-unsafe-member-access': 'off', // decoradores de NestJS lo necesitan
|
|
'@typescript-eslint/no-unsafe-call': 'off', // ídem
|
|
|
|
'@typescript-eslint/naming-convention': ['warn',
|
|
{ selector: 'interface', format: ['PascalCase'] },
|
|
{ selector: 'typeAlias', format: ['PascalCase'] },
|
|
{ selector: 'enum', format: ['PascalCase'] },
|
|
],
|
|
},
|
|
},
|
|
);
|