Merge pull request #3753 from mermaid-js/sidv/cspell

Fix CSpell
This commit is contained in:
Knut Sveidqvist
2022-11-07 09:40:23 +01:00
committed by GitHub
5 changed files with 100 additions and 99 deletions

View File

@@ -1,3 +1,4 @@
{ {
"!(docs/**/*)*.{ts,js,json,html,md,mts}": ["eslint --fix", "prettier --write"] "!(docs/**/*)*.{ts,js,json,html,md,mts}": ["eslint --fix", "prettier --write"],
"cSpell.json": ["ts-node-esm scripts/fixCSpell.ts"]
} }

View File

@@ -2,91 +2,85 @@
"version": "0.2", "version": "0.2",
"language": "en", "language": "en",
"words": [ "words": [
"blockquotes", "acyclicer",
"customizability", "adamiecki",
"Gantt", "alois",
"jison", "antiscript",
"mermaid",
"mindmap",
"Mindmaps",
"mitigations",
"sandboxed",
"shiki",
"verdana",
"Visio"
],
"ignoreWords": [
"Alois",
"Klink",
"knsv",
"Knut",
"Matthieu",
"Sidharth",
"Sveidqvist",
"Vinod",
"Faber",
"Orlandoni",
"Klemm",
"Mindaugas",
"Laganeckas",
"Cuzon",
"Yash",
"Adamiecki",
"applitools", "applitools",
"Asciidoctor", "asciidoctor",
"Astah", "ashish",
"Bisheng", "astah",
"bbox",
"bilkent",
"bisheng",
"brolin",
"codedoc", "codedoc",
"Docsy", "colour",
"Doku", "cpettitt",
"Gitea", "customizability",
"Gitgraph", "cuzon",
"Grav", "cytoscape",
"Inkdrop", "dagre",
"Jaoude", "descr",
"docsify",
"docsy",
"doku",
"dompurify",
"edgechromium",
"faber",
"flatmap",
"gantt",
"gitea",
"gitgraph",
"graphlib",
"grav",
"greywolf",
"inkdrop",
"jaoude",
"jison",
"kaufmann",
"klemm",
"klink",
"knsv",
"knut",
"laganeckas",
"lucida",
"matthieu",
"mdbook", "mdbook",
"mermerd", "mermerd",
"mindaugas",
"mindmap",
"mindmaps",
"mitigations",
"mkdocs", "mkdocs",
"orlandoni",
"phpbb", "phpbb",
"Plantuml", "plantuml",
"Playfair's", "playfair",
"Podlite", "podlite",
"redmine",
"sphinxcontrib",
"Tuleap",
"dagre",
"vitepress",
"docsify",
"colour",
"graphlib",
"acyclicer",
"ranksep", "ranksep",
"descr", "redmine",
"substate", "sandboxed",
"Ashish", "setupgraphviewbox",
"bbox", "shiki",
"techn", "sidharth",
"cytoscape", "sphinxcontrib",
"Lucida",
"Bilkent",
"cpettitt",
"antiscript",
"ts-nocheck",
"setupGraphViewbox",
"flatmap",
"Kaufmann",
"viewports",
"edgechromium",
"statediagram", "statediagram",
"Brolin", "substate",
"Greywolf" "sveidqvist",
"techn",
"ts-nocheck",
"tuleap",
"verdana",
"viewports",
"vinod",
"visio",
"vitepress",
"xlink",
"yash"
], ],
"patterns": [ "patterns": [
{ { "name": "Markdown links", "pattern": "\\((.*)\\)", "description": "" },
"name": "Markdown links",
"pattern": "\\((.*)\\)",
"description": ""
},
{ {
"name": "Markdown code blocks", "name": "Markdown code blocks",
"pattern": "/^(\\s*`{3,}).*[\\s\\S]*?^\\1/gmx", "pattern": "/^(\\s*`{3,}).*[\\s\\S]*?^\\1/gmx",
@@ -97,25 +91,14 @@
"pattern": "\\`([^\\`\\r\\n]+?)\\`", "pattern": "\\`([^\\`\\r\\n]+?)\\`",
"description": "https://stackoverflow.com/questions/41274241/how-to-capture-inline-markdown-code-but-not-a-markdown-code-fence-with-regex" "description": "https://stackoverflow.com/questions/41274241/how-to-capture-inline-markdown-code-but-not-a-markdown-code-fence-with-regex"
}, },
{ { "name": "Link contents", "pattern": "\\<a(.*)\\>", "description": "" },
"name": "Link contents", { "name": "Snippet references", "pattern": "-- snippet:(.*)", "description": "" },
"pattern": "\\<a(.*)\\>",
"description": ""
},
{
"name": "Snippet references",
"pattern": "-- snippet:(.*)",
"description": ""
},
{ {
"name": "Snippet references 2", "name": "Snippet references 2",
"pattern": "\\<\\[sample:(.*)", "pattern": "\\<\\[sample:(.*)",
"description": "another kind of snippet reference" "description": "another kind of snippet reference"
}, },
{ { "name": "Multi-line code blocks", "pattern": "/^\\s*```[\\s\\S]*?^\\s*```/gm" },
"name": "Multi-line code blocks",
"pattern": "/^\\s*```[\\s\\S]*?^\\s*```/gm"
},
{ {
"name": "HTML Tags", "name": "HTML Tags",
"pattern": "<[^>]*>", "pattern": "<[^>]*>",

View File

@@ -33,7 +33,7 @@
"dev": "concurrently \"pnpm build:vite --watch\" \"ts-node-esm .vite/server.ts\"", "dev": "concurrently \"pnpm build:vite --watch\" \"ts-node-esm .vite/server.ts\"",
"release": "pnpm build", "release": "pnpm build",
"lint": "eslint --cache --ignore-path .gitignore . && pnpm --filter mermaid run lint:jison && prettier --check .", "lint": "eslint --cache --ignore-path .gitignore . && pnpm --filter mermaid run lint:jison && prettier --check .",
"lint:fix": "eslint --fix --ignore-path .gitignore . && prettier --write .", "lint:fix": "eslint --fix --ignore-path .gitignore . && prettier --write . && ts-node-esm scripts/fixCSpell.ts",
"cypress": "cypress run", "cypress": "cypress run",
"cypress:open": "cypress open", "cypress:open": "cypress open",
"e2e": "start-server-and-test dev http://localhost:9000/ cypress", "e2e": "start-server-and-test dev http://localhost:9000/ cypress",

View File

@@ -61,14 +61,7 @@ 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 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.`;
// TODO: Read from .prettierrc? const prettierConfig = prettier.resolveConfig.sync('.') ?? {};
const prettierConfig: prettier.Config = {
useTabs: false,
tabWidth: 2,
endOfLine: 'auto',
printWidth: 100,
singleQuote: true,
};
let filesWereTransformed = false; let filesWereTransformed = false;

24
scripts/fixCSpell.ts Normal file
View File

@@ -0,0 +1,24 @@
/**
* Sorts all the `words` in the cSpell.json file.
*
* Run from the same folder as the `cSpell.json` file
* (i.e. the root of the Mermaid project).
*/
import { readFileSync, writeFileSync } from 'node:fs';
import prettier from 'prettier';
const filepath = './cSpell.json';
const cSpell: { words: string[] } = JSON.parse(readFileSync(filepath, 'utf8'));
cSpell.words = [...new Set(cSpell.words.map((word) => word.toLowerCase()))];
cSpell.words.sort((a, b) => a.localeCompare(b));
const prettierConfig = prettier.resolveConfig.sync(filepath) ?? {};
writeFileSync(
filepath,
prettier.format(JSON.stringify(cSpell), {
...prettierConfig,
filepath,
})
);