UNPKG

radashi-helper

Version:
49 lines (47 loc) 1.33 kB
import { stdio } from "./chunk-GGEXN2BI.js"; import { getEnv } from "./chunk-DSXY7YVB.js"; import { RadashiError, exec, log } from "./chunk-JLKIE3A2.js"; import "./chunk-VOEQFXI5.js"; // src/lint.ts import glob from "fast-glob"; import { existsSync } from "node:fs"; import { join } from "node:path"; async function lint(files, options) { const env = options.env ?? getEnv(options.dir); const binFiles = glob.sync("*", { cwd: join(env.root, "node_modules/.bin") }); for (const binFile of binFiles) { if (binFile === "biome" && existsSync(join(env.root, "biome.json"))) { const biomeGlobs = ["./src", "./tests", "./benchmarks"].flatMap( (rootGlob) => [rootGlob, rootGlob.replace("./", "./overrides/")] ); await exec("pnpm", ["biome", "check", ...biomeGlobs], { cwd: env.root, stdio }).catch((error) => { log.error(error.message); throw new RadashiError("Biome failed to lint."); }); } else if (binFile === "eslint" && (await glob("eslint.config.*", { cwd: env.root })).length > 0) { await exec("pnpm", ["eslint", ...files], { cwd: env.root, stdio }).catch((error) => { log.error(error.message); throw new RadashiError("ESLint failed to lint."); }); } } } export { lint };