La libreria
@nodecfdi/eslint-config
exporta la configuración base para eslint usada en los proyectos de NodeCfdi.
🇺🇸 The documentation of this project is in spanish as this is the natural language for intended audience.
🇲🇽 La documentación del proyecto está en español porque ese es el lenguaje principal de los usuarios.
npm i -D eslint @nodecfdi/eslint-config
yarn add -D eslint @nodecfdi/eslint-config
pnpm add -D eslint @nodecfdi/eslint-config
Opcional puedes instalar eslint-define-config
Para habilitar está configuración crea un archivo eslint.config.js
en el root del proyecto y copia y pega el siguiente contenido:
// @ts-check
import { nodecfdiConfig } from '@nodecfdi/eslint-config';
import { defineFlatConfig } from 'eslint-define-config';
export default defineFlatConfig([...nodecfdiConfig()]);
Si deseas ajustar algúna regla o habilitar alguna no incluida, puedes extender de está configuración por ejemplo:
// @ts-check
import { nodecfdiConfig } from '@nodecfdi/eslint-config';
import { defineFlatConfig } from 'eslint-define-config';
// my other imports...
export default defineFlatConfig([
...nodecfdiConfig(),
// my other configurations
]);
type NodecfdiSettings = {
/**
* Vitest support.
*/
vitest?: boolean;
/**
* AdonisJS support.
*/
adonisjs?: boolean;
/**
* Vue3 Support.
*/
vue?: boolean;
/**
* This parameter allows you to override the paths for some Nodecfdi settings.
*/
pathsOverrides?: {
/**
* With this setting, if you have multiple tsconfig.json files in your project (like tsconfig.json, tsconfig.eslint.json, tsconfig.node.json, etc...) you can specify which config NodeCfdi will pickup. You can also specify a list of paths, see: https://typescript-eslint.io/linting/typed-linting/monorepos/#one-tsconfigjson-per-package-and-an-optional-one-in-the-root.
*/
tsconfigLocation?: string | string[];
/**
* This setting overrides the default Nodecfdi filepaths for test files. It accepts an array of filepaths, dictaced by minimatch syntax. Nodecfdi will apply Vitest rules only on these files.
*/
tests?: string[];
};
/**
* This setting apply some ignore patterns to the whole config.
*/
ignores?: {
/**
* Some commonly ignored folders.
*/
recommended?: boolean;
/**
* With this setting, Nodecfdi will ignore all the files that are currently ignored by git. Chances are that if you are ignoring a file in git, you don't want to lint it, which usually is the case with temporary and autogenerated files.
*/
inheritedFromGitignore?: boolean;
/**
* Include additional ignore files paths or regex paths to ignore on current eslint config
*/
additional?: string[];
};
};
Para que la extensión VSCode ESLint funcione correctamente, necesitaremos habilitar algunas configuraciones. Es recomendable habilitarlos en el nivel del espacio de trabajo, es decir, en la raíz del proyecto en .vscode/settings.json
La compatibilidad con ESLint FlatConfig
actualmente no está habilitada de forma predeterminada. Debe habilitarse manualmente así:
{
"eslint.experimental.useFlatConfig": true
}