From 6d447033c9800d7e00ef48a185d16fd6cf6d029c Mon Sep 17 00:00:00 2001 From: Dolan Miu Date: Tue, 5 Jul 2022 05:06:32 +0100 Subject: [PATCH] Fix more spelling rules --- .cspell.json | 29 +++++++++++++++++-- package.json | 2 +- src/export/packer/next-compiler.ts | 6 ++-- src/export/packer/packer.ts | 8 ++--- src/file/document/document-attributes.ts | 2 ++ src/file/paragraph/math/n-ary/index.ts | 2 +- ....spec.ts => math-n-ary-properties.spec.ts} | 22 +++++++------- ...properties.ts => math-n-ary-properties.ts} | 2 +- src/file/paragraph/math/n-ary/math-sum.ts | 4 +-- .../table-float-properties.ts | 2 ++ .../xml-components/imported-xml-component.ts | 4 +-- src/util/values.spec.ts | 1 + src/util/values.ts | 1 + 13 files changed, 58 insertions(+), 27 deletions(-) rename src/file/paragraph/math/n-ary/{math-naray-properties.spec.ts => math-n-ary-properties.spec.ts} (81%) rename src/file/paragraph/math/n-ary/{math-naray-properties.ts => math-n-ary-properties.ts} (93%) diff --git a/.cspell.json b/.cspell.json index ae890c6084..4d88d4de47 100644 --- a/.cspell.json +++ b/.cspell.json @@ -19,9 +19,34 @@ "iroha", "chosung", "Abjad", - "Initializable" + "Initializable", + "rels", + "dolan", + "xmlify", + "Xmlifyed", + "xmlified", + "datas", + "jszip", + "rsid", + "NUMPAGES", + "ATLEAST" + ], + "ignoreRegExpList": [ + "/w:.+/", + "/s:.+/", + "/a:.+/", + "/pic:.+/", + "/xmlns:.+/", + "/vt:.+/", + "/[^\\s]{40,}/", + "//", + "/[A-Z_]+ = \".+\"/", + "/XmlAttributeComponent<{[^}]+}>/g", + "/xmlKeys = {[^}]+}/g", + "/\\.to\\.deep\\.equal\\({[^)]+}\\)/g", + "\\.to\\.include\\.members\\(\\[[^\\]]+]\\)", + "/new [a-zA-Z]+\\({[^£]+}\\)/g" ], - "ignoreRegExpList": ["/w:.+/", "/s:.+/", "/a:.+/", "/pic:.+/", "/xmlns:.+/", "/[^\\s]{40,}/", "//", "/[A-Z_]+ = \".+\"/", "/XmlAttributeComponent<{(.|\\n| )+}>/"], "allowCompoundWords": true, // flagWords - list of words to be always considered incorrect // This is useful for offensive words and common spelling errors. diff --git a/package.json b/package.json index b97b4eb907..240f08677e 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "typedoc": "rimraf ./build && typedoc src/index.ts --tsconfig tsconfig.typedoc.json", "style": "prettier -l \"src/**/*.ts\"", "style.fix": "npm run style -- --write", - "cspell": "cspell \"/**/*.{ts,scss,html}\"", + "cspell": "cspell \"src/**/*.ts\" && cspell \"demo/**/*.{ts,scss,html}\" && cspell \"docs/**/*.{ts,md,html}\"", "fix-types": "ts-node --skip-project scripts/types-absolute-fixer.ts", "e2e": "ts-node scripts/e2e.ts", "serve.docs": "cd docs && docsify serve", diff --git a/src/export/packer/next-compiler.ts b/src/export/packer/next-compiler.ts index 5604cdabbb..59776fe1c4 100644 --- a/src/export/packer/next-compiler.ts +++ b/src/export/packer/next-compiler.ts @@ -6,7 +6,7 @@ import { File } from "@file/file"; import { Formatter } from "../formatter"; import { ImageReplacer } from "./image-replacer"; import { NumberingReplacer } from "./numbering-replacer"; -import { PrettityType } from "./packer"; +import { PrettifyType } from "./packer"; interface IXmlifyedFile { readonly data: string; @@ -44,7 +44,7 @@ export class Compiler { this.numberingReplacer = new NumberingReplacer(); } - public compile(file: File, prettifyXml?: boolean | PrettityType): JSZip { + public compile(file: File, prettifyXml?: boolean | PrettifyType): JSZip { const zip = new JSZip(); const xmlifiedFileMapping = this.xmlifyFile(file, prettifyXml); const map = new Map(Object.entries(xmlifiedFileMapping)); @@ -67,7 +67,7 @@ export class Compiler { return zip; } - private xmlifyFile(file: File, prettify?: boolean | PrettityType): IXmlifyedFileMapping { + private xmlifyFile(file: File, prettify?: boolean | PrettifyType): IXmlifyedFileMapping { const documentRelationshipCount = file.Document.Relationships.RelationshipCount + 1; const documentXmlData = xml( diff --git a/src/export/packer/packer.ts b/src/export/packer/packer.ts index 66bfe583e6..56d604fe18 100644 --- a/src/export/packer/packer.ts +++ b/src/export/packer/packer.ts @@ -5,7 +5,7 @@ import { Compiler } from "./next-compiler"; /** * Use blanks to prettify */ -export enum PrettityType { +export enum PrettifyType { NONE = "", WITH_2_BLANKS = " ", WITH_4_BLANKS = " ", @@ -13,7 +13,7 @@ export enum PrettityType { } export class Packer { - public static async toBuffer(file: File, prettify?: boolean | PrettityType): Promise { + public static async toBuffer(file: File, prettify?: boolean | PrettifyType): Promise { const zip = this.compiler.compile(file, prettify); const zipData = await zip.generateAsync({ type: "nodebuffer", @@ -24,7 +24,7 @@ export class Packer { return zipData; } - public static async toBase64String(file: File, prettify?: boolean | PrettityType): Promise { + public static async toBase64String(file: File, prettify?: boolean | PrettifyType): Promise { const zip = this.compiler.compile(file, prettify); const zipData = await zip.generateAsync({ type: "base64", @@ -35,7 +35,7 @@ export class Packer { return zipData; } - public static async toBlob(file: File, prettify?: boolean | PrettityType): Promise { + public static async toBlob(file: File, prettify?: boolean | PrettifyType): Promise { const zip = this.compiler.compile(file, prettify); const zipData = await zip.generateAsync({ type: "blob", diff --git a/src/file/document/document-attributes.ts b/src/file/document/document-attributes.ts index 1dd1546e4c..e919fa3de5 100644 --- a/src/file/document/document-attributes.ts +++ b/src/file/document/document-attributes.ts @@ -1,5 +1,6 @@ import { XmlAttributeComponent } from "@file/xml-components"; +/* cSpell:disable */ export interface IDocumentAttributesProperties { readonly wpc?: string; readonly mc?: string; @@ -41,6 +42,7 @@ export interface IDocumentAttributesProperties { readonly w16sdtdh?: string; readonly w16se?: string; } +/* cSpell:enable */ export class DocumentAttributes extends XmlAttributeComponent { protected readonly xmlKeys = { diff --git a/src/file/paragraph/math/n-ary/index.ts b/src/file/paragraph/math/n-ary/index.ts index 6929544152..59df698e9c 100644 --- a/src/file/paragraph/math/n-ary/index.ts +++ b/src/file/paragraph/math/n-ary/index.ts @@ -1,7 +1,7 @@ export * from "./math-accent-character"; export * from "./math-base"; export * from "./math-limit-location"; -export * from "./math-naray-properties"; +export * from "./math-n-ary-properties"; export * from "./math-sub-script"; export * from "./math-sum"; export * from "./math-super-script"; diff --git a/src/file/paragraph/math/n-ary/math-naray-properties.spec.ts b/src/file/paragraph/math/n-ary/math-n-ary-properties.spec.ts similarity index 81% rename from src/file/paragraph/math/n-ary/math-naray-properties.spec.ts rename to src/file/paragraph/math/n-ary/math-n-ary-properties.spec.ts index bc2d9a72e5..03111874d4 100644 --- a/src/file/paragraph/math/n-ary/math-naray-properties.spec.ts +++ b/src/file/paragraph/math/n-ary/math-n-ary-properties.spec.ts @@ -2,14 +2,14 @@ import { expect } from "chai"; import { Formatter } from "@export/formatter"; -import { MathNArayProperties } from "./math-naray-properties"; +import { MathNAryProperties } from "./math-n-ary-properties"; -describe("MathNArayProperties", () => { +describe("MathNAryProperties", () => { describe("#constructor()", () => { - it("should create a MathNArayProperties with correct root key", () => { - const mathNArayProperties = new MathNArayProperties("∑", true, true); + it("should create a MathNAryProperties with correct root key", () => { + const mathNAryProperties = new MathNAryProperties("∑", true, true); - const tree = new Formatter().format(mathNArayProperties); + const tree = new Formatter().format(mathNAryProperties); expect(tree).to.deep.equal({ "m:naryPr": [ { @@ -31,9 +31,9 @@ describe("MathNArayProperties", () => { }); it("should add super-script hide attributes", () => { - const mathNArayProperties = new MathNArayProperties("∑", false, true); + const mathNAryProperties = new MathNAryProperties("∑", false, true); - const tree = new Formatter().format(mathNArayProperties); + const tree = new Formatter().format(mathNAryProperties); expect(tree).to.deep.equal({ "m:naryPr": [ { @@ -62,9 +62,9 @@ describe("MathNArayProperties", () => { }); it("should add sub-script hide attributes", () => { - const mathNArayProperties = new MathNArayProperties("∑", true, false); + const mathNAryProperties = new MathNAryProperties("∑", true, false); - const tree = new Formatter().format(mathNArayProperties); + const tree = new Formatter().format(mathNAryProperties); expect(tree).to.deep.equal({ "m:naryPr": [ { @@ -93,9 +93,9 @@ describe("MathNArayProperties", () => { }); it("should add both super-script and sub-script hide attributes", () => { - const mathNArayProperties = new MathNArayProperties("∑", false, false); + const mathNAryProperties = new MathNAryProperties("∑", false, false); - const tree = new Formatter().format(mathNArayProperties); + const tree = new Formatter().format(mathNAryProperties); expect(tree).to.deep.equal({ "m:naryPr": [ { diff --git a/src/file/paragraph/math/n-ary/math-naray-properties.ts b/src/file/paragraph/math/n-ary/math-n-ary-properties.ts similarity index 93% rename from src/file/paragraph/math/n-ary/math-naray-properties.ts rename to src/file/paragraph/math/n-ary/math-n-ary-properties.ts index a1476eb0fc..8edacc8530 100644 --- a/src/file/paragraph/math/n-ary/math-naray-properties.ts +++ b/src/file/paragraph/math/n-ary/math-n-ary-properties.ts @@ -6,7 +6,7 @@ import { MathLimitLocation } from "./math-limit-location"; import { MathSubScriptHide } from "./math-sub-script-hide"; import { MathSuperScriptHide } from "./math-super-script-hide"; -export class MathNArayProperties extends XmlComponent { +export class MathNAryProperties extends XmlComponent { constructor(accent: string, hasSuperScript: boolean, hasSubScript: boolean) { super("m:naryPr"); diff --git a/src/file/paragraph/math/n-ary/math-sum.ts b/src/file/paragraph/math/n-ary/math-sum.ts index d899231a19..4d4506eb98 100644 --- a/src/file/paragraph/math/n-ary/math-sum.ts +++ b/src/file/paragraph/math/n-ary/math-sum.ts @@ -3,7 +3,7 @@ import { XmlComponent } from "@file/xml-components"; import { MathComponent } from "../math-component"; import { MathBase } from "./math-base"; -import { MathNArayProperties } from "./math-naray-properties"; +import { MathNAryProperties } from "./math-n-ary-properties"; import { MathSubScriptElement } from "./math-sub-script"; import { MathSuperScriptElement } from "./math-super-script"; @@ -17,7 +17,7 @@ export class MathSum extends XmlComponent { constructor(options: IMathSumOptions) { super("m:nary"); - this.root.push(new MathNArayProperties("∑", !!options.superScript, !!options.subScript)); + this.root.push(new MathNAryProperties("∑", !!options.superScript, !!options.subScript)); if (!!options.subScript) { this.root.push(new MathSubScriptElement(options.subScript)); diff --git a/src/file/table/table-properties/table-float-properties.ts b/src/file/table/table-properties/table-float-properties.ts index 740a98bee7..e0f19fc093 100644 --- a/src/file/table/table-properties/table-float-properties.ts +++ b/src/file/table/table-properties/table-float-properties.ts @@ -27,6 +27,7 @@ export enum RelativeVerticalPosition { } export interface ITableFloatOptions { + /* cSpell:disable */ /** * Specifies the horizontal anchor or the base object from which the horizontal positioning in the * tblpX or tblpXSpec attribute should be determined. @@ -35,6 +36,7 @@ export interface ITableFloatOptions { * text - relative to the vertical edge of the text margin for the column in which the anchor paragraph is located * If omitted, the value is assumed to be page. */ + /* cSpell:enable */ readonly horizontalAnchor?: TableAnchorType; /** diff --git a/src/file/xml-components/imported-xml-component.ts b/src/file/xml-components/imported-xml-component.ts index 0bf29c401e..85d46a7dbd 100644 --- a/src/file/xml-components/imported-xml-component.ts +++ b/src/file/xml-components/imported-xml-component.ts @@ -13,8 +13,8 @@ export function convertToXmlComponent(element: XmlElement): ImportedXmlComponent case undefined: case "element": const xmlComponent = new ImportedXmlComponent(element.name as string, element.attributes); - const childElments = element.elements || []; - for (const childElm of childElments) { + const childElements = element.elements || []; + for (const childElm of childElements) { const child = convertToXmlComponent(childElm); if (child !== undefined) { xmlComponent.push(child); diff --git a/src/util/values.spec.ts b/src/util/values.spec.ts index 3ef06a6abc..b4b36dbe44 100644 --- a/src/util/values.spec.ts +++ b/src/util/values.spec.ts @@ -73,6 +73,7 @@ describe("values", () => { it("should throw on invalid values", () => { expect(() => shortHexNumber("11")).to.throw(); expect(() => shortHexNumber("112233")).to.throw(); + /* cspell:disable-next-line */ expect(() => shortHexNumber("FFFG")).to.throw(); }); }); diff --git a/src/util/values.ts b/src/util/values.ts index 8634d47de4..aab6bc11ab 100644 --- a/src/util/values.ts +++ b/src/util/values.ts @@ -208,6 +208,7 @@ export const pointMeasureValue = unsignedDecimalNumber; // // http://www.datypic.com/sc/xsd/t-xsd_dateTime.html // The type xsd:dateTime represents a specific date and time in the format +/* cspell:disable-next-line */ // CCYY-MM-DDThh:mm:ss.sss, which is a concatenation of the date and time forms, // separated by a literal letter "T". All of the same rules that apply to the date // and time types are applicable to xsd:dateTime as well.