Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3753 from mermaid-js/sidv/cspell
Fix CSpell
- Loading branch information
Showing
5 changed files
with
95 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}) | ||
); |