ci(lint): exit with error when issues are found (#419)
This commit is contained in:
1 parent
2064cb869e
commit
d520b24b53
2 files changed
+14
-9
No files matched your search
+10
-3
@@ -20,6 +20,8 @@ const stylesheets = walk(join(REPO_ROOT, "styles", subDir), {
|
||||
match: [/\.user.css$/],
|
||||
});
|
||||
|
||||
let failed = false;
|
||||
|
||||
for await (const entry of stylesheets) {
|
||||
const repodir = dirname(entry.path);
|
||||
const repo = basename(repodir);
|
||||
@@ -33,8 +35,9 @@ for await (const entry of stylesheets) {
|
||||
if (!isLess) continue;
|
||||
|
||||
// try to compile the less file, report any errors
|
||||
less.render(content, { lint: true, globalVars }).then().catch(
|
||||
(err) => {
|
||||
less.render(content, { lint: true, globalVars }).catch(
|
||||
(err: Less.RenderError) => {
|
||||
failed = true;
|
||||
log(
|
||||
err.message,
|
||||
{ file, startLine: err.line, endLine: err.line, content },
|
||||
@@ -44,10 +47,14 @@ for await (const entry of stylesheets) {
|
||||
);
|
||||
|
||||
// advanced linting with stylelint
|
||||
await lint(entry, content, flags.fix);
|
||||
await lint(entry, content, flags.fix).catch(() => failed = true);
|
||||
}
|
||||
|
||||
// if any files are missing, cause the workflow to fail
|
||||
if (await checkForMissingFiles() === false) {
|
||||
failed = true;
|
||||
}
|
||||
|
||||
if (failed) {
|
||||
Deno.exit(1);
|
||||
}
|
||||
@@ -10,10 +10,8 @@ import "npm:stylelint-config-recommended";
|
||||
import { REPO_ROOT } from "@/deps.ts";
|
||||
import { log } from "@/lint/logger.ts";
|
||||
|
||||
export const lint = async (entry: WalkEntry, content: string, fix: boolean) => {
|
||||
const file = relative(REPO_ROOT, entry.path);
|
||||
|
||||
await stylelint.lint({ files: entry.path, fix })
|
||||
export const lint = (entry: WalkEntry, content: string, fix: boolean) =>
|
||||
stylelint.lint({ files: entry.path, fix })
|
||||
.then(({ results }) => {
|
||||
results.map((result) => {
|
||||
result.warnings.map((warning) => {
|
||||
@@ -24,7 +22,7 @@ export const lint = async (entry: WalkEntry, content: string, fix: boolean) => {
|
||||
) ?? "unspecified stylelint error";
|
||||
|
||||
log(message, {
|
||||
file,
|
||||
file: relative(REPO_ROOT, entry.path),
|
||||
startLine: warning.line,
|
||||
endLine: warning.endLine,
|
||||
startColumn: warning.column,
|
||||
@@ -32,6 +30,6 @@ export const lint = async (entry: WalkEntry, content: string, fix: boolean) => {
|
||||
content,
|
||||
}, warning.severity);
|
||||
});
|
||||
if (result.warnings.length > 0) throw new Error("stylelint error");
|
||||
});
|
||||
});
|
||||
};
|
||||
Reference in new issue
Block a user