From 0c85e8ee53725f0371c2fe0952c011846e971c1b Mon Sep 17 00:00:00 2001 From: "Ashley Engelund (weedySeaDragon @ github)" Date: Mon, 5 Sep 2022 18:27:58 -0700 Subject: [PATCH] eslint (mostly use double quotes) --- src/docs.mts | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/docs.mts b/src/docs.mts index 76594c4bf..9e3b9ddef 100644 --- a/src/docs.mts +++ b/src/docs.mts @@ -1,26 +1,26 @@ -import { remark } from 'remark'; -import type { Code, Root } from 'mdast'; -import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'fs'; +import { remark } from "remark"; +import type { Code, Root } from "mdast"; +import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs"; // @ts-ignore -import flatmap from 'unist-util-flatmap'; -import { globby } from 'globby'; -import { join, dirname } from 'path'; -import { exec } from 'child_process'; -import prettier from 'prettier'; +import flatmap from "unist-util-flatmap"; +import { globby } from "globby"; +import { join, dirname } from "path"; +import { exec } from "child_process"; +import prettier from "prettier"; -const verify = process.argv.includes('--verify'); -const git = process.argv.includes('--git'); +const verify = process.argv.includes("--verify"); +const git = process.argv.includes("--git"); let fileChanged = false; // Possible Improvement: combine with lint-staged to only copy files that have changed const prepareOutFile = (file: string): string => { - const outFile = join('docs', file.replace('src/docs/', '')); + const outFile = join("docs", file.replace("src/docs/", "")); mkdirSync(dirname(outFile), { recursive: true }); return outFile; }; const verifyAndCopy = (file: string, content?: string) => { const outFile = prepareOutFile(file); - const existingBuffer = existsSync(outFile) ? readFileSync(outFile) : Buffer.from('#NEW FILE#'); + const existingBuffer = existsSync(outFile) ? readFileSync(outFile) : Buffer.from("#NEW FILE#"); const newBuffer = content ? Buffer.from(content) : readFileSync(file); if (existingBuffer.equals(newBuffer)) { // Files are same, skip. @@ -34,16 +34,16 @@ const verifyAndCopy = (file: string, content?: string) => { }; const transform = (file: string) => { - const doc = readFileSync(file, 'utf8'); + const doc = readFileSync(file, "utf8"); const ast: Root = remark.parse(doc); const out = flatmap(ast, (c: Code) => { - if (c.type !== 'code' || !c.lang?.startsWith('mermaid')) { + if (c.type !== "code" || !c.lang?.startsWith("mermaid")) { return [c]; } - if (c.lang === 'mermaid' || c.lang === 'mmd') { - c.lang = 'mermaid-example'; + if (c.lang === "mermaid" || c.lang === "mmd") { + c.lang = "mermaid-example"; } - return [c, Object.assign({}, c, { lang: 'mermaid' })]; + return [c, Object.assign({}, c, { lang: "mermaid" })]; }); const transformed = `# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT. Please edit corresponding file in src/docs.\n${remark.stringify( @@ -52,20 +52,20 @@ const transform = (file: string) => { verifyAndCopy( file, prettier.format(transformed, { - parser: 'markdown', + parser: "markdown", useTabs: false, tabWidth: 2, - endOfLine: 'auto', + endOfLine: "auto", printWidth: 100, - singleQuote: true, + singleQuote: true }) ); }; (async () => { - const mdFiles = await globby(['./src/docs/**/*.md'], { dot: true }); + const mdFiles = await globby(["./src/docs/**/*.md"], { dot: true }); mdFiles.forEach(transform); - const nonMDFiles = await globby(['src/docs/**', '!**/*.md'], { dot: true }); + const nonMDFiles = await globby(["src/docs/**", "!**/*.md"], { dot: true }); nonMDFiles.forEach((file) => { verifyAndCopy(file); }); @@ -77,8 +77,8 @@ const transform = (file: string) => { process.exit(1); } if (git) { - console.log('Adding changes in docs folder to git'); - exec('git add docs'); + console.log("Adding changes in docs folder to git"); + exec("git add docs"); } } })();