# Linting

URL: https://softwaredictionary.org/terms/linting
Category: Testing & Quality
Last updated: 2026-09-30

In short: Linting is the automated analysis of source code, without running it, to flag likely bugs, style problems, and suspicious patterns before the code ships.

## What is linting?

Linting means running a tool called a linter over your source code to find problems without executing the program. A linter reports issues such as unused variables, unreachable code, a missing `await`, or comparisons that are almost always mistakes. The name comes from `lint`, a Unix tool from 1978 that checked C code for suspicious constructs, named after the bits of fluff that collect on clothes.

A linter parses the code into a structured representation and checks it against a set of rules. Each rule can be turned on or off and set to warn or fail, usually in a configuration file committed to the repository. Many rules can fix problems automatically, and linters typically run in the editor as you type, in pre-commit hooks, and in the CI/CD pipeline.

Linting is like a spelling and grammar checker for code: it won't tell you whether your argument is right, but it catches many mechanical mistakes. Linters exist for nearly every language, and teams use them to catch bugs early and keep a consistent style that makes code review faster.

Linting is often confused with formatting and with testing. A formatter only rewrites layout, such as indentation and line breaks, while a linter also looks for questionable logic. And unlike tests, a linter never runs your code, so it can't prove that the program produces the right results.

## Key takeaways

- A linter analyzes code without running it.
- It flags likely bugs, risky patterns, and style inconsistencies.
- Rules are configurable, and many issues can be fixed automatically.
- Linters run in editors, pre-commit hooks, and CI/CD pipelines.
- Linting complements tests; it doesn't replace them.

## Example: Problems a linter would flag

```javascript
function getTotal(items) {
  const discount = 0.1; // warning: 'discount' is assigned but never used
  let total = 0;

  for (const item of items) {
    if (item.price = 0) continue; // error: assignment inside a condition
    total += item.price;
  }

  return total;
}
```

## Frequently asked questions

**What is the difference between a linter and a formatter?**

A formatter only changes how code looks, such as spacing, indentation, and line length. A linter looks for likely bugs and bad practices, like unused variables or accidental assignments, although some linters can also enforce style.

**Is linting the same as static analysis?**

Linting is a lightweight form of static analysis, which means examining code without running it. Broader static analysis tools can go further, for example by tracking data across files to find security vulnerabilities.

---

Software Dictionary: https://softwaredictionary.org/ · https://softwaredictionary.org/llms.txt
