Zero to linting and formatting
Start by installing ESLint:
shell
npm install -D eslint @eslint/js typescript typescript-eslint
Optionally install prettier for formatting:
shell
npm install -D eslint-plugin-prettier eslint-config-prettier
Optionally install jiti for having the config file in TypeScript:
shell
npm install -D jiti
Then configure them:
eslint.config.ts
shell
import prettier from "eslint-plugin-prettier/recommended";
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
export default tseslint.config(
eslint.configs.recommended,
tseslint.configs.strict,
tseslint.configs.stylistic,
prettier,
);
:::warn Unconfigured ESLint will run against all valid source files it can find.
You probably have a build folder or some files to ignore, to ignore files, add them to the flat config like:
ts
export default tseslint.config(
/* ..., */
{
ignores: ["node_modules", "dist"],
}
)
:::