
- Next.js - Home
- Next.js - Overview
- Next.js - Project Setup
- Next.js - Folder Structure
- Next.js - App Router
- Next.js - Page Router
- Next.js Features
- Next.js - Pages
- Next.js - Data Fetching
- Next.js - ISR
- Next.js - Static File Serving
- Next.js - Pre-Rendering
- Next.js - Partial Pre Rendering
- Next.js - Server Side Rendering
- Next.js - Client Side Rendering
- Next.js Routing
- Next.js - Routing
- Next.js - Nested Routing
- Next.js - Dynamic Routing
- Next.js - Parallel Routing
- Next.js - Imperative Routing
- Next.js - Shallow Routing
- Next.js - Intercepting Routes
- Next.js - Redirecting Routes
- Next.js - Navigation and Linking
- Next.js Configuration
- Next.js - TypeScript
- Next.js - Environment Variables
- Next.js - File Conventions
- Next.js - ESLint
- Next.js API & Backend
- Next.js - API Routes
- Next.js - Dynamic API Routes
- Next.js - Route Handlers
- Next.js - API MiddleWares
- Next.js - Response Helpers
- Next.js API Reference
- Next.js - CLI Commands
- Next.js - Functions
- Next.js - Directives
- Next.js - Components
- Next.js - Image Component
- Next.js - Font Component
- Next.js - Head Component
- Next.js - Form Component
- Next.js - Link Component
- Next.js - Script Component
- Next.js Styling & SEO
- Next.js - CSS Support
- Next.js - Global CSS Support
- Next.js - Meta Data
- Next.js Advanced Topics
- Next.js - Error Handling
- Next.js - Server Actions
- Next.js - Fast Refresh
- Next.js - Internationalization
- Next.js - Authentication
- Next.js - Session Management
- Next.js - Authorization
- Next.js - Caching
- Next.js - Data Caching
- Next.js - Router Caching
- Next.js - Full Route Caching
- Next.js - Request Memoization
- Next.js Performance Optimization
- Next.js - Optimizations
- Next.js - Image Optimization
- Next.js - Lazy Loading
- Next.js - Font Optimization
- Next.js - Video Optimization
- Next.js - Script Optimization
- Next.js - Memory Optimization
- Next.js - Using OpenTelemetry
- Next.js - Package Bundling Optimization
- Next.js Testing
- Next.js - Testing
- Next.js - Testing with Jest
- Next.js - Testing with Cypress
- Next.js - Testing with Vitest
- Next.js - Testing with Playwright
- Next.js Debugging & Deployment
- Next.js - Debugging
- Next.js - Deployment
- Next.js Useful Resources
- Next.js - Interview Questions
- Next.js - Quick Guide
- Next.js - Useful Resources
- Next.js - Discussion
Next.js - CLI lint Command
In Next.js CLI, the `lint` command is used to run ESLint on your application code. This command helps you catch potential issues in Next.js code by analyzing all the directories or selected specific directories. In this chapter, we will explain how to use the `lint` command and its available options to simplify the linting process.
Next.js Lint Command Syntax
Following is the syntax of the lint command in Next.js CLI.
npx next lint [options]
For example, npx next lint --ext .ts,.tsx, specifies the file extensions to lint as `.ts` and `.tsx`.
Options of Lint Command
Below is a list of options available for the `lint` command.
Options | Explanation |
---|---|
[directory] | Specifies a base directory to lint the application. If not provided, the current directory is used. |
-d, --dir | Include directory or directories to run ESLint. |
--file | Include file or files to run ESLint. |
--ext | Specify JavaScript file extensions to lint. |
-c, --config | Uses a configuration file, overriding all other configuration options. |
--strict | Creates a .eslintrc.json file using the Next.js strict configuration. |
--rulesdir | Uses additional rules from this directory or directories. |
--fix | Automatically fix linting issues. |
--fix-type | Specify the types of fixes to apply (e.g., problem, suggestion, layout). |
--ignore-path | Specify a file to ignore. |
--no-ignore | Disables the --ignore-path option. |
--quiet | Reports errors only, suppressing warnings. |
--max-warnings | Specify the number of warnings before triggering a non-zero exit code. Default: -1. |
-o, --output-file | Specify a file to write the linting report to. |
-f, --format | Uses a specific output format for linting results. |
--no-inline-config | Prevents comments from changing the config or rules. |
--report-unused-disable-directives-severity | Specify severity level for unused eslint-disable directives. Choices: "error", "off", "warn". |
--no-cache | Disables caching of linting results. |
--cache-location | Specify a location for cache. |
--cache-strategy | Specify a strategy to use for detecting changed files in the cache. Default: "metadata". |
--error-on-unmatched-pattern | Reports errors when any file patterns are unmatched. |
-h, --help | Displays the help message for the lint command. |
Lint Command with Ignore Path
In Next.js, we can use the `--ignore-path` option to specify a file that should be ignored during linting.
npx next lint --ignore-path .eslintignore
After running the above command in your terminal, the files specified in the `.eslintignore` file will be ignored during linting.
Output
In the output, you can see that warnings and errors are reported.

Lint Command with Quiet Option
In Next.js, we can use the `--quiet` option to hide warnings and report only errors.
npx next lint --quiet
Output
In the output, you can see that no errors are found, and all warnings are ignored.
