Configure ESLint as a code-quality gate
Quick answer
A linter analyzes source for configured code patterns. ESLint rules can report potential bugs or project conventions, but do not prove application correctness.
Tooling examples
Configuration excerpt: projects/lint-lab/eslint.config.mjs; requires ESLint to interpret rules. Manual integration example — not executed here.
// eslint.config.mjsexport default [{ files: ["**/*.js"], rules: { "no-unused-vars": "error", eqeqeq: "error" } }];Expected observation: Config enables two error-level rules for matching JS files.
Example 2. Context: projects/lint-lab. Run in a fresh prepared fixture copy; see its README. Manual integration example — not executed here.
npm run lint -- --max-warnings 0Expected observation: With lint-lab bad.js present, expected nonzero exit.
How the tooling works
Use an ESLint version compatible with your runtime. Modern flat configuration exports an array of configuration objects, optionally selected by files. The no-unused-vars rule can detect unused bindings, and eqeqeq discourages coercive equality. Rule levels control whether issues are off, warnings or errors. The exit status can gate CI; --max-warnings 0 can fail a job even when only warnings remain. Review suppressions narrowly. The lint-lab contains a configuration and deliberately failing source, but ESLint is not installed here.
Common mistakes
Do not disable a rule globally just to silence one legitimate exception; document the narrow reason.
Practice
Install a reviewed pinned ESLint version in lint-lab, run lint on good.js and bad.js, then repair the unused binding and comparison without changing intended behavior.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Configure ESLint as a code-quality gate — Knowledge Check
Assess tooling contracts, diagnostic reasoning and transfer to a project.
What does an error-level ESLint rule do when violated?
What does --max-warnings 0 enforce?
Why do lint checks not replace tests?
In Configure ESLint as a code-quality gate, what is the expected observation for example 1 in its documented setup? // eslint.config.mjs export default [{ files: ["**/*.js"], rules: { "no-unused-vars": "error", eqeqeq: "error" } }];
In Configure ESLint as a code-quality gate, what is the expected observation for example 2 in its documented setup? npm run lint -- --max-warnings 0