Fix prettier formatting on generation.

We should replace this with Biome as well, but it's a bit complicated.
This commit is contained in:
Sidharth Vinod 2024-06-21 15:18:30 +05:30
parent a23b891f20
commit ba34386a69
No known key found for this signature in database
GPG Key ID: FB5CCD378D3907CD
4 changed files with 11 additions and 9 deletions

View File

@ -18,7 +18,7 @@ import { execFile } from 'node:child_process';
import { readFile, writeFile } from 'node:fs/promises';
import { join } from 'node:path';
import { promisify } from 'node:util';
import prettier from 'prettier';
import { prettierConfig } from './prettier.js';
// Workaround for wrong AJV types, see
// https://github.com/ajv-validator/ajv/issues/2132#issuecomment-1290409907
@ -141,7 +141,7 @@ async function generateTypescript(mermaidConfigSchema: JSONSchemaType<MermaidCon
{
additionalProperties: false, // in JSON Schema 2019-09, these are called `unevaluatedProperties`
unreachableDefinitions: true, // definition for FontConfig is unreachable
style: (await prettier.resolveConfig('.')) ?? {},
style: prettierConfig,
}
);

View File

@ -52,6 +52,7 @@ import mm from 'micromatch';
// @ts-ignore No typescript declaration file
import flatmap from 'unist-util-flatmap';
import { visit } from 'unist-util-visit';
import { prettierConfig } from './prettier.js';
export const MERMAID_RELEASE_VERSION = JSON.parse(readFileSync('../mermaid/package.json', 'utf8'))
.version as string;
@ -85,7 +86,6 @@ const LOGMSG_COPIED = `, and copied to ${FINAL_DOCS_DIR}`;
const WARN_DOCSDIR_DOESNT_MATCH = `Changed files were transformed in ${SOURCE_DOCS_DIR} but do not match the files in ${FINAL_DOCS_DIR}. Please run 'pnpm --filter mermaid run docs:build' after making changes to ${SOURCE_DOCS_DIR} to update the ${FINAL_DOCS_DIR} directory with the transformed files.`;
const prettierConfig = (await prettier.resolveConfig('.')) ?? {};
// From https://github.com/vuejs/vitepress/blob/428eec3750d6b5648a77ac52d88128df0554d4d1/src/node/markdownToVue.ts#L20-L21
const includesRE = /<!--\s*@include:\s*(.*?)\s*-->/g;
const includedFiles: Set<string> = new Set();

View File

@ -0,0 +1,8 @@
export const prettierConfig = {
endOfLine: 'auto',
printWidth: 100,
singleQuote: true,
useTabs: false,
tabWidth: 2,
trailingComma: 'es5',
} as const;

6
pnpm-lock.yaml generated
View File

@ -303,12 +303,6 @@ importers:
'@types/uuid':
specifier: ^9.0.8
version: 9.0.8
'@typescript-eslint/eslint-plugin':
specifier: ^7.3.1
version: 7.6.0(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.4.5))(eslint@8.57.0)(typescript@5.4.5)
'@typescript-eslint/parser':
specifier: ^7.3.1
version: 7.6.0(eslint@8.57.0)(typescript@5.4.5)
ajv:
specifier: ^8.12.0
version: 8.12.0