Skip to content

Commit

Permalink
Add more warning about --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ybiquitous committed Jun 29, 2022
1 parent dbbb211 commit b2c92ef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/formatters/__tests__/verboseFormatter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ describe('verboseFormatter', () => {
file.css
1 error found
no-foo: 1 (maybe fixable)`);
no-foo: 1 (maybe fixable)
You may fix some problems with the "--fix" option.`);
});
});
9 changes: 9 additions & 0 deletions lib/formatters/verboseFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ module.exports = function verboseFormatter(results, returnValue) {
output += '\n0 problems found\n';
} else {
const warningsBySeverity = groupBy(warnings, (w) => w.severity);
let fixableProblemsFound = false;

/**
* @param {Severity} severity
Expand All @@ -75,11 +76,19 @@ module.exports = function verboseFormatter(results, returnValue) {
const fixable = meta && meta.fixable ? ' (maybe fixable)' : '';

output += dim(` ${ruleLink(rule, meta)}: ${list.length}${fixable}\n`);

if (!fixableProblemsFound && meta && meta.fixable) {
fixableProblemsFound = true;
}
}
};

printProblems('error');
printProblems('warning');

if (fixableProblemsFound) {
output += yellow('\nYou may fix some problems with the "--fix" option.\n');
}
}

return `${output}\n`;
Expand Down

0 comments on commit b2c92ef

Please sign in to comment.