Update linting

This commit is contained in:
Zaid Humaimidi committed 2023-12-16 19:08:13 -08:00
1 parent 4f2dfb4f48
commit 0c9c027a77
112 files changed
+3781 -4125

No files matched your search

+12 -12
View File
@@ -106,7 +106,7 @@ const assetsPlugin = {
setup(build) {
build.onLoad({ filter: /\/build\/assets.ts$/ }, () => {
const lines = Object.entries(ASSETS).map(
([k, v]) => `export const ${k} = ${JSON.stringify(v)};`
([k, v]) => `export const ${k} = ${JSON.stringify(v)};`,
);
return { contents: lines.join("\n") };
});
@@ -194,11 +194,11 @@ async function init(): Promise<void> {
fsAsync.mkdir(path.join(OUTPUT_DIR, "public")),
fsAsync.writeFile(
path.join(OUTPUT_DIR, "package.json"),
JSON.stringify(packageJson, null, 2)
JSON.stringify(packageJson, null, 2),
),
fsAsync.writeFile(
path.join(OUTPUT_DIR, "npm-shrinkwrap.json"),
JSON.stringify(npmShrinkwrap, null, 2)
JSON.stringify(npmShrinkwrap, null, 2),
),
]);
}
@@ -228,9 +228,9 @@ async function copyStatic(): Promise<void> {
files.map((f) =>
fsAsync.copyFile(
path.join(INPUT_DIR, f),
path.join(OUTPUT_DIR, filenames[f] || f)
)
)
path.join(OUTPUT_DIR, filenames[f] || f),
),
),
);
}
@@ -252,7 +252,7 @@ async function generateCss(): Promise<void> {
if (v.entryPoint === "ui/css/app.css") {
ASSETS.APP_CSS = path.relative(
path.join(OUTPUT_DIR, "public"),
path.join(INPUT_DIR, k)
path.join(INPUT_DIR, k),
);
break;
}
@@ -315,7 +315,7 @@ async function generateFrontendJs(): Promise<void> {
if (v.entryPoint === "ui/app.ts") {
ASSETS.APP_JS = path.relative(
path.join(OUTPUT_DIR, "public"),
path.join(INPUT_DIR, k)
path.join(INPUT_DIR, k),
);
break;
}
@@ -344,12 +344,12 @@ async function generateIconsSprite(): Promise<void> {
symbols.push(generateSymbol(id, data));
}
const data = `<svg xmlns="http://www.w3.org/2000/svg">${symbols.join(
""
"",
)}</svg>`;
ASSETS.ICONS_SVG = `icons-${assetHash(data)}.svg`;
await fsAsync.writeFile(
path.join(OUTPUT_DIR, "public", ASSETS.ICONS_SVG),
data
data,
);
}
@@ -357,10 +357,10 @@ init()
.then(() =>
Promise.all([
Promise.all([generateIconsSprite(), copyStatic()]).then(
generateFrontendJs
generateFrontendJs,
),
generateCss(),
]).then(generateBackendJs)
]).then(generateBackendJs),
)
.catch((err) => {
process.stderr.write(err.stack + "\n");
+55
View File
@@ -0,0 +1,55 @@
import { exec } from "child_process";
import { promisify } from "util";
const execPromise = promisify(exec);
async function runEslint(): Promise<string> {
const CMD =
"eslint 'bin/*.ts' 'lib/**/*.ts' 'ui/**/*.ts' 'test/**/*.ts' 'build/**/*.ts'";
const env = {
...(process.stdout.isTTY && { FORCE_COLOR: "1" }),
...process.env,
};
try {
const { stdout, stderr } = await execPromise(CMD, { env });
if (stderr) throw new Error(stderr);
return stdout;
} catch (err) {
if (err.killed || err.signal || err.stderr || err.code !== 1) throw err;
return err.stdout;
}
}
async function runTsc(): Promise<string> {
const CMD = "tsc --noEmit";
const env = {
...(process.stdout.isTTY && { FORCE_COLOR: "1" }),
...process.env,
};
const { stdout, stderr } = await execPromise(CMD, { env });
if (stderr) throw new Error(stderr);
return stdout;
}
async function runPrettier(): Promise<string> {
const CMD = "prettier --prose-wrap always --write .";
const env = {
...(process.stdout.isTTY && { FORCE_COLOR: "1" }),
...process.env,
};
const { stdout, stderr } = await execPromise(CMD, { env });
if (stderr) throw new Error(stderr);
return stdout;
}
async function runAll(): Promise<void> {
const prom1 = runPrettier();
const prom2 = runEslint();
const prom3 = runTsc();
console.log(await prom1);
console.log(await prom2);
console.log(await prom3);
}
runAll().catch(console.error);