Linter
Линтер
A tool that checks source code without running the program. It flags likely mistakes and violations of project rules, such as variables that are declared but never used.
Also known as: ESLint, статический анализ
What a linter catches
A linter answers a practical question: does this code violate any of the rules the project checks automatically? Depending on the rule set, it might flag a duplicate case label, an unused variable, or an import from a module the team has agreed not to use. A finding isn't necessarily a bug. Some rules catch suspicious code, while others enforce conventions that would otherwise have to be checked in review.
Linting is a form of static analysis: the tool inspects the code without running the application. Static analysis is the broader category and also includes checks such as type checking. ESLint is one example of a linter, not another name for linting. It checks JavaScript and can be configured to work with TypeScript.
How rules work
Many linters parse a file into an abstract syntax tree (AST), which represents constructs such as declarations, function calls, and conditionals. A rule can inspect that structure instead of guessing from the raw text. A rule that looks for unused variables also needs to know which declaration each reference belongs to, since two variables in different scopes can have the same name. Some rules can use type information when the linter is configured to obtain it.
The project's configuration controls which rules run and how findings are reported. A typical diagnostic gives a file, a line number, and a rule name. Some rules offer an automatic fix; others can point out a problem but can't tell what the author intended.
Example: a useful warning, not a diagnosis
function label(name) {
const cleaned = name.trim();
return name;
}
With no-unused-vars enabled, ESLint flags cleaned because nothing reads it. The function is valid JavaScript, but it returns the original string. If the requirement is to remove surrounding whitespace, the right change is to return cleaned, not to delete the unused variable. A test with a name containing extra spaces can verify the intended behavior.
Where linting fits in the workflow
An editor integration gives feedback as you work. A CI job runs a shared check on pull requests even if a contributor hasn't installed that integration. Teams typically keep the rules in the repository so everyone can run the same checks locally. A finding configured as an error can fail the CI job, and a required check can then block the merge.
What interviewers may ask
Be ready to explain why a project might use ESLint, Prettier, a type checker, and tests together. Prettier handles layout choices such as line breaks; ESLint reports violations of the rules the team enables. Their responsibilities can overlap, so avoid enabling formatting rules that fight the formatter. A type checker can reject a call that passes a string where a number is expected, while a test runs the code and checks its behavior for a specific case. Passing lint checks means none of the enabled rules reported a blocking issue; it doesn't prove the code meets the requirements.