chore: fix biome warnings/errors (#26295)
* Fix icon-names * make all errors into warns * Minimal fix to mock
This commit is contained in:
1 parent
e4753778fe
commit
c52eff65a2
14 files changed
+246
-217
No files matched your search
@@ -32,13 +32,21 @@ async function generateIconFiles() {
|
||||
|
||||
const spriteFilepath = path.join(outputDir, "sprite.svg");
|
||||
const typeOutputFilepath = path.join(typesDir, "icon-names.ts");
|
||||
const currentSprite = await fsExtra.readFile(spriteFilepath, "utf8").catch(() => "");
|
||||
const currentTypes = await fsExtra.readFile(typeOutputFilepath, "utf8").catch(() => "");
|
||||
const currentSprite = await fsExtra
|
||||
.readFile(spriteFilepath, "utf8")
|
||||
.catch(() => "");
|
||||
const currentTypes = await fsExtra
|
||||
.readFile(typeOutputFilepath, "utf8")
|
||||
.catch(() => "");
|
||||
|
||||
const iconNames = files.map((file) => iconName(file));
|
||||
|
||||
const spriteUpToDate = iconNames.every((name) => currentSprite.includes(`id=${name}`));
|
||||
const typesUpToDate = iconNames.every((name) => currentTypes.includes(`"${name}"`));
|
||||
const spriteUpToDate = iconNames.every((name) =>
|
||||
currentSprite.includes(`id=${name}`)
|
||||
);
|
||||
const typesUpToDate = iconNames.every((name) =>
|
||||
currentTypes.includes(`"${name}"`)
|
||||
);
|
||||
|
||||
if (spriteUpToDate && typesUpToDate) {
|
||||
logVerbose(`Icons are up to date`);
|
||||
@@ -63,9 +71,12 @@ async function generateIconFiles() {
|
||||
const typeOutputContent = `// This file is generated by yarn run build:icons
|
||||
|
||||
export type IconName =
|
||||
\t| ${stringifiedIconNames.join("\n\t| ")};
|
||||
\t| ${stringifiedIconNames.join("\n | ")};
|
||||
`;
|
||||
const typesChanged = await writeIfChanged(typeOutputFilepath, typeOutputContent);
|
||||
const typesChanged = await writeIfChanged(
|
||||
typeOutputFilepath,
|
||||
typeOutputContent
|
||||
);
|
||||
|
||||
logVerbose(`Manifest saved to ${path.relative(cwd, typeOutputFilepath)}`);
|
||||
|
||||
@@ -119,7 +130,9 @@ async function generateSvgSprite({ files, inputDir, outputPath }) {
|
||||
}
|
||||
|
||||
async function writeIfChanged(filepath, newContent) {
|
||||
const currentContent = await fsExtra.readFile(filepath, "utf8").catch(() => "");
|
||||
const currentContent = await fsExtra
|
||||
.readFile(filepath, "utf8")
|
||||
.catch(() => "");
|
||||
if (currentContent === newContent) return false;
|
||||
await fsExtra.writeFile(filepath, newContent, "utf8");
|
||||
await $`node ${biomeBin} format --write ${filepath}`;
|
||||
|
||||
Reference in new issue
Block a user