feat(scripts/lint): intercept lib http imports for local linting (#2292)
This commit is contained in:
2 files changed
+52
-12
No files matched your search
+1
-12
@@ -12,6 +12,7 @@ import { verifyMetadata } from "@/lint/metadata.ts";
|
||||
import { runStylelint } from "@/lint/stylelint.ts";
|
||||
import { getUserstylesData, getUserstylesFiles } from "@/utils.ts";
|
||||
import stylelintConfig from "../../.stylelintrc.js";
|
||||
import "@/lint/library.ts";
|
||||
|
||||
const args = parseArgs(Deno.args, { boolean: ["fix"] });
|
||||
const userstyle = args._[0]?.toString().match(
|
||||
@@ -24,19 +25,12 @@ const stylesheets = userstyle
|
||||
const { userstyles } = getUserstylesData();
|
||||
|
||||
let didLintFail = false;
|
||||
const patches = [
|
||||
["https://userstyles.catppuccin.com/lib", path.join(REPO_ROOT, "lib")],
|
||||
];
|
||||
|
||||
for (const style of stylesheets) {
|
||||
const dir = path.basename(path.dirname(style));
|
||||
const file = path.relative(REPO_ROOT, style);
|
||||
|
||||
let content = await Deno.readTextFile(style);
|
||||
// Apply patches.
|
||||
for (const [search, replace] of patches) {
|
||||
content = content.replaceAll(search, replace);
|
||||
}
|
||||
|
||||
// Verify the UserCSS metadata.
|
||||
const { globalVars, isLess, fixed } = await verifyMetadata(
|
||||
@@ -63,11 +57,6 @@ for (const style of stylesheets) {
|
||||
},
|
||||
);
|
||||
|
||||
// Reverse apply patches.
|
||||
for (const [search, replace] of patches) {
|
||||
content = content.replaceAll(replace, search);
|
||||
}
|
||||
|
||||
// Lint with Stylelint.
|
||||
const results = await runStylelint(style, content, args.fix, stylelintConfig)
|
||||
.catch(() => didLintFail = true);
|
||||
|
||||
Reference in new issue
Block a user