Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
[next/lint] `--max-warnings` option does not work | GoodFirstPicks

[next/lint] `--max-warnings` option does not work

vercel/next.js 10 comments 1mo ago
View on GitHub
lowopenScope: clearSkill match: yesTest focusedNext.jsTypeScriptReact

Why this is a good first issue

The --max-warnings flag in next lint is not functioning as expected.

AI Summary

The issue reports that the --max-warnings flag in next lint does not work, causing problems in pre-commit hooks. The bug is reproducible and has clear steps to verify. The fix likely involves correcting the lint command's handling of the max-warnings option.

Issue Description

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: linux
      Arch: x64
      Version: #1 SMP Fri Jan 27 02:56:13 UTC 2023
    Binaries:
      Node: 18.16.0
      npm: 9.5.1
      Yarn: N/A
      pnpm: N/A
    Relevant packages:
      next: 13.4.4
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0
      typescript: N/A

Which area(s) of Next.js are affected? (leave empty if unsure)

ESLint (eslint-config-next)

Link to the code that reproduces this issue or a replay of the bug

To Reproduce

  1. Create a new project using npx create-next-app@latest, setting it to "YES" for the Eslint and Typescript settings.

  2. Add the following rule to the eslintrc.json

{
    ...
    "rules": {
        "react/jsx-props-no-spreading": "error"
    }
}

This should cause an error in the _app.tsx file.

  1. Modify the lint script to

"lint": "next lint --max-warnings 0"

  1. Run the command npm run lint

  2. It will not give an error or end with an exit code 0, it will only report errors.

Describe the Bug

Using the npm run lint command that runs next lint --max-warnings 0` has no effect on the console output.

This is a problem when wanting to use it with Husky and Lint-staged, since if there is a pre-commit hook it is necessary to stop the commit if there are Eslint errors, but this does not work, since it does not end with a code status 0.

const path = require('path')

const buildEslintCommand = (filenames) =>
  `next lint --max-warnings 0 --fix --file ${filenames
    .map((f) => path.relative(process.cwd(), f))
    .join(' --file ')}`

module.exports = {
  '**/*.{js,jsx,ts,tsx}': [buildEslintCommand, 'npm run format:fix'],
  '**/*.{md,mdx,mjs,yml,yaml,css,json}': ['npm run format:fix'],
}

This has already been r

GitHub Labels

bug

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!

Risk Flags

  • eslint integration
Loading labels...

Details

Points10 pts
Difficultylow
Scopeclear
Skill Matchyes
Test Focusedyes