Skip to content

Commit 2fe49f0

Browse files
committed
feat: name --max-warnings to --max-errors, add --max-warnings
1 parent 589e5e9 commit 2fe49f0

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

packages/@vue/cli-plugin-eslint/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ module.exports = (api, { lintOnSave }) => {
2525
options: {
2626
'--format [formatter]': 'specify formatter (default: codeframe)',
2727
'--no-fix': 'do not fix errors',
28-
'--max-warnings [limit]': 'specify number of warnings to make build failed'
28+
'--max-errors [limit]': 'specify number of errors to make build failed (default: 0)',
29+
'--max-warnings [limit]': 'specify number of warnings to make build failed (default: Infinity)'
2930
},
3031
details: 'For more options, see https://eslint.org/docs/user-guide/command-line-interface#options'
3132
}, args => {

packages/@vue/cli-plugin-eslint/lint.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ module.exports = function lint (args = {}, api) {
2020
CLIEngine.outputFixes(report)
2121
}
2222

23-
if (report.errorCount <= (argsConfig.maxWarnings || 0)) {
23+
const isErrorsExceed = report.errorCount > (argsConfig.maxErrors || 0)
24+
const isWarningsExceed = report.warningCount > (
25+
'maxWarnings' in argsConfig ? argsConfig.maxWarnings : Infinity)
26+
if (!isErrorsExceed && !isWarningsExceed) {
2427
if (!args.silent) {
2528
const hasFixed = report.results.some(f => f.output)
2629
if (hasFixed) {
@@ -41,6 +44,12 @@ module.exports = function lint (args = {}, api) {
4144
}
4245
} else {
4346
console.log(formatter(report.results))
47+
if (isErrorsExceed && typeof argsConfig.maxErrors === 'number') {
48+
log(`Eslint found too many errors (maximum: ${argsConfig.maxErrors}).`)
49+
}
50+
if (isWarningsExceed) {
51+
log(`Eslint found too many warnings (maximum: ${argsConfig.maxWarnings}).`)
52+
}
4453
process.exit(1)
4554
}
4655
}

0 commit comments

Comments
 (0)