Kamran Mushtaq
Back to Development Commands
Development Commands

npm run lint

Added: July 17, 2026

Definition

npm run lint runs a script named lint from your project's package.json. It is usually used to run ESLint, which checks your code for mistakes, bad practices, and coding standard violations.

Example:

{ "scripts": { "lint": "eslint ." } }

Running:

npm run lint

is equivalent to:

eslint .

The Problem That Led to It

Formatting tools like Prettier make code look consistent, but they don't check whether the code is written correctly. Developers still made mistakes like unused variables, forgotten imports, or risky code patterns that could cause bugs.

What Problem It Solves

A linter analyzes your code without running it and warns you about potential issues before you deploy your application.

What Happens If Not Used

You might have:

  • Unused variables.
  • Forgotten imports.
  • Potential bugs.
  • Code that doesn't follow team standards.

Easy Wording

It acts like a grammar checker for your code.

Layman Example

Imagine writing an essay:

  • Prettier = fixes spacing, indentation, and punctuation.
  • ESLint = points out grammar mistakes and awkward sentences.

Technical Example

Suppose you write:

const user = "Kami"; const age = 20;

console.log(user);

Run:

npm run lint

ESLint may report:

'age' is assigned a value but never used.

Notice:

  • ❌ It doesn't automatically fix every issue.
  • ✅ It tells you what should be fixed (some issues can be auto-fixed).