Skip to content

Commit bd9c00e

Browse files
committed
Improve error message and add instructions.
1 parent cf0bce5 commit bd9c00e

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

‎tools/stylelint/lint-css.js‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,30 @@ async function main() {
1414
console.log( report );
1515
}
1616

17-
// Stylelint leaves `errored` set on results whose problems were all suppressed, so count what remains.
18-
const hasErrors = results.some( ( result ) =>
19-
result.parseErrors.length > 0 ||
20-
result.invalidOptionWarnings.length > 0 ||
17+
// Don't rely on `errored`: Stylelint leaves it set on results whose problems were all suppressed. Count what remains.
18+
const hasViolations = results.some( ( result ) =>
2119
result.warnings.some( ( warning ) => warning.severity === 'error' )
2220
);
2321

22+
const hasErrors = hasViolations || results.some( ( result ) =>
23+
result.parseErrors.length > 0 ||
24+
result.invalidOptionWarnings.length > 0
25+
);
26+
27+
if ( hasViolations ) {
28+
console.log(
29+
[
30+
'Stylelint found new CSS Coding Standards violations.',
31+
'',
32+
'Existing violations are allowed up to the count recorded for each file and rule in stylelint-suppressions.json.',
33+
'Note that if a file has new violations, Stylelint lists all of them, including the existing ones.',
34+
'',
35+
'Fix the problems you introduced. Do not increase the counts in stylelint-suppressions.json.',
36+
'Once you have fixed the new violations, update the suppressions file by using: npm run lint:css:update-suppressions',
37+
].join( '\n' )
38+
);
39+
}
40+
2441
process.exitCode = hasErrors ? 1 : 0;
2542
}
2643

0 commit comments

Comments
 (0)