Nodea — logo

Linting

Linting is the process of automatically analyzing source code for potential bugs, risky constructs and deviations from agreed style rules — before the code is ever run. The tool that performs this analysis is called a linter, a name that traces back to the Unix lint program for the C language in the 1970s.

How linting works

A linter is a kind of static analyzer: it reads code without executing it and checks it against a set of rules. It catches problems a compiler or interpreter might overlook — unused variables, possibly uninitialized values, comparisons that could yield an unexpected result, missing statements or unsafe patterns. Beyond finding bugs, a linter enforces a consistent style across a team: naming conventions, indentation, import ordering. Rules are configured in a project file so that every developer works to the same agreements. It is worth distinguishing linting from debugging — a linter acts preventively and statically, while debugging examines a running program.

Practical application

Every popular ecosystem has its linters: ESLint for JavaScript and TypeScript, PHP_CodeSniffer and PHPStan for PHP, RuboCop for Ruby, Pylint and flake8 for Python. In mature projects linting hooks into several places: live hints in the editor, pre-commit hooks that run before changes are committed to version control, and the CI/CD pipeline, where a failed lint blocks deployment.

As a result, style issues and common mistakes are caught automatically and most cheaply — as the code is being written, rather than during testing or in production. Linting also eases refactoring and code review, since reviewers can focus on logic instead of formatting.

Powiązane pojęcia

Najczęstsze pytania

How is linting different from code formatting?

A linter analyzes code for errors and risky patterns and reports problems, whereas a formatter (such as Prettier) automatically normalizes appearance: indentation, quotes, line length. In practice both are used together — the linter guards quality, the formatter guards a consistent style.