@kachkaev/eslint-config-base
v2.0.0
Published
Readme
@kachkaev → eslint config (base)
A collection of carefully picked ESLint rules and plugins for TypeScript projects.
Compatible with ESLint v10+ (Flat config). Requires TypeScript to be present as a dependency.
See also @kachkaev/eslint-config-next.
Principles
This configuration uses warnings for rules that are related to code style (the ones that are not likely to prevent runtime errors), and errors otherwise.
This looks less noisy than using errors for all rules.
Both severity levels fail CI when eslint is called with --max-warnings=0.
It is assumed that all files are written in TypeScript and use ESM (not CommonJS).
Adding to project
Ensure your
package.jsoncontains"type": "module".Ensure your project has a
tsconfig.jsonfile.Install these packages as dev dependencies:
## If you use NPM npm install -D eslint @kachkaev/eslint-config-base ## If you use PNPM pnpm add -D eslint @kachkaev/eslint-config-base ## If you use Yarn yarn add -D eslint @kachkaev/eslint-config-baseIf you don't keep your Node.js runtime up-to-date, you might need to install
jitito enable*.tsfiles -- see ESLint docs for details.If you use TypeScript 7 (the native compiler), keep the TypeScript 6 JavaScript API installed under the
typescriptname, because typescript-eslint depends on it. The aliases recommended in the TypeScript 7 announcement maketscrun the native compiler while ESLint keeps working:{ "devDependencies": { "@typescript/native": "npm:typescript@^7.0.2", "typescript": "npm:@typescript/typescript6@^6.0.2" } }Create
eslint.config.tswith the following contents:import { generateBaseConfigs } from "@kachkaev/eslint-config-base"; export default generateBaseConfigs();To add project-specific configs, wrap the result in
defineConfigfrom ESLint. The generated configs are scoped to*.tsand*.tsxfiles, so configs for other languages can be added alongside:import { generateBaseConfigs } from "@kachkaev/eslint-config-base"; import { defineConfig } from "eslint/config"; export default defineConfig([ generateBaseConfigs(), { rules: { "no-console": "off", }, }, ]);If you work in a monorepo, you may need to specify
tsconfigRootDirfor some rules to work correctly:- generateBaseConfigs(); + generateBaseConfigs({ tsconfigRootDir: import.meta.dirname });Add
package.jsonscripts:{ "...": "...", "scripts": { "...": "...", "fix:eslint": "eslint --max-warnings=0 --fix", "...": "...", "lint:eslint": "eslint --max-warnings=0", "...": "..." } }
You can now run [npm/pnpm/yarn] run lint:eslint to lint your code and [npm/pnpm/yarn] run fix:eslint to fix linting errors.
