Skip to content

Commit

Permalink
chore: Add better lint output
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Holzer committed Sep 17, 2020
1 parent ca55a52 commit 83ec1a2
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tools/bazel_rules/stylelint/run-stylelint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import { lint, LinterResult } from 'stylelint';
import { junitFormatter, createXML } from './junit-formatter';
import { writeFileSync } from 'fs';
import { resolve } from 'path';
import { resolve, relative } from 'path';
import { options } from 'yargs';

const { XML_OUTPUT_FILE } = process.env;
Expand Down Expand Up @@ -51,8 +51,20 @@ async function main(): Promise<void> {

writeFileSync(XML_OUTPUT_FILE as string, lintingOutcome.output);

const lintResult = lintingOutcome.results.map((suite) => {
const file = relative(process.cwd(), suite.source);
const warnings = suite.warnings.map((c) => `L${c.line}: ${c.text}`);
const icon = suite.errored ? '\u2705' : '\u274C';

return `
${icon} ${file} ${warnings.length ? '\n\n' + warnings.join('\n') : ''}`;
});

if (lintingOutcome.errored) {
throw new Error('Lint errors found in the listed files.');
throw new Error(`Lint errors found in the listed files:
${lintResult}
`);
}
}

Expand Down

0 comments on commit 83ec1a2

Please sign in to comment.