ESLint JavaScript linter
Light · Postcard
102 × 152 mm · PDF
Dark · Postcard
102 × 152 mm · PDF
Ink saver · Postcard
102 × 152 mm · PDF
Light · A4 landscape
297 × 210 mm · PDF
Dark · A4 landscape
297 × 210 mm · PDF
Ink saver · A4 landscape
297 × 210 mm · PDF
Light · A3 landscape
420 × 297 mm · PDF
Dark · A3 landscape
420 × 297 mm · PDF
Ink saver · A3 landscape
420 × 297 mm · PDF
Start here
npm init @eslint/config@latest
npx eslint .npx eslint --fix .
npx eslint <file>
npx eslint --quiet .
npx eslint --max-warnings 0 .
npx eslint --cache .
npx eslint --print-config <file>
Concepts
- Files globs from CLI
- Flat config eslint.config.js
- Problems error / warn
- Report -f, exit code
Running
npx eslint .npx eslint <file> <dir>
npx eslint "src/**/*.{js,ts}"
npx eslint --stdin --stdin-filename <path>
npx eslint --ignore-pattern <glob> .
npx eslint --no-warn-ignored <file>
npx eslint --no-error-on-unmatched-pattern
<glob>
npx eslint --concurrency auto .
Fixing
npx eslint --fix .
npx eslint --fix --fix-type suggestion,layout .
npx eslint --cache --fix .
Warnings and exit codes
npx eslint --quiet .
npx eslint --max-warnings 0 .
echo $?npx eslint --rule '<rule>: error' .
npx eslint --report-unused-disable-directives .
Output
npx eslint -f json .
npx eslint -f <name> .
npx eslint -f json -o <file> .
Cache and speed
npx eslint --cache .
npx eslint --cache --cache-strategy content .
Config
npm init @eslint/config@latest
npx eslint -c <file> .
npx eslint --print-config <file>
npx eslint --debug <file>
import js from "@eslint/js";import globals from "globals";export default [ { ignores: ["dist/", "coverage/"] }, js.configs.recommended, { files: ["**/*.js"], languageOptions: { globals: globals.node }, rules: { "no-unused-vars": "warn", eqeqeq: "error" }, },];
import { defineConfig } from "eslint/config";import js from "@eslint/js";export default defineConfig([ { files: ["src/**/*.js"], plugins: { js }, extends: ["js/recommended"] }, { files: ["test/**"], rules: { "no-console": "off" } },]);
{ ignores: ["dist/"] }
{ files: ["**/*.ts"], ... }
Inline comments
// eslint-disable-next-line <rule>
// eslint-disable-line <rule>
/* eslint-disable <rule> */
// eslint-disable-next-line <rule> --
<reason>
Recipes
npx eslint --max-warnings 0 --cache --cache-strategy content .
git diff --name-only --cached --diff-filter=d -- '*.js' \ | xargs npx eslint --max-warnings 0
npx eslint --suppress-all .# fix gradually, then drop stale entriesnpx eslint --prune-suppressions



