Skip to content

Commit

Permalink
build(lint): chalk -> std/fmt/color
Browse files Browse the repository at this point in the history
  • Loading branch information
nekowinston committed Nov 19, 2023
1 parent 7027b69 commit c3f013a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
5 changes: 2 additions & 3 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
"catppuccin-repo/": "https://raw.githubusercontent.com/catppuccin/catppuccin/91d6b5433730103c504dcf43583b594e418ee7c1/",
"@actions/core": "npm:@actions/[email protected]",
"@octokit/rest": "npm:@octokit/[email protected]",
"usercss-meta": "npm:[email protected]",
"ajv": "npm:[email protected]",
"chalk": "npm:[email protected].0",
"less": "npm:[email protected].0"
"less": "npm:[email protected].0",
"usercss-meta": "npm:[email protected].0"
},
"tasks": {
"ci:generate": "deno run -A ./scripts/generate/main.ts",
Expand Down
4 changes: 2 additions & 2 deletions scripts/lint/file-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import core from "@actions/core";

import { REPO_ROOT } from "@/deps.ts";
import { log } from "./logger.ts";
import chalk from "chalk";
import * as color from "std/fmt/colors.ts";

const requiredFiles = [
"catppuccin.user.css",
Expand Down Expand Up @@ -39,7 +39,7 @@ export const checkForMissingFiles = async () => {
.write();
} else {
missingFiles.map((f) => {
log(chalk.red(`Missing file:`) + ` ${f}`, { file: f }, "error");
log(color.red(`Missing file:`) + ` ${f}`, { file: f }, "error");
});
}

Expand Down
18 changes: 9 additions & 9 deletions scripts/lint/logger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { sprintf } from "std/fmt/printf.ts";
import chalk from "chalk";
import * as color from "std/fmt/colors.ts";
import core from "@actions/core";

export type LoggerProps = core.AnnotationProperties & { content?: string };
Expand All @@ -15,7 +15,7 @@ const pretty_print = (
const lines = (props.content ?? "").split("\n");

const error = [
chalk[severity === "error" ? "red" : "yellow"](severity),
color[severity === "error" ? "red" : "yellow"](severity),
message,
].join(" ");

Expand All @@ -24,7 +24,7 @@ const pretty_print = (
const endCol = (props.endColumn ?? Infinity) - 1;

if (i >= startCol && i <= endCol) {
return chalk[severity === "error" ? "red" : "yellow"](char);
return color[severity === "error" ? "red" : "yellow"](char);
} else {
return char;
}
Expand All @@ -33,7 +33,7 @@ const pretty_print = (
const pad = startLine.toString().length;
console.log(
[
chalk.underline(
color.underline(
sprintf(
"%s%s%d%s%d",
file,
Expand All @@ -46,15 +46,15 @@ const pretty_print = (
sprintf(
"%*s│ %s",
pad,
chalk.dim(startLine - 1),
chalk.dim(lines[startLine - 2]),
color.dim(String(startLine - 1)),
color.dim(lines[startLine - 2]),
),
sprintf("%*s│ %s", pad, chalk.bold(startLine), line),
sprintf("%*s│ %s", pad, color.bold(String(startLine)), line),
sprintf(
"%*s│ %s",
pad,
chalk.dim(startLine + 1),
chalk.dim(lines[startLine]),
color.dim(String(startLine + 1)),
color.dim(lines[startLine]),
),
sprintf("%*s╰─► %s", pad, "", error),
undefined,
Expand Down
8 changes: 4 additions & 4 deletions scripts/lint/metadata.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chalk from "chalk";
// @deno-types="../usercss-meta.d.ts";
import usercssMeta from "usercss-meta";
import { log } from "./logger.ts";
import * as color from "std/fmt/colors.ts";
import { sprintf } from "std/fmt/printf.ts";
import type { WalkEntry } from "std/fs/mod.ts";
import { relative } from "std/path/mod.ts";
Expand Down Expand Up @@ -39,9 +39,9 @@ export const verifyMetadata = (

const message = sprintf(
"Metadata %s should be %s but is %s",
chalk.bold(k),
chalk.green(v),
chalk.red(defacto),
color.bold(k),
color.green(v),
color.red(String(defacto)),
);

log(message, {
Expand Down
4 changes: 2 additions & 2 deletions scripts/lint/stylelint.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deepMerge } from "std/collections/mod.ts";

import chalk from "chalk";
import * as color from "std/fmt/colors.ts";
import stylelint from "npm:stylelint";
import stylelintConfigStandard from "npm:stylelint-config-standard";
import stylelintConfigRecommended from "npm:stylelint-config-recommended";
Expand Down Expand Up @@ -182,7 +182,7 @@ export const lint = (entry: WalkEntry, content: string, fix: boolean) => {
// some cleanup for fancier logging, dims the rule name
const message = warning.text?.replace(
new RegExp(`\\(?${warning.rule}\\)?`),
chalk.dim(`(${warning.rule})`),
color.dim(`(${warning.rule})`),
) ?? "unspecified stylelint error";

log(message, {
Expand Down

0 comments on commit c3f013a

Please sign in to comment.