The --max-warnings flag in next lint is not functioning as expected.
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.
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
ESLint (eslint-config-next)
Create a new project using npx create-next-app@latest, setting it to "YES" for the Eslint and Typescript settings.
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.
lint script to"lint": "next lint --max-warnings 0"
Run the command npm run lint
It will not give an error or end with an exit code 0, it will only report errors.
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
Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!