diff --git a/.vscode/settings.json b/.vscode/settings.json index f144f59202c..5702eef1689 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,5 +5,6 @@ "editor.formatOnSave": false, "prettier.tabWidth": 4, "prettier.arrowParens": "always", - "prettier.bracketSpacing": true + "prettier.bracketSpacing": true, + "eslint.useFlatConfig": true } diff --git a/eslint.config.ts b/eslint.config.ts index 004a904d748..8733c814a1b 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -1,28 +1,24 @@ import eslint from "@eslint/js"; import type { Linter } from "eslint"; -import _import from "eslint-plugin-import"; -import noNull from "eslint-plugin-no-null"; +import importPlugin from "eslint-plugin-import"; import unicorn from "eslint-plugin-unicorn"; import jsdoc from "eslint-plugin-jsdoc"; import preferArrow from "eslint-plugin-prefer-arrow"; import functional from "eslint-plugin-functional"; -import { fixupPluginRules } from "@eslint/compat"; import globals from "globals"; -import tsEslint from 'typescript-eslint'; - +import tsEslint from "typescript-eslint"; const config: Linter.Config[] = [ { ignores: ["**/vite.config.ts", "**/build/**", "**/coverage/**", "**/*.js", "eslint.config.ts", "**/demo/**", "**/scripts/**"], }, eslint.configs.recommended, + importPlugin.flatConfigs.recommended, ...tsEslint.configs.recommended, ...tsEslint.configs.stylistic, { files: ["**/src/**/*.ts"], plugins: { - import: fixupPluginRules(_import), - "no-null": noNull, unicorn, jsdoc, "prefer-arrow": preferArrow, @@ -36,6 +32,13 @@ const config: Linter.Config[] = [ }, }, + settings: { + "import/resolver": { + typescript: true, + node: true, + }, + }, + rules: { "no-undef": "off", "no-extra-boolean-cast": "off", @@ -217,7 +220,30 @@ const config: Linter.Config[] = [ "import/no-default-export": "error", "import/no-extraneous-dependencies": "off", "import/no-internal-modules": "off", - "import/order": "error", + "sort-imports": [ + "error", + { + allowSeparatedGroups: true, + ignoreDeclarationSort: true, + }, + ], + "import/order": [ + "error", + { + groups: [["external", "builtin"], "internal", ["sibling", "parent", "index"]], + "newlines-between": "always", + pathGroups: [ + { pattern: "@file/**/*", group: "internal" }, + { pattern: "@file/**", group: "internal" }, + { pattern: "@export/**", group: "internal" }, + ], + pathGroupsExcludedImportTypes: ["internal"], + alphabetize: { + order: "asc", + caseInsensitive: true, + }, + }, + ], indent: "off", "jsdoc/check-alignment": "error", "jsdoc/check-indentation": "off", @@ -240,7 +266,6 @@ const config: Linter.Config[] = [ "no-multiple-empty-lines": "error", "no-new-func": "error", "no-new-wrappers": "error", - "no-null/no-null": "error", "no-param-reassign": "error", "no-redeclare": "error", "no-return-await": "error", @@ -308,8 +333,6 @@ const config: Linter.Config[] = [ { files: ["**/*.spec.ts"], plugins: { - import: fixupPluginRules(_import), - "no-null": noNull, unicorn, jsdoc, "prefer-arrow": preferArrow, diff --git a/package-lock.json b/package-lock.json index 6ed77d0aa53..5ad479b4365 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,6 +30,7 @@ "cspell": "^8.2.3", "docsify-cli": "^4.3.0", "eslint": "^9.13.0", + "eslint-import-resolver-typescript": "^3.6.3", "eslint-plugin-functional": "^7.0.2", "eslint-plugin-import": "^2.26.0", "eslint-plugin-jsdoc": "^50.3.1", @@ -1845,6 +1846,16 @@ "node": ">= 8" } }, + "node_modules/@nolyfill/is-core-module": { + "version": "1.0.39", + "resolved": "https://registry.npmjs.org/@nolyfill/is-core-module/-/is-core-module-1.0.39.tgz", + "integrity": "sha512-nn5ozdjYQpUCZlWGuxcJY/KpxkWQs4DcbMCmKojjyrYDEAGy4Ce19NN4v5MduafTwJlbKc99UA8YhSVqq9yPZA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.4.0" + } + }, "node_modules/@pkgr/core": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz", @@ -5388,6 +5399,20 @@ "once": "^1.4.0" } }, + "node_modules/enhanced-resolve": { + "version": "5.17.1", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz", + "integrity": "sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.4", + "tapable": "^2.2.0" + }, + "engines": { + "node": ">=10.13.0" + } + }, "node_modules/enquirer": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", @@ -5736,6 +5761,67 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, + "node_modules/eslint-import-resolver-typescript": { + "version": "3.6.3", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.6.3.tgz", + "integrity": "sha512-ud9aw4szY9cCT1EWWdGv1L1XR6hh2PaRWif0j2QjQ0pgTY/69iw+W0Z4qZv5wHahOl8isEr+k/JnyAqNQkLkIA==", + "dev": true, + "license": "ISC", + "dependencies": { + "@nolyfill/is-core-module": "1.0.39", + "debug": "^4.3.5", + "enhanced-resolve": "^5.15.0", + "eslint-module-utils": "^2.8.1", + "fast-glob": "^3.3.2", + "get-tsconfig": "^4.7.5", + "is-bun-module": "^1.0.2", + "is-glob": "^4.0.3" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts/projects/eslint-import-resolver-ts" + }, + "peerDependencies": { + "eslint": "*", + "eslint-plugin-import": "*", + "eslint-plugin-import-x": "*" + }, + "peerDependenciesMeta": { + "eslint-plugin-import": { + "optional": true + }, + "eslint-plugin-import-x": { + "optional": true + } + } + }, + "node_modules/eslint-import-resolver-typescript/node_modules/debug": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", + "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/eslint-import-resolver-typescript/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, "node_modules/eslint-module-utils": { "version": "2.12.0", "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.12.0.tgz", @@ -7882,6 +7968,29 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/is-bun-module": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-bun-module/-/is-bun-module-1.2.1.tgz", + "integrity": "sha512-AmidtEM6D6NmUiLOvvU7+IePxjEjOzra2h0pSrsfSAcXwl/83zLLXDByafUJy9k/rKK0pvXMLdwKwGHlX2Ke6Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.6.3" + } + }, + "node_modules/is-bun-module/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/is-callable": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", @@ -11414,6 +11523,16 @@ "url": "https://opencollective.com/unts" } }, + "node_modules/tapable": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", + "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/term-size": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/term-size/-/term-size-2.2.1.tgz", @@ -15125,6 +15244,12 @@ "fastq": "^1.6.0" } }, + "@nolyfill/is-core-module": { + "version": "1.0.39", + "resolved": "https://registry.npmjs.org/@nolyfill/is-core-module/-/is-core-module-1.0.39.tgz", + "integrity": "sha512-nn5ozdjYQpUCZlWGuxcJY/KpxkWQs4DcbMCmKojjyrYDEAGy4Ce19NN4v5MduafTwJlbKc99UA8YhSVqq9yPZA==", + "dev": true + }, "@pkgr/core": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz", @@ -17790,6 +17915,16 @@ "once": "^1.4.0" } }, + "enhanced-resolve": { + "version": "5.17.1", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz", + "integrity": "sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.4", + "tapable": "^2.2.0" + } + }, "enquirer": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", @@ -18190,6 +18325,39 @@ } } }, + "eslint-import-resolver-typescript": { + "version": "3.6.3", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.6.3.tgz", + "integrity": "sha512-ud9aw4szY9cCT1EWWdGv1L1XR6hh2PaRWif0j2QjQ0pgTY/69iw+W0Z4qZv5wHahOl8isEr+k/JnyAqNQkLkIA==", + "dev": true, + "requires": { + "@nolyfill/is-core-module": "1.0.39", + "debug": "^4.3.5", + "enhanced-resolve": "^5.15.0", + "eslint-module-utils": "^2.8.1", + "fast-glob": "^3.3.2", + "get-tsconfig": "^4.7.5", + "is-bun-module": "^1.0.2", + "is-glob": "^4.0.3" + }, + "dependencies": { + "debug": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", + "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", + "dev": true, + "requires": { + "ms": "^2.1.3" + } + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + } + } + }, "eslint-module-utils": { "version": "2.12.0", "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.12.0.tgz", @@ -19601,6 +19769,23 @@ } } }, + "is-bun-module": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-bun-module/-/is-bun-module-1.2.1.tgz", + "integrity": "sha512-AmidtEM6D6NmUiLOvvU7+IePxjEjOzra2h0pSrsfSAcXwl/83zLLXDByafUJy9k/rKK0pvXMLdwKwGHlX2Ke6Q==", + "dev": true, + "requires": { + "semver": "^7.6.3" + }, + "dependencies": { + "semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true + } + } + }, "is-callable": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", @@ -22237,6 +22422,12 @@ "tslib": "^2.6.2" } }, + "tapable": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", + "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", + "dev": true + }, "term-size": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/term-size/-/term-size-2.2.1.tgz", diff --git a/package.json b/package.json index ba1c9ccd0cb..a1acfe319fa 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "test": "vitest --ui --coverage", "test:ci": "vitest run --coverage", "prepublishOnly": "npm run build --omit=dev", - "lint": "npx eslint --flag unstable_ts_config --config eslint.config.ts", + "lint": "eslint --flag unstable_ts_config --config eslint.config.ts", "predemo": "npm run build", "demo": "tsx ./demo/index.ts", "typedoc": "typedoc src/index.ts --tsconfig tsconfig.typedoc.json", @@ -81,6 +81,7 @@ "cspell": "^8.2.3", "docsify-cli": "^4.3.0", "eslint": "^9.13.0", + "eslint-import-resolver-typescript": "^3.6.3", "eslint-plugin-functional": "^7.0.2", "eslint-plugin-import": "^2.26.0", "eslint-plugin-jsdoc": "^50.3.1", diff --git a/src/export/formatter.ts b/src/export/formatter.ts index 26dc04eb092..694c97f9b40 100644 --- a/src/export/formatter.ts +++ b/src/export/formatter.ts @@ -1,7 +1,6 @@ import { BaseXmlComponent, IContext, IXmlableObject } from "@file/xml-components"; export class Formatter { - // tslint:disable-next-line: no-object-literal-type-assertion public format(input: BaseXmlComponent, context: IContext = { stack: [] } as unknown as IContext): IXmlableObject { const output = input.prepForXml(context); diff --git a/src/export/packer/next-compiler.spec.ts b/src/export/packer/next-compiler.spec.ts index 753389de44e..e0c7197df7a 100644 --- a/src/export/packer/next-compiler.spec.ts +++ b/src/export/packer/next-compiler.spec.ts @@ -125,7 +125,6 @@ describe("Compiler", () => { ], }); - // tslint:disable-next-line: no-string-literal const spy = vi.spyOn(compiler["formatter"], "format"); compiler.compile(file); diff --git a/src/export/packer/next-compiler.ts b/src/export/packer/next-compiler.ts index b7df84c8995..089489d9024 100644 --- a/src/export/packer/next-compiler.ts +++ b/src/export/packer/next-compiler.ts @@ -9,12 +9,12 @@ import { ImageReplacer } from "./image-replacer"; import { NumberingReplacer } from "./numbering-replacer"; import { PrettifyType } from "./packer"; -interface IXmlifyedFile { +type IXmlifyedFile = { readonly data: string; readonly path: string; -} +}; -interface IXmlifyedFileMapping { +type IXmlifyedFileMapping = { readonly Document: IXmlifyedFile; readonly Styles: IXmlifyedFile; readonly Properties: IXmlifyedFile; @@ -34,7 +34,7 @@ interface IXmlifyedFileMapping { readonly Comments?: IXmlifyedFile; readonly FontTable?: IXmlifyedFile; readonly FontTableRelationships?: IXmlifyedFile; -} +}; export class Compiler { private readonly formatter: Formatter; diff --git a/src/export/packer/packer.spec.ts b/src/export/packer/packer.spec.ts index ae59646cf95..344d3d35f2c 100644 --- a/src/export/packer/packer.spec.ts +++ b/src/export/packer/packer.spec.ts @@ -139,7 +139,6 @@ describe("Packer", () => { it("should create a standard docx file", async () => { // eslint-disable-next-line @typescript-eslint/no-explicit-any vi.spyOn((Packer as any).compiler, "compile").mockReturnValue({ - // tslint:disable-next-line: no-empty generateAsync: () => vi.fn(), }); const str = await Packer.toBlob(file); @@ -167,7 +166,6 @@ describe("Packer", () => { it("should create a standard docx file", async () => { // eslint-disable-next-line @typescript-eslint/no-explicit-any vi.spyOn((Packer as any).compiler, "compile").mockReturnValue({ - // tslint:disable-next-line: no-empty generateAsync: () => Promise.resolve(vi.fn()), }); const stream = Packer.toStream(file); diff --git a/src/export/packer/packer.ts b/src/export/packer/packer.ts index 4f1bc534583..78dff25943c 100644 --- a/src/export/packer/packer.ts +++ b/src/export/packer/packer.ts @@ -1,4 +1,5 @@ import { Stream } from "stream"; + import { File } from "@file/file"; import { Compiler } from "./next-compiler"; @@ -10,7 +11,7 @@ export const PrettifyType = { NONE: "", WITH_2_BLANKS: " ", WITH_4_BLANKS: " ", - // eslint-disable-next-line @typescript-eslint/naming-convention + WITH_TAB: "\t", } as const; diff --git a/src/file/app-properties/app-properties.ts b/src/file/app-properties/app-properties.ts index 7774a155b17..715d95fa1d2 100644 --- a/src/file/app-properties/app-properties.ts +++ b/src/file/app-properties/app-properties.ts @@ -1,4 +1,5 @@ import { XmlComponent } from "@file/xml-components"; + import { AppPropertiesAttributes } from "./app-properties-attributes"; export class AppProperties extends XmlComponent { diff --git a/src/file/border/border.ts b/src/file/border/border.ts index 5b76390af5b..55942c25952 100644 --- a/src/file/border/border.ts +++ b/src/file/border/border.ts @@ -22,7 +22,7 @@ import { XmlAttributeComponent, XmlComponent } from "@file/xml-components"; import { eighthPointMeasureValue, hexColorValue, pointMeasureValue } from "@util/values"; -export interface IBorderOptions { +export type IBorderOptions = { readonly style: (typeof BorderStyle)[keyof typeof BorderStyle]; /** Border color, in hex (eg 'FF00AA') */ readonly color?: string; @@ -30,7 +30,7 @@ export interface IBorderOptions { readonly size?: number; /** Spacing offset. Values are specified in pt */ readonly space?: number; -} +}; export class BorderElement extends XmlComponent { public constructor(elementName: string, { color, size, space, style }: IBorderOptions) { @@ -55,7 +55,6 @@ class BordersAttributes extends XmlAttributeComponent { }; } -/* eslint-disable @typescript-eslint/naming-convention */ export const BorderStyle = { SINGLE: "single", DASH_DOT_STROKED: "dashDotStroked", @@ -85,4 +84,3 @@ export const BorderStyle = { TRIPLE: "triple", WAVE: "wave", } as const; -/* eslint-enable */ diff --git a/src/file/checkbox/checkbox-util.spec.ts b/src/file/checkbox/checkbox-util.spec.ts index 74fc74b8204..bc696acd9d6 100644 --- a/src/file/checkbox/checkbox-util.spec.ts +++ b/src/file/checkbox/checkbox-util.spec.ts @@ -1,5 +1,7 @@ import { describe, expect, it } from "vitest"; + import { Formatter } from "@export/formatter"; + import { CheckBoxUtil } from "."; describe("CheckBoxUtil", () => { diff --git a/src/file/checkbox/checkbox-util.ts b/src/file/checkbox/checkbox-util.ts index d6abb2a3b3e..010405e4363 100644 --- a/src/file/checkbox/checkbox-util.ts +++ b/src/file/checkbox/checkbox-util.ts @@ -7,20 +7,20 @@ // // -import { XmlComponent } from "@file/xml-components"; import { CheckBoxSymbolElement } from "@file/checkbox/checkbox-symbol"; +import { XmlComponent } from "@file/xml-components"; -export interface ICheckboxSymbolProperties { +export type ICheckboxSymbolProperties = { readonly value?: string; readonly font?: string; -} +}; -export interface ICheckboxSymbolOptions { +export type ICheckboxSymbolOptions = { readonly alias?: string; readonly checked?: boolean; readonly checkedState?: ICheckboxSymbolProperties; readonly uncheckedState?: ICheckboxSymbolProperties; -} +}; export class CheckBoxUtil extends XmlComponent { private readonly DEFAULT_UNCHECKED_SYMBOL: string = "2610"; diff --git a/src/file/checkbox/checkbox.spec.ts b/src/file/checkbox/checkbox.spec.ts index e6553ac4590..f546cd6a73a 100644 --- a/src/file/checkbox/checkbox.spec.ts +++ b/src/file/checkbox/checkbox.spec.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from "vitest"; + import { Formatter } from "@export/formatter"; import { CheckBox } from "./checkbox"; diff --git a/src/file/checkbox/checkbox.ts b/src/file/checkbox/checkbox.ts index 9b75ee7f6cc..bd6a28fb870 100644 --- a/src/file/checkbox/checkbox.ts +++ b/src/file/checkbox/checkbox.ts @@ -1,7 +1,8 @@ import { SymbolRun } from "@file/paragraph/run/symbol-run"; -import { StructuredDocumentTagProperties } from "@file/table-of-contents/sdt-properties"; import { StructuredDocumentTagContent } from "@file/table-of-contents/sdt-content"; +import { StructuredDocumentTagProperties } from "@file/table-of-contents/sdt-properties"; import { XmlComponent } from "@file/xml-components"; + import { CheckBoxUtil, ICheckboxSymbolOptions } from "./checkbox-util"; export class CheckBox extends XmlComponent { diff --git a/src/file/content-types/content-types.spec.ts b/src/file/content-types/content-types.spec.ts index 1fac77993ec..cf78cb68092 100644 --- a/src/file/content-types/content-types.spec.ts +++ b/src/file/content-types/content-types.spec.ts @@ -1,5 +1,3 @@ -// tslint:disable:no-string-literal - import { beforeEach, describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; diff --git a/src/file/content-types/content-types.ts b/src/file/content-types/content-types.ts index fc7cc8a8b0e..8107e2525c7 100644 --- a/src/file/content-types/content-types.ts +++ b/src/file/content-types/content-types.ts @@ -1,4 +1,5 @@ import { XmlComponent } from "@file/xml-components"; + import { ContentTypeAttributes } from "./content-types-attributes"; import { Default } from "./default/default"; import { Override } from "./override/override"; diff --git a/src/file/content-types/default/default.ts b/src/file/content-types/default/default.ts index 775300258c7..eba4d9e1499 100644 --- a/src/file/content-types/default/default.ts +++ b/src/file/content-types/default/default.ts @@ -1,4 +1,5 @@ import { XmlComponent } from "@file/xml-components"; + import { DefaultAttributes } from "./default-attributes"; export class Default extends XmlComponent { diff --git a/src/file/content-types/override/override.ts b/src/file/content-types/override/override.ts index d28a40e4734..511edd95a66 100644 --- a/src/file/content-types/override/override.ts +++ b/src/file/content-types/override/override.ts @@ -1,4 +1,5 @@ import { XmlComponent } from "@file/xml-components"; + import { OverrideAttributes } from "./override-attributes"; export class Override extends XmlComponent { diff --git a/src/file/core-properties/properties.spec.ts b/src/file/core-properties/properties.spec.ts index 133cc3e858c..40dad1db535 100644 --- a/src/file/core-properties/properties.spec.ts +++ b/src/file/core-properties/properties.spec.ts @@ -45,7 +45,7 @@ describe("Properties", () => { expect(tree["cp:coreProperties"]).to.be.an.instanceof(Array); // eslint-disable-next-line @typescript-eslint/no-explicit-any - const key = (obj: { readonly [key: string]: any }) => Object.keys(obj)[0]; + const key = (obj: Readonly>) => Object.keys(obj)[0]; expect(tree["cp:coreProperties"].map(key)).to.include.members([ "_attr", "cp:keywords", diff --git a/src/file/core-properties/properties.ts b/src/file/core-properties/properties.ts index d51b1f23b7b..97ab0623169 100644 --- a/src/file/core-properties/properties.ts +++ b/src/file/core-properties/properties.ts @@ -1,19 +1,18 @@ +import { FontOptions } from "@file/fonts/font-table"; import { ICommentsOptions } from "@file/paragraph/run/comment-run"; import { ICompatibilityOptions } from "@file/settings/compatibility"; -import { FontOptions } from "@file/fonts/font-table"; import { StringContainer, XmlComponent } from "@file/xml-components"; import { dateTimeValue } from "@util/values"; import { ICustomPropertyOptions } from "../custom-properties"; import { IDocumentBackgroundOptions } from "../document"; - import { DocumentAttributes } from "../document/document-attributes"; import { ISectionOptions } from "../file"; import { INumberingOptions } from "../numbering"; import { Paragraph } from "../paragraph"; import { IStylesOptions } from "../styles"; -export interface IPropertiesOptions { +export type IPropertiesOptions = { readonly sections: readonly ISectionOptions[]; readonly title?: string; readonly subject?: string; @@ -26,11 +25,14 @@ export interface IPropertiesOptions { readonly styles?: IStylesOptions; readonly numbering?: INumberingOptions; readonly comments?: ICommentsOptions; - readonly footnotes?: { - readonly [key: string]: { - readonly children: readonly Paragraph[]; - }; - }; + readonly footnotes?: Readonly< + Record< + string, + { + readonly children: readonly Paragraph[]; + } + > + >; readonly background?: IDocumentBackgroundOptions; readonly features?: { readonly trackRevisions?: boolean; @@ -42,7 +44,7 @@ export interface IPropertiesOptions { readonly evenAndOddHeaderAndFooters?: boolean; readonly defaultTabStop?: number; readonly fonts?: readonly FontOptions[]; -} +}; // diff --git a/src/file/custom-properties/custom-properties.ts b/src/file/custom-properties/custom-properties.ts index c85a02ef74f..f24dcaa12a4 100644 --- a/src/file/custom-properties/custom-properties.ts +++ b/src/file/custom-properties/custom-properties.ts @@ -1,4 +1,5 @@ import { IContext, IXmlableObject, XmlComponent } from "@file/xml-components"; + import { CustomPropertiesAttributes } from "./custom-properties-attributes"; import { CustomProperty, ICustomPropertyOptions } from "./custom-property"; diff --git a/src/file/custom-properties/custom-property.ts b/src/file/custom-properties/custom-property.ts index 65e926ad4a3..c72de03e339 100644 --- a/src/file/custom-properties/custom-property.ts +++ b/src/file/custom-properties/custom-property.ts @@ -1,10 +1,11 @@ import { XmlComponent } from "@file/xml-components"; + import { CustomPropertyAttributes } from "./custom-property-attributes"; -export interface ICustomPropertyOptions { +export type ICustomPropertyOptions = { readonly name: string; readonly value: string; -} +}; export class CustomProperty extends XmlComponent { public constructor(id: number, properties: ICustomPropertyOptions) { diff --git a/src/file/document-wrapper.ts b/src/file/document-wrapper.ts index e60b2a19274..578ac2d048a 100644 --- a/src/file/document-wrapper.ts +++ b/src/file/document-wrapper.ts @@ -1,14 +1,14 @@ -import { XmlComponent } from "./xml-components"; import { Document, IDocumentOptions } from "./document"; import { Footer } from "./footer/footer"; import { FootNotes } from "./footnotes"; import { Header } from "./header/header"; import { Relationships } from "./relationships"; +import { XmlComponent } from "./xml-components"; -export interface IViewWrapper { +export type IViewWrapper = { readonly View: Document | Footer | Header | FootNotes | XmlComponent; readonly Relationships: Relationships; -} +}; export class DocumentWrapper implements IViewWrapper { private readonly document: Document; diff --git a/src/file/document/body/section-properties/properties/columns.ts b/src/file/document/body/section-properties/properties/columns.ts index 8cf204d1a66..628c01a8b91 100644 --- a/src/file/document/body/section-properties/properties/columns.ts +++ b/src/file/document/body/section-properties/properties/columns.ts @@ -1,5 +1,5 @@ import { NextAttributeComponent, XmlComponent } from "@file/xml-components"; -import { decimalNumber, PositiveUniversalMeasure, twipsMeasureValue } from "@util/values"; +import { PositiveUniversalMeasure, decimalNumber, twipsMeasureValue } from "@util/values"; import { Column } from "./column"; diff --git a/src/file/document/body/section-properties/properties/doc-grid.ts b/src/file/document/body/section-properties/properties/doc-grid.ts index e7ddbe6a775..e9f086045a8 100644 --- a/src/file/document/body/section-properties/properties/doc-grid.ts +++ b/src/file/document/body/section-properties/properties/doc-grid.ts @@ -17,7 +17,6 @@ import { decimalNumber } from "@util/values"; // // -/* eslint-disable @typescript-eslint/naming-convention */ export const DocumentGridType = { DEFAULT: "default", LINES: "lines", @@ -25,12 +24,11 @@ export const DocumentGridType = { SNAP_TO_CHARS: "snapToChars", } as const; -/* eslint-enable */ -export interface IDocGridAttributesProperties { +export type IDocGridAttributesProperties = { readonly type?: (typeof DocumentGridType)[keyof typeof DocumentGridType]; readonly linePitch?: number; readonly charSpace?: number; -} +}; export class DocGridAttributes extends XmlAttributeComponent { protected readonly xmlKeys = { diff --git a/src/file/document/body/section-properties/properties/header-footer-reference.spec.ts b/src/file/document/body/section-properties/properties/header-footer-reference.spec.ts index 84f3d131f9c..f996b4d8891 100644 --- a/src/file/document/body/section-properties/properties/header-footer-reference.spec.ts +++ b/src/file/document/body/section-properties/properties/header-footer-reference.spec.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; + import { HeaderFooterReference, HeaderFooterReferenceType, HeaderFooterType } from "./header-footer-reference"; describe("HeaderFooterReference", () => { diff --git a/src/file/document/body/section-properties/properties/header-footer-reference.ts b/src/file/document/body/section-properties/properties/header-footer-reference.ts index ab7b4f44c0e..ee8a45a2268 100644 --- a/src/file/document/body/section-properties/properties/header-footer-reference.ts +++ b/src/file/document/body/section-properties/properties/header-footer-reference.ts @@ -32,10 +32,10 @@ export const HeaderFooterReferenceType = { // // -export interface IHeaderFooterOptions { +export type IHeaderFooterOptions = { readonly type?: (typeof HeaderFooterReferenceType)[keyof typeof HeaderFooterReferenceType]; readonly id?: number; -} +}; class FooterReferenceAttributes extends XmlAttributeComponent<{ readonly type: (typeof HeaderFooterReferenceType)[keyof typeof HeaderFooterReferenceType]; diff --git a/src/file/document/body/section-properties/properties/line-number.ts b/src/file/document/body/section-properties/properties/line-number.ts index 3c71597fd69..50bfd17ce05 100644 --- a/src/file/document/body/section-properties/properties/line-number.ts +++ b/src/file/document/body/section-properties/properties/line-number.ts @@ -1,6 +1,6 @@ // http://officeopenxml.com/WPsectionLineNumbering.php import { BuilderElement, XmlComponent } from "@file/xml-components"; -import { decimalNumber, PositiveUniversalMeasure, twipsMeasureValue } from "@util/values"; +import { PositiveUniversalMeasure, decimalNumber, twipsMeasureValue } from "@util/values"; // // @@ -10,13 +10,11 @@ import { decimalNumber, PositiveUniversalMeasure, twipsMeasureValue } from "@uti // // -/* eslint-disable @typescript-eslint/naming-convention */ export const LineNumberRestartFormat = { NEW_PAGE: "newPage", NEW_SECTION: "newSection", CONTINUOUS: "continuous", } as const; -/* eslint-enable */ // // diff --git a/src/file/document/body/section-properties/properties/page-borders.spec.ts b/src/file/document/body/section-properties/properties/page-borders.spec.ts index 8890ca0eeef..2b983d5f17b 100644 --- a/src/file/document/body/section-properties/properties/page-borders.spec.ts +++ b/src/file/document/body/section-properties/properties/page-borders.spec.ts @@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; import { BorderStyle } from "@file/border"; -import { PageBorderDisplay, PageBorders, PageBorderZOrder } from "./page-borders"; +import { PageBorderDisplay, PageBorderZOrder, PageBorders } from "./page-borders"; describe("PageBorders", () => { describe("#constructor()", () => { diff --git a/src/file/document/body/section-properties/properties/page-borders.ts b/src/file/document/body/section-properties/properties/page-borders.ts index e7fe557da57..e597cac61ba 100644 --- a/src/file/document/body/section-properties/properties/page-borders.ts +++ b/src/file/document/body/section-properties/properties/page-borders.ts @@ -10,13 +10,11 @@ import { IgnoreIfEmptyXmlComponent, XmlAttributeComponent } from "@file/xml-comp // // -/* eslint-disable @typescript-eslint/naming-convention */ export const PageBorderDisplay = { ALL_PAGES: "allPages", FIRST_PAGE: "firstPage", NOT_FIRST_PAGE: "notFirstPage", } as const; -/* eslint-enable */ // // @@ -40,19 +38,19 @@ export const PageBorderZOrder = { FRONT: "front", } as const; -export interface IPageBorderAttributes { +export type IPageBorderAttributes = { readonly display?: (typeof PageBorderDisplay)[keyof typeof PageBorderDisplay]; readonly offsetFrom?: (typeof PageBorderOffsetFrom)[keyof typeof PageBorderOffsetFrom]; readonly zOrder?: (typeof PageBorderZOrder)[keyof typeof PageBorderZOrder]; -} +}; -export interface IPageBordersOptions { +export type IPageBordersOptions = { readonly pageBorders?: IPageBorderAttributes; readonly pageBorderTop?: IBorderOptions; readonly pageBorderRight?: IBorderOptions; readonly pageBorderBottom?: IBorderOptions; readonly pageBorderLeft?: IBorderOptions; -} +}; class PageBordersAttributes extends XmlAttributeComponent { protected readonly xmlKeys = { diff --git a/src/file/document/body/section-properties/properties/page-margin.ts b/src/file/document/body/section-properties/properties/page-margin.ts index 5e905c0f733..03378a0db2f 100644 --- a/src/file/document/body/section-properties/properties/page-margin.ts +++ b/src/file/document/body/section-properties/properties/page-margin.ts @@ -1,5 +1,5 @@ import { NextAttributeComponent, XmlComponent } from "@file/xml-components"; -import { PositiveUniversalMeasure, signedTwipsMeasureValue, twipsMeasureValue, UniversalMeasure } from "@util/values"; +import { PositiveUniversalMeasure, UniversalMeasure, signedTwipsMeasureValue, twipsMeasureValue } from "@util/values"; // // diff --git a/src/file/document/body/section-properties/properties/page-number.ts b/src/file/document/body/section-properties/properties/page-number.ts index cf93ea13552..055349d0ece 100644 --- a/src/file/document/body/section-properties/properties/page-number.ts +++ b/src/file/document/body/section-properties/properties/page-number.ts @@ -13,7 +13,6 @@ import { decimalNumber } from "@util/values"; // // -/* eslint-disable @typescript-eslint/naming-convention */ export const PageNumberSeparator = { HYPHEN: "hyphen", PERIOD: "period", @@ -22,13 +21,11 @@ export const PageNumberSeparator = { EN_DASH: "endash", } as const; -/* eslint-enable */ - -export interface IPageNumberTypeAttributes { +export type IPageNumberTypeAttributes = { readonly start?: number; readonly formatType?: (typeof NumberFormat)[keyof typeof NumberFormat]; readonly separator?: (typeof PageNumberSeparator)[keyof typeof PageNumberSeparator]; -} +}; // // diff --git a/src/file/document/body/section-properties/properties/page-text-direction.spec.ts b/src/file/document/body/section-properties/properties/page-text-direction.spec.ts index e1a690d66c5..e4c1c870952 100644 --- a/src/file/document/body/section-properties/properties/page-text-direction.spec.ts +++ b/src/file/document/body/section-properties/properties/page-text-direction.spec.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; + import { PageTextDirection, PageTextDirectionType } from "./page-text-direction"; describe("PageTextDirection", () => { diff --git a/src/file/document/body/section-properties/properties/page-text-direction.ts b/src/file/document/body/section-properties/properties/page-text-direction.ts index b5b71c03da4..ee883e3f1e3 100644 --- a/src/file/document/body/section-properties/properties/page-text-direction.ts +++ b/src/file/document/body/section-properties/properties/page-text-direction.ts @@ -1,13 +1,10 @@ import { XmlAttributeComponent, XmlComponent } from "@file/xml-components"; -/* eslint-disable @typescript-eslint/naming-convention */ export const PageTextDirectionType = { LEFT_TO_RIGHT_TOP_TO_BOTTOM: "lrTb", TOP_TO_BOTTOM_RIGHT_TO_LEFT: "tbRl", } as const; -/* eslint-enable */ - class PageTextDirectionAttributes extends XmlAttributeComponent<{ readonly val: (typeof PageTextDirectionType)[keyof typeof PageTextDirectionType]; }> { diff --git a/src/file/document/body/section-properties/properties/section-type.spec.ts b/src/file/document/body/section-properties/properties/section-type.spec.ts index 644e6d568f2..068d657a27a 100644 --- a/src/file/document/body/section-properties/properties/section-type.spec.ts +++ b/src/file/document/body/section-properties/properties/section-type.spec.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; + import { SectionType, Type } from "./section-type"; describe("Type", () => { diff --git a/src/file/document/body/section-properties/properties/section-type.ts b/src/file/document/body/section-properties/properties/section-type.ts index 4b3a5ea6a95..e56a4c45a91 100644 --- a/src/file/document/body/section-properties/properties/section-type.ts +++ b/src/file/document/body/section-properties/properties/section-type.ts @@ -11,7 +11,6 @@ import { XmlAttributeComponent, XmlComponent } from "@file/xml-components"; // // -/* eslint-disable @typescript-eslint/naming-convention */ export const SectionType = { NEXT_PAGE: "nextPage", NEXT_COLUMN: "nextColumn", @@ -19,7 +18,6 @@ export const SectionType = { EVEN_PAGE: "evenPage", ODD_PAGE: "oddPage", } as const; -/* eslint-enable */ // // diff --git a/src/file/document/body/section-properties/section-properties.spec.ts b/src/file/document/body/section-properties/section-properties.spec.ts index cefee6d8304..a31d2723b8b 100644 --- a/src/file/document/body/section-properties/section-properties.spec.ts +++ b/src/file/document/body/section-properties/section-properties.spec.ts @@ -15,7 +15,7 @@ import { LineNumberRestartFormat } from "./properties/line-number"; import { PageBorderOffsetFrom } from "./properties/page-borders"; import { PageTextDirectionType } from "./properties/page-text-direction"; import { SectionType } from "./properties/section-type"; -import { sectionMarginDefaults, sectionPageSizeDefaults, SectionProperties } from "./section-properties"; +import { SectionProperties, sectionMarginDefaults, sectionPageSizeDefaults } from "./section-properties"; const DEFAULT_MARGINS = { "w:bottom": sectionMarginDefaults.BOTTOM, diff --git a/src/file/document/body/section-properties/section-properties.ts b/src/file/document/body/section-properties/section-properties.ts index 2e9c61819ba..3a83945691f 100644 --- a/src/file/document/body/section-properties/section-properties.ts +++ b/src/file/document/body/section-properties/section-properties.ts @@ -1,14 +1,13 @@ // http://officeopenxml.com/WPsection.php -// tslint:disable: no-unnecessary-initializer import { FooterWrapper } from "@file/footer-wrapper"; import { HeaderWrapper } from "@file/header-wrapper"; import { VerticalAlign, VerticalAlignElement } from "@file/vertical-align"; import { OnOffElement, XmlComponent } from "@file/xml-components"; -import { HeaderFooterReference, HeaderFooterReferenceType, HeaderFooterType } from "./properties/header-footer-reference"; import { Columns, IColumnsAttributes } from "./properties/columns"; import { DocumentGrid, IDocGridAttributesProperties } from "./properties/doc-grid"; +import { HeaderFooterReference, HeaderFooterReferenceType, HeaderFooterType } from "./properties/header-footer-reference"; import { ILineNumberAttributes, createLineNumberType } from "./properties/line-number"; import { IPageBordersOptions, PageBorders } from "./properties/page-borders"; import { IPageMarginAttributes, PageMargin } from "./properties/page-margin"; @@ -17,13 +16,13 @@ import { IPageSizeAttributes, PageOrientation, PageSize } from "./properties/pag import { PageTextDirection, PageTextDirectionType } from "./properties/page-text-direction"; import { SectionType, Type } from "./properties/section-type"; -export interface IHeaderFooterGroup { +export type IHeaderFooterGroup = { readonly default?: T; readonly first?: T; readonly even?: T; -} +}; -export interface ISectionPropertiesOptions { +export type ISectionPropertiesOptions = { readonly page?: { readonly size?: IPageSizeAttributes; readonly margin?: IPageMarginAttributes; @@ -39,7 +38,7 @@ export interface ISectionPropertiesOptions { readonly verticalAlign?: (typeof VerticalAlign)[keyof typeof VerticalAlign]; readonly column?: IColumnsAttributes; readonly type?: (typeof SectionType)[keyof typeof SectionType]; -} +}; // // diff --git a/src/file/document/document-attributes.ts b/src/file/document/document-attributes.ts index e919fa3de51..996763d7920 100644 --- a/src/file/document/document-attributes.ts +++ b/src/file/document/document-attributes.ts @@ -1,7 +1,7 @@ import { XmlAttributeComponent } from "@file/xml-components"; /* cSpell:disable */ -export interface IDocumentAttributesProperties { +export type IDocumentAttributesProperties = { readonly wpc?: string; readonly mc?: string; readonly o?: string; @@ -41,7 +41,7 @@ export interface IDocumentAttributesProperties { readonly w16?: string; readonly w16sdtdh?: string; readonly w16se?: string; -} +}; /* cSpell:enable */ export class DocumentAttributes extends XmlAttributeComponent { diff --git a/src/file/document/document-background/document-background.ts b/src/file/document/document-background/document-background.ts index a769065632c..c3d3143ca0e 100644 --- a/src/file/document/document-background/document-background.ts +++ b/src/file/document/document-background/document-background.ts @@ -39,12 +39,12 @@ export class DocumentBackgroundAttributes extends XmlAttributeComponent<{ }; } -export interface IDocumentBackgroundOptions { +export type IDocumentBackgroundOptions = { readonly color?: string; readonly themeColor?: string; readonly themeShade?: string; readonly themeTint?: string; -} +}; // // diff --git a/src/file/document/document.ts b/src/file/document/document.ts index e1b098d9cb5..f233d932c81 100644 --- a/src/file/document/document.ts +++ b/src/file/document/document.ts @@ -1,5 +1,6 @@ // http://officeopenxml.com/WPdocument.php import { XmlComponent } from "@file/xml-components"; + import { ConcreteHyperlink, Paragraph } from "../paragraph"; import { Table } from "../table"; import { TableOfContents } from "../table-of-contents"; @@ -7,9 +8,9 @@ import { Body } from "./body"; import { DocumentAttributes } from "./document-attributes"; import { DocumentBackground, IDocumentBackgroundOptions } from "./document-background"; -export interface IDocumentOptions { +export type IDocumentOptions = { readonly background?: IDocumentBackgroundOptions; -} +}; // // @@ -80,7 +81,6 @@ export class Document extends XmlComponent { } public add(item: Paragraph | Table | TableOfContents | ConcreteHyperlink): Document { - // eslint-disable-next-line functional/immutable-data this.body.push(item); return this; } diff --git a/src/file/drawing/anchor/anchor-attributes.ts b/src/file/drawing/anchor/anchor-attributes.ts index 2e4ca7a33d8..8d3210fdea6 100644 --- a/src/file/drawing/anchor/anchor-attributes.ts +++ b/src/file/drawing/anchor/anchor-attributes.ts @@ -1,14 +1,15 @@ import { XmlAttributeComponent } from "@file/xml-components"; + import { IDistance } from "../drawing"; -export interface IAnchorAttributes extends IDistance { +export type IAnchorAttributes = { readonly allowOverlap?: "0" | "1"; readonly behindDoc?: "0" | "1"; readonly layoutInCell?: "0" | "1"; readonly locked?: "0" | "1"; readonly relativeHeight?: number; readonly simplePos?: "0" | "1"; -} +} & IDistance; export class AnchorAttributes extends XmlAttributeComponent { protected readonly xmlKeys = { diff --git a/src/file/drawing/anchor/anchor.spec.ts b/src/file/drawing/anchor/anchor.spec.ts index ab0c9cb4010..b5f5f2e3e35 100644 --- a/src/file/drawing/anchor/anchor.spec.ts +++ b/src/file/drawing/anchor/anchor.spec.ts @@ -1,7 +1,6 @@ import { assert, describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; - import { Utility } from "tests/utility"; import { IDrawingOptions } from "../drawing"; diff --git a/src/file/drawing/anchor/anchor.ts b/src/file/drawing/anchor/anchor.ts index e674e4ce20f..2d4ba1aa204 100644 --- a/src/file/drawing/anchor/anchor.ts +++ b/src/file/drawing/anchor/anchor.ts @@ -1,6 +1,7 @@ // http://officeopenxml.com/drwPicFloating.php import { IMediaData, IMediaDataTransformation } from "@file/media"; import { XmlComponent } from "@file/xml-components"; + import { IDrawingOptions } from "../drawing"; import { HorizontalPosition, IFloating, SimplePos, VerticalPosition } from "../floating"; import { Graphic } from "../inline/graphic"; diff --git a/src/file/drawing/doc-properties/doc-properties.ts b/src/file/drawing/doc-properties/doc-properties.ts index 5df1497bb5a..242bcdea426 100644 --- a/src/file/drawing/doc-properties/doc-properties.ts +++ b/src/file/drawing/doc-properties/doc-properties.ts @@ -1,7 +1,6 @@ // https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_docPr_topic_ID0ES32OB.html -import { IContext, IXmlableObject, NextAttributeComponent, XmlComponent } from "@file/xml-components"; import { ConcreteHyperlink } from "@file/paragraph"; - +import { IContext, IXmlableObject, NextAttributeComponent, XmlComponent } from "@file/xml-components"; import { docPropertiesUniqueNumericIdGen } from "@util/convenience-functions"; import { createHyperlinkClick } from "./doc-properties-children"; @@ -18,11 +17,11 @@ import { createHyperlinkClick } from "./doc-properties-children"; // // -export interface DocPropertiesOptions { +export type DocPropertiesOptions = { readonly name: string; readonly description: string; readonly title: string; -} +}; export class DocProperties extends XmlComponent { private readonly docPropertiesUniqueNumericId = docPropertiesUniqueNumericIdGen(); diff --git a/src/file/drawing/drawing.spec.ts b/src/file/drawing/drawing.spec.ts index 73bb1fcd154..c2bc794a646 100644 --- a/src/file/drawing/drawing.spec.ts +++ b/src/file/drawing/drawing.spec.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from "vitest"; -import { IContext } from "@file/xml-components"; import { Formatter } from "@export/formatter"; +import { IContext } from "@file/xml-components"; import { ConcreteHyperlink, TextRun } from "../"; import { Drawing, IDrawingOptions } from "./drawing"; @@ -80,7 +80,6 @@ describe("Drawing", () => { { "a:graphicFrameLocks": { _attr: { - // tslint:disable-next-line:object-literal-key-quotes noChangeAspect: 1, "xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main", }, @@ -139,7 +138,6 @@ describe("Drawing", () => { { "a:blip": { _attr: { - // tslint:disable-next-line:object-literal-key-quotes cstate: "none", "r:embed": "rId{test.jpg}", }, @@ -311,7 +309,6 @@ describe("Drawing", () => { { "a:graphicFrameLocks": { _attr: { - // tslint:disable-next-line:object-literal-key-quotes noChangeAspect: 1, "xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main", }, @@ -370,7 +367,6 @@ describe("Drawing", () => { { "a:blip": { _attr: { - // tslint:disable-next-line:object-literal-key-quotes cstate: "none", "r:embed": "rId{test.jpg}", }, @@ -554,7 +550,6 @@ describe("Drawing", () => { { "a:graphicFrameLocks": { _attr: { - // tslint:disable-next-line:object-literal-key-quotes noChangeAspect: 1, "xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main", }, @@ -622,7 +617,6 @@ describe("Drawing", () => { { "a:blip": { _attr: { - // tslint:disable-next-line:object-literal-key-quotes cstate: "none", "r:embed": "rId{test.jpg}", }, diff --git a/src/file/drawing/drawing.ts b/src/file/drawing/drawing.ts index 3664da15a2c..2e6cf991fa9 100644 --- a/src/file/drawing/drawing.ts +++ b/src/file/drawing/drawing.ts @@ -14,11 +14,11 @@ export type IDistance = { readonly distR?: number; }; -export interface IDrawingOptions { +export type IDrawingOptions = { readonly floating?: IFloating; readonly docProperties?: DocPropertiesOptions; readonly outline?: OutlineOptions; -} +}; // // diff --git a/src/file/drawing/floating/floating-position.ts b/src/file/drawing/floating/floating-position.ts index 9d3cf27397b..dc4b7fb8e53 100644 --- a/src/file/drawing/floating/floating-position.ts +++ b/src/file/drawing/floating/floating-position.ts @@ -4,7 +4,6 @@ import { HorizontalPositionAlign, VerticalPositionAlign } from "@file/shared/ali import { ITextWrapping } from "../text-wrap"; -/* eslint-disable @typescript-eslint/naming-convention */ export const HorizontalPositionRelativeFrom = { CHARACTER: "character", COLUMN: "column", @@ -27,27 +26,26 @@ export const VerticalPositionRelativeFrom = { TOP_MARGIN: "topMargin", } as const; -/* eslint-enable */ -export interface IHorizontalPositionOptions { +export type IHorizontalPositionOptions = { readonly relative?: (typeof HorizontalPositionRelativeFrom)[keyof typeof HorizontalPositionRelativeFrom]; readonly align?: (typeof HorizontalPositionAlign)[keyof typeof HorizontalPositionAlign]; readonly offset?: number; -} +}; -export interface IVerticalPositionOptions { +export type IVerticalPositionOptions = { readonly relative?: (typeof VerticalPositionRelativeFrom)[keyof typeof VerticalPositionRelativeFrom]; readonly align?: (typeof VerticalPositionAlign)[keyof typeof VerticalPositionAlign]; readonly offset?: number; -} +}; -export interface IMargins { +export type IMargins = { readonly left?: number; readonly bottom?: number; readonly top?: number; readonly right?: number; -} +}; -export interface IFloating { +export type IFloating = { readonly horizontalPosition: IHorizontalPositionOptions; readonly verticalPosition: IVerticalPositionOptions; readonly allowOverlap?: boolean; @@ -57,4 +55,4 @@ export interface IFloating { readonly margins?: IMargins; readonly wrap?: ITextWrapping; readonly zIndex?: number; -} +}; diff --git a/src/file/drawing/floating/horizontal-position.ts b/src/file/drawing/floating/horizontal-position.ts index 10b36ba7789..0cdc495c5bb 100644 --- a/src/file/drawing/floating/horizontal-position.ts +++ b/src/file/drawing/floating/horizontal-position.ts @@ -1,5 +1,6 @@ // http://officeopenxml.com/drwPicFloating-position.php import { XmlAttributeComponent, XmlComponent } from "@file/xml-components"; + import { Align } from "./align"; import { HorizontalPositionRelativeFrom, IHorizontalPositionOptions } from "./floating-position"; import { PositionOffset } from "./position-offset"; diff --git a/src/file/drawing/floating/vertical-position.ts b/src/file/drawing/floating/vertical-position.ts index 01e41344533..855a1f43b40 100644 --- a/src/file/drawing/floating/vertical-position.ts +++ b/src/file/drawing/floating/vertical-position.ts @@ -1,5 +1,6 @@ // http://officeopenxml.com/drwPicFloating-position.php import { XmlAttributeComponent, XmlComponent } from "@file/xml-components"; + import { Align } from "./align"; import { IVerticalPositionOptions, VerticalPositionRelativeFrom } from "./floating-position"; import { PositionOffset } from "./position-offset"; diff --git a/src/file/drawing/graphic-frame/graphic-frame-locks/graphic-frame-locks.ts b/src/file/drawing/graphic-frame/graphic-frame-locks/graphic-frame-locks.ts index c9b0b339220..c22a603d8c1 100644 --- a/src/file/drawing/graphic-frame/graphic-frame-locks/graphic-frame-locks.ts +++ b/src/file/drawing/graphic-frame/graphic-frame-locks/graphic-frame-locks.ts @@ -1,4 +1,5 @@ import { XmlComponent } from "@file/xml-components"; + import { GraphicFrameLockAttributes } from "./graphic-frame-lock-attributes"; export class GraphicFrameLocks extends XmlComponent { diff --git a/src/file/drawing/graphic-frame/graphic-frame-properties.ts b/src/file/drawing/graphic-frame/graphic-frame-properties.ts index 90935ed5333..03d0cd2728e 100644 --- a/src/file/drawing/graphic-frame/graphic-frame-properties.ts +++ b/src/file/drawing/graphic-frame/graphic-frame-properties.ts @@ -1,4 +1,5 @@ import { XmlComponent } from "@file/xml-components"; + import { GraphicFrameLocks } from "./graphic-frame-locks/graphic-frame-locks"; export class GraphicFrameProperties extends XmlComponent { diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/blip/blip-extentions.ts b/src/file/drawing/inline/graphic/graphic-data/pic/blip/blip-extentions.ts index 909d87f80b6..e15c132c58d 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/blip/blip-extentions.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/blip/blip-extentions.ts @@ -1,5 +1,5 @@ -import { BuilderElement, XmlComponent } from "@file/xml-components"; import { IMediaData } from "@file/media"; +import { BuilderElement, XmlComponent } from "@file/xml-components"; const createSvgBlip = (mediaData: IMediaData): XmlComponent => new BuilderElement({ diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/blip/blip.ts b/src/file/drawing/inline/graphic/graphic-data/pic/blip/blip.ts index d3222727379..e57274c3739 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/blip/blip.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/blip/blip.ts @@ -1,5 +1,6 @@ import { IMediaData } from "@file/media"; import { BuilderElement, XmlComponent } from "@file/xml-components"; + import { createExtentionList } from "./blip-extentions"; type BlipAttributes = { diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/child-non-visual-pic-properties/child-non-visual-pic-properties.ts b/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/child-non-visual-pic-properties/child-non-visual-pic-properties.ts index 979272cf8f0..18ca70c711f 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/child-non-visual-pic-properties/child-non-visual-pic-properties.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/child-non-visual-pic-properties/child-non-visual-pic-properties.ts @@ -1,4 +1,5 @@ import { XmlComponent } from "@file/xml-components"; + import { PicLocks } from "./pic-locks/pic-locks"; export class ChildNonVisualProperties extends XmlComponent { diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/child-non-visual-pic-properties/pic-locks/pic-locks.ts b/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/child-non-visual-pic-properties/pic-locks/pic-locks.ts index b507c8e7b12..594b3da7552 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/child-non-visual-pic-properties/pic-locks/pic-locks.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/child-non-visual-pic-properties/pic-locks/pic-locks.ts @@ -1,4 +1,5 @@ import { XmlComponent } from "@file/xml-components"; + import { PicLocksAttributes } from "./pic-locks-attributes"; export class PicLocks extends XmlComponent { diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-pic-properties.ts b/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-pic-properties.ts index a5bc3c24dde..6e28a27e133 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-pic-properties.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-pic-properties.ts @@ -1,4 +1,5 @@ import { XmlComponent } from "@file/xml-components"; + import { ChildNonVisualProperties } from "./child-non-visual-pic-properties/child-non-visual-pic-properties"; import { NonVisualProperties } from "./non-visual-properties/non-visual-properties"; diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-properties/non-visual-properties.ts b/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-properties/non-visual-properties.ts index 31842356c0a..880b79dcab6 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-properties/non-visual-properties.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/non-visual-pic-properties/non-visual-properties/non-visual-properties.ts @@ -1,6 +1,6 @@ -import { IContext, IXmlableObject, XmlComponent } from "@file/xml-components"; import { createHyperlinkClick } from "@file/drawing/doc-properties/doc-properties-children"; import { ConcreteHyperlink } from "@file/paragraph"; +import { IContext, IXmlableObject, XmlComponent } from "@file/xml-components"; import { NonVisualPropertiesAttributes } from "./non-visual-properties-attributes"; diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/pic.ts b/src/file/drawing/inline/graphic/graphic-data/pic/pic.ts index e05c6aa15a3..da43e86f0ad 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/pic.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/pic.ts @@ -5,8 +5,8 @@ import { XmlComponent } from "@file/xml-components"; import { BlipFill } from "./blip/blip-fill"; import { NonVisualPicProperties } from "./non-visual-pic-properties/non-visual-pic-properties"; import { PicAttributes } from "./pic-attributes"; -import { ShapeProperties } from "./shape-properties/shape-properties"; import { OutlineOptions } from "./shape-properties/outline/outline"; +import { ShapeProperties } from "./shape-properties/shape-properties"; export class Pic extends XmlComponent { public constructor({ diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form.spec.ts b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form.spec.ts index 2e032a1638a..8b24f7d4345 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form.spec.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form.spec.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; + import { Form } from "./form/form"; describe("Form", () => { diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/extents/extents.ts b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/extents/extents.ts index b87cbe5d83f..4aa40e8a025 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/extents/extents.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/extents/extents.ts @@ -1,5 +1,6 @@ // http://officeopenxml.com/drwSp-size.php import { XmlComponent } from "@file/xml-components"; + import { ExtentsAttributes } from "./extents-attributes"; export class Extents extends XmlComponent { diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/offset/off.ts b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/offset/off.ts index eef5b9e0f8a..ab0ab07f77b 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/offset/off.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/offset/off.ts @@ -1,5 +1,6 @@ // http://officeopenxml.com/drwSp-size.php import { XmlComponent } from "@file/xml-components"; + import { OffsetAttributes } from "./off-attributes"; export class Offset extends XmlComponent { diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/outline/outline.ts b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/outline/outline.ts index ed274299d12..05e21c74643 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/outline/outline.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/outline/outline.ts @@ -1,8 +1,9 @@ // http://officeopenxml.com/drwSp-outline.php import { BuilderElement, XmlComponent } from "@file/xml-components"; + import { createNoFill } from "./no-fill"; -import { createSolidFill } from "./solid-fill"; import { SchemeColor } from "./scheme-color"; +import { createSolidFill } from "./solid-fill"; // // diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/outline/solid-fill.spec.ts b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/outline/solid-fill.spec.ts index e66a53c4fe9..2436a8f1cdf 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/outline/solid-fill.spec.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/outline/solid-fill.spec.ts @@ -2,8 +2,8 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; -import { createSolidFill } from "./solid-fill"; import { SchemeColor } from "./scheme-color"; +import { createSolidFill } from "./solid-fill"; describe("createSolidFill", () => { it("should create of rgb", () => { diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/outline/solid-fill.ts b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/outline/solid-fill.ts index ee3d58777a9..aa8ec9c1775 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/outline/solid-fill.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/outline/solid-fill.ts @@ -1,7 +1,7 @@ import { BuilderElement, XmlComponent } from "@file/xml-components"; -import { createSchemeColor, SchemeColor } from "./scheme-color"; import { createSolidRgbColor } from "./rgb-color"; +import { SchemeColor, createSchemeColor } from "./scheme-color"; export type RgbColorOptions = { readonly type: "rgb"; diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/preset-geometry/preset-geometry.ts b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/preset-geometry/preset-geometry.ts index 816bdedcda4..8b38aa18428 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/preset-geometry/preset-geometry.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/preset-geometry/preset-geometry.ts @@ -1,5 +1,6 @@ // http://officeopenxml.com/drwSp-prstGeom.php import { XmlComponent } from "@file/xml-components"; + import { AdjustmentValues } from "./adjustment-values/adjustment-values"; import { PresetGeometryAttributes } from "./preset-geometry-attributes"; diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/shape-properties.ts b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/shape-properties.ts index 8b9effc44d9..fb00d37eaa2 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/shape-properties.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/shape-properties.ts @@ -1,11 +1,12 @@ // http://officeopenxml.com/drwSp-SpPr.php import { IMediaDataTransformation } from "@file/media"; import { XmlComponent } from "@file/xml-components"; + import { Form } from "./form"; +import { createNoFill } from "./outline/no-fill"; import { OutlineOptions, createOutline } from "./outline/outline"; import { PresetGeometry } from "./preset-geometry/preset-geometry"; import { ShapePropertiesAttributes } from "./shape-properties-attributes"; -import { createNoFill } from "./outline/no-fill"; export class ShapeProperties extends XmlComponent { private readonly form: Form; diff --git a/src/file/drawing/inline/inline.spec.ts b/src/file/drawing/inline/inline.spec.ts index 1d2a7915074..09c89e71009 100644 --- a/src/file/drawing/inline/inline.spec.ts +++ b/src/file/drawing/inline/inline.spec.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; + import { createInline } from "./inline"; describe("Inline", () => { diff --git a/src/file/drawing/inline/inline.ts b/src/file/drawing/inline/inline.ts index e752c9faa52..09959210b31 100644 --- a/src/file/drawing/inline/inline.ts +++ b/src/file/drawing/inline/inline.ts @@ -1,6 +1,7 @@ // http://officeopenxml.com/drwPicInline.php import { IMediaData, IMediaDataTransformation } from "@file/media"; import { BuilderElement, XmlComponent } from "@file/xml-components"; + import { DocProperties, DocPropertiesOptions } from "./../doc-properties/doc-properties"; import { createEffectExtent } from "./../effect-extent/effect-extent"; import { Extent } from "./../extent/extent"; diff --git a/src/file/drawing/text-wrap/text-wrapping.ts b/src/file/drawing/text-wrap/text-wrapping.ts index 9ea1f200386..0c82f86134a 100644 --- a/src/file/drawing/text-wrap/text-wrapping.ts +++ b/src/file/drawing/text-wrap/text-wrapping.ts @@ -1,7 +1,6 @@ // http://officeopenxml.com/drwPicFloating-textWrap.php import { IDistance } from "../drawing"; -/* eslint-disable @typescript-eslint/naming-convention */ export const TextWrappingType = { NONE: 0, SQUARE: 1, @@ -16,10 +15,8 @@ export const TextWrappingSide = { LARGEST: "largest", } as const; -/* eslint-enable */ - -export interface ITextWrapping { +export type ITextWrapping = { readonly type: (typeof TextWrappingType)[keyof typeof TextWrappingType]; readonly side?: (typeof TextWrappingSide)[keyof typeof TextWrappingSide]; readonly margins?: IDistance; -} +}; diff --git a/src/file/drawing/text-wrap/wrap-square.ts b/src/file/drawing/text-wrap/wrap-square.ts index 3f0b7d3907c..f9b1a13e990 100644 --- a/src/file/drawing/text-wrap/wrap-square.ts +++ b/src/file/drawing/text-wrap/wrap-square.ts @@ -5,9 +5,9 @@ import { IDistance } from "../drawing"; import { IMargins } from "../floating"; import { ITextWrapping, TextWrappingSide } from "./text-wrapping"; -interface IWrapSquareAttributes extends IDistance { +type IWrapSquareAttributes = { readonly wrapText?: (typeof TextWrappingSide)[keyof typeof TextWrappingSide]; -} +} & IDistance; class WrapSquareAttributes extends XmlAttributeComponent { protected readonly xmlKeys = { diff --git a/src/file/file.ts b/src/file/file.ts index 47dd895166c..cc7c5f51d5b 100644 --- a/src/file/file.ts +++ b/src/file/file.ts @@ -2,8 +2,10 @@ import { AppProperties } from "./app-properties/app-properties"; import { ContentTypes } from "./content-types/content-types"; import { CoreProperties, IPropertiesOptions } from "./core-properties"; import { CustomProperties } from "./custom-properties"; -import { DocumentWrapper } from "./document-wrapper"; import { HeaderFooterReferenceType, ISectionPropertiesOptions } from "./document/body/section-properties"; +import { DocumentWrapper } from "./document-wrapper"; +import { FileChild } from "./file-child"; +import { FontWrapper } from "./fonts/font-wrapper"; import { FooterWrapper, IDocumentFooter } from "./footer-wrapper"; import { FootnotesWrapper } from "./footnotes-wrapper"; import { Footer, Header } from "./header"; @@ -16,10 +18,8 @@ import { Settings } from "./settings"; import { Styles } from "./styles"; import { ExternalStylesFactory } from "./styles/external-styles-factory"; import { DefaultStylesFactory } from "./styles/factory"; -import { FileChild } from "./file-child"; -import { FontWrapper } from "./fonts/font-wrapper"; -export interface ISectionOptions { +export type ISectionOptions = { readonly headers?: { readonly default?: Header; readonly first?: Header; @@ -32,7 +32,7 @@ export interface ISectionOptions { }; readonly properties?: ISectionPropertiesOptions; readonly children: readonly FileChild[]; -} +}; export class File { // eslint-disable-next-line functional/prefer-readonly-type diff --git a/src/file/fonts/font-table.ts b/src/file/fonts/font-table.ts index fce632a9e28..b3dc461e903 100644 --- a/src/file/fonts/font-table.ts +++ b/src/file/fonts/font-table.ts @@ -1,8 +1,8 @@ import { BuilderElement, XmlComponent } from "@file/xml-components"; import { createRegularFont } from "./create-regular-font"; -import { FontOptionsWithKey } from "./font-wrapper"; import { CharacterSet } from "./font"; +import { FontOptionsWithKey } from "./font-wrapper"; // // diff --git a/src/file/fonts/font.ts b/src/file/fonts/font.ts index 618bcd62938..8a62c0018d4 100644 --- a/src/file/fonts/font.ts +++ b/src/file/fonts/font.ts @@ -1,4 +1,4 @@ -import { BuilderElement, createStringElement, OnOffElement, XmlComponent } from "@file/xml-components"; +import { BuilderElement, OnOffElement, XmlComponent, createStringElement } from "@file/xml-components"; // // @@ -27,7 +27,7 @@ import { BuilderElement, createStringElement, OnOffElement, XmlComponent } from // // http://www.datypic.com/sc/ooxml/e-w_embedRegular-1.html -export interface IFontRelationshipOptions { +export type IFontRelationshipOptions = { /** * Relationship to Part */ @@ -40,7 +40,7 @@ export interface IFontRelationshipOptions { * Embedded Font Is Subsetted */ readonly subsetted?: boolean; -} +}; export const CharacterSet = { ANSI: "00", diff --git a/src/file/footer-wrapper.ts b/src/file/footer-wrapper.ts index 8b4958ad5f6..cb078f1a8a3 100644 --- a/src/file/footer-wrapper.ts +++ b/src/file/footer-wrapper.ts @@ -8,10 +8,10 @@ import { Paragraph } from "./paragraph"; import { Relationships } from "./relationships"; import { Table } from "./table"; -export interface IDocumentFooter { +export type IDocumentFooter = { readonly footer: FooterWrapper; readonly type: (typeof HeaderFooterReferenceType)[keyof typeof HeaderFooterReferenceType]; -} +}; export class FooterWrapper implements IViewWrapper { private readonly footer: Footer; diff --git a/src/file/footer/footer.ts b/src/file/footer/footer.ts index fc1607466b5..71f69eefe48 100644 --- a/src/file/footer/footer.ts +++ b/src/file/footer/footer.ts @@ -1,5 +1,6 @@ // http://officeopenxml.com/WPfooters.php import { InitializableXmlComponent, XmlComponent } from "@file/xml-components"; + import { Paragraph } from "../paragraph"; import { Table } from "../table"; import { FooterAttributes } from "./footer-attributes"; diff --git a/src/file/footnotes/footnote/footnote.ts b/src/file/footnotes/footnote/footnote.ts index fc87a3013bf..011ae53c1ee 100644 --- a/src/file/footnotes/footnote/footnote.ts +++ b/src/file/footnotes/footnote/footnote.ts @@ -6,15 +6,15 @@ import { FootnoteRefRun } from "./run/footnote-ref-run"; export const FootnoteType = { SEPERATOR: "separator", - // eslint-disable-next-line @typescript-eslint/naming-convention + CONTINUATION_SEPERATOR: "continuationSeparator", } as const; -export interface IFootnoteOptions { +export type IFootnoteOptions = { readonly id: number; readonly type?: (typeof FootnoteType)[keyof typeof FootnoteType]; readonly children: readonly Paragraph[]; -} +}; export class Footnote extends XmlComponent { public constructor(options: IFootnoteOptions) { diff --git a/src/file/footnotes/footnote/run/continuation-seperator-run.ts b/src/file/footnotes/footnote/run/continuation-seperator-run.ts index e70f24f70e1..722a2bf385c 100644 --- a/src/file/footnotes/footnote/run/continuation-seperator-run.ts +++ b/src/file/footnotes/footnote/run/continuation-seperator-run.ts @@ -1,4 +1,5 @@ import { Run } from "@file/paragraph"; + import { ContinuationSeperator } from "./continuation-seperator"; export class ContinuationSeperatorRun extends Run { diff --git a/src/file/footnotes/footnote/run/seperator-run.ts b/src/file/footnotes/footnote/run/seperator-run.ts index 45ce385884e..9f0a12eae41 100644 --- a/src/file/footnotes/footnote/run/seperator-run.ts +++ b/src/file/footnotes/footnote/run/seperator-run.ts @@ -1,4 +1,5 @@ import { Run } from "@file/paragraph"; + import { Seperator } from "./seperator"; export class SeperatorRun extends Run { diff --git a/src/file/header-wrapper.ts b/src/file/header-wrapper.ts index fc7d824f0f5..880d9131b4e 100644 --- a/src/file/header-wrapper.ts +++ b/src/file/header-wrapper.ts @@ -8,10 +8,10 @@ import { Paragraph } from "./paragraph"; import { Relationships } from "./relationships"; import { Table } from "./table"; -export interface IDocumentHeader { +export type IDocumentHeader = { readonly header: HeaderWrapper; readonly type: (typeof HeaderFooterReferenceType)[keyof typeof HeaderFooterReferenceType]; -} +}; export class HeaderWrapper implements IViewWrapper { private readonly header: Header; diff --git a/src/file/header.ts b/src/file/header.ts index 76f008ed767..b76952d8ea9 100644 --- a/src/file/header.ts +++ b/src/file/header.ts @@ -1,9 +1,9 @@ import { Paragraph } from "./paragraph"; import { Table } from "./table"; -export interface IHeaderOptions { +export type IHeaderOptions = { readonly children: readonly (Paragraph | Table)[]; -} +}; export class Header { public readonly options: IHeaderOptions; diff --git a/src/file/header/header.ts b/src/file/header/header.ts index e1f65eadbe8..08b6ab12dd4 100644 --- a/src/file/header/header.ts +++ b/src/file/header/header.ts @@ -1,5 +1,6 @@ // http://officeopenxml.com/WPheaders.php import { InitializableXmlComponent, XmlComponent } from "@file/xml-components"; + import { Paragraph } from "../paragraph"; import { Table } from "../table"; import { HeaderAttributes } from "./header-attributes"; diff --git a/src/file/media/data.ts b/src/file/media/data.ts index 1cdd76f2a7c..7024c74e4b5 100644 --- a/src/file/media/data.ts +++ b/src/file/media/data.ts @@ -1,4 +1,4 @@ -export interface IMediaDataTransformation { +export type IMediaDataTransformation = { readonly pixels: { readonly x: number; readonly y: number; @@ -12,7 +12,7 @@ export interface IMediaDataTransformation { readonly horizontal?: boolean; }; readonly rotation?: number; -} +}; type CoreMediaData = { readonly fileName: string; diff --git a/src/file/media/media.spec.ts b/src/file/media/media.spec.ts index 8cc0d0f741b..871bdbcc8c6 100644 --- a/src/file/media/media.spec.ts +++ b/src/file/media/media.spec.ts @@ -1,4 +1,3 @@ -// tslint:disable:object-literal-key-quotes import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import * as convenienceFunctions from "@util/convenience-functions"; diff --git a/src/file/media/media.ts b/src/file/media/media.ts index 64787380254..6007658721b 100644 --- a/src/file/media/media.ts +++ b/src/file/media/media.ts @@ -1,6 +1,6 @@ import { IMediaData } from "./data"; -export interface IMediaTransformation { +export type IMediaTransformation = { readonly width: number; readonly height: number; readonly flip?: { @@ -8,7 +8,7 @@ export interface IMediaTransformation { readonly horizontal?: boolean; }; readonly rotation?: number; -} +}; export class Media { // eslint-disable-next-line functional/prefer-readonly-type diff --git a/src/file/numbering/abstract-numbering.spec.ts b/src/file/numbering/abstract-numbering.spec.ts index cad3f52feeb..77a3dd7b948 100644 --- a/src/file/numbering/abstract-numbering.spec.ts +++ b/src/file/numbering/abstract-numbering.spec.ts @@ -3,8 +3,8 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; import { AlignmentType, EmphasisMarkType, TabStopPosition } from "../paragraph"; -import { UnderlineType } from "../paragraph/run/underline"; import { HighlightColor } from "../paragraph/run/properties"; +import { UnderlineType } from "../paragraph/run/underline"; import { ShadingType } from "../shading"; import { AbstractNumbering } from "./abstract-numbering"; import { LevelFormat, LevelSuffix } from "./level"; diff --git a/src/file/numbering/level.ts b/src/file/numbering/level.ts index fb0040f609e..e9744e8937f 100644 --- a/src/file/numbering/level.ts +++ b/src/file/numbering/level.ts @@ -202,7 +202,7 @@ export const LevelSuffix = { TAB: "tab", } as const; -export interface ILevelsOptions { +export type ILevelsOptions = { readonly level: number; readonly format?: (typeof LevelFormat)[keyof typeof LevelFormat]; readonly text?: string; @@ -214,7 +214,7 @@ export interface ILevelsOptions { readonly run?: IRunStylePropertiesOptions; readonly paragraph?: ILevelParagraphStylePropertiesOptions; }; -} +}; // // diff --git a/src/file/numbering/num.ts b/src/file/numbering/num.ts index 597f7530d1d..41d16d60a58 100644 --- a/src/file/numbering/num.ts +++ b/src/file/numbering/num.ts @@ -18,18 +18,18 @@ class NumAttributes extends XmlAttributeComponent<{ protected readonly xmlKeys = { numId: "w:numId" }; } -interface IOverrideLevel { +type IOverrideLevel = { readonly num: number; readonly start?: number; -} +}; -export interface IConcreteNumberingOptions { +export type IConcreteNumberingOptions = { readonly numId: number; readonly abstractNumId: number; readonly reference: string; readonly instance: number; readonly overrideLevels?: readonly IOverrideLevel[]; -} +}; // // ... diff --git a/src/file/numbering/numbering.ts b/src/file/numbering/numbering.ts index daf9ca38c78..81efdd83f61 100644 --- a/src/file/numbering/numbering.ts +++ b/src/file/numbering/numbering.ts @@ -4,17 +4,17 @@ import { AlignmentType } from "@file/paragraph"; import { IContext, IXmlableObject, XmlComponent } from "@file/xml-components"; import { abstractNumUniqueNumericIdGen, concreteNumUniqueNumericIdGen, convertInchesToTwip } from "@util/convenience-functions"; -import { DocumentAttributes } from "../document/document-attributes"; import { AbstractNumbering } from "./abstract-numbering"; import { ILevelsOptions, LevelFormat } from "./level"; import { ConcreteNumbering } from "./num"; +import { DocumentAttributes } from "../document/document-attributes"; -export interface INumberingOptions { +export type INumberingOptions = { readonly config: readonly { readonly levels: readonly ILevelsOptions[]; readonly reference: string; }[]; -} +}; // // diff --git a/src/file/paragraph/formatting/alignment.spec.ts b/src/file/paragraph/formatting/alignment.spec.ts index 34048190f69..3042faacc79 100644 --- a/src/file/paragraph/formatting/alignment.spec.ts +++ b/src/file/paragraph/formatting/alignment.spec.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; + import { Alignment, AlignmentType } from "./alignment"; describe("Alignment", () => { diff --git a/src/file/paragraph/formatting/alignment.ts b/src/file/paragraph/formatting/alignment.ts index cfd9f8fbaac..ea99505fbe2 100644 --- a/src/file/paragraph/formatting/alignment.ts +++ b/src/file/paragraph/formatting/alignment.ts @@ -20,7 +20,6 @@ import { XmlAttributeComponent, XmlComponent } from "@file/xml-components"; // // -/* eslint-disable @typescript-eslint/naming-convention */ export const AlignmentType = { /** Align Start */ START: "start", @@ -50,8 +49,6 @@ export const AlignmentType = { JUSTIFIED: "both", } as const; -/* eslint-enable */ - export class AlignmentAttributes extends XmlAttributeComponent<{ readonly val: (typeof AlignmentType)[keyof typeof AlignmentType]; }> { diff --git a/src/file/paragraph/formatting/border.spec.ts b/src/file/paragraph/formatting/border.spec.ts index e6ab032facb..43dafe5e7d1 100644 --- a/src/file/paragraph/formatting/border.spec.ts +++ b/src/file/paragraph/formatting/border.spec.ts @@ -1,8 +1,8 @@ import { beforeEach, describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; - import { BorderStyle } from "@file/border"; + import { Border, ThematicBreak } from "./border"; describe("Border", () => { diff --git a/src/file/paragraph/formatting/border.ts b/src/file/paragraph/formatting/border.ts index 9cef69b6b28..fec72546c60 100644 --- a/src/file/paragraph/formatting/border.ts +++ b/src/file/paragraph/formatting/border.ts @@ -2,12 +2,12 @@ import { BorderElement, BorderStyle, IBorderOptions } from "@file/border"; import { IgnoreIfEmptyXmlComponent, XmlComponent } from "@file/xml-components"; -export interface IBordersOptions { +export type IBordersOptions = { readonly top?: IBorderOptions; readonly bottom?: IBorderOptions; readonly left?: IBorderOptions; readonly right?: IBorderOptions; -} +}; export class Border extends IgnoreIfEmptyXmlComponent { public constructor(options: IBordersOptions) { diff --git a/src/file/paragraph/formatting/break.ts b/src/file/paragraph/formatting/break.ts index b972ed99708..ccf91d7fc88 100644 --- a/src/file/paragraph/formatting/break.ts +++ b/src/file/paragraph/formatting/break.ts @@ -1,5 +1,6 @@ // http://officeopenxml.com/WPtextSpecialContent-break.php import { Attributes, XmlComponent } from "@file/xml-components"; + import { Run } from "../run"; const BreakType = { diff --git a/src/file/paragraph/formatting/indent.ts b/src/file/paragraph/formatting/indent.ts index 059cf9c2a96..68913c4ff0b 100644 --- a/src/file/paragraph/formatting/indent.ts +++ b/src/file/paragraph/formatting/indent.ts @@ -1,15 +1,15 @@ // http://officeopenxml.com/WPindentation.php import { NextAttributeComponent, XmlComponent } from "@file/xml-components"; -import { PositiveUniversalMeasure, signedTwipsMeasureValue, twipsMeasureValue, UniversalMeasure } from "@util/values"; +import { PositiveUniversalMeasure, UniversalMeasure, signedTwipsMeasureValue, twipsMeasureValue } from "@util/values"; -export interface IIndentAttributesProperties { +export type IIndentAttributesProperties = { readonly start?: number | UniversalMeasure; readonly end?: number | UniversalMeasure; readonly left?: number | UniversalMeasure; readonly right?: number | UniversalMeasure; readonly hanging?: number | PositiveUniversalMeasure; readonly firstLine?: number | PositiveUniversalMeasure; -} +}; // // diff --git a/src/file/paragraph/formatting/spacing.ts b/src/file/paragraph/formatting/spacing.ts index 4403e866f71..a524888f875 100644 --- a/src/file/paragraph/formatting/spacing.ts +++ b/src/file/paragraph/formatting/spacing.ts @@ -2,21 +2,20 @@ import { XmlAttributeComponent, XmlComponent } from "@file/xml-components"; export const LineRuleType = { - // eslint-disable-next-line @typescript-eslint/naming-convention AT_LEAST: "atLeast", EXACTLY: "exactly", EXACT: "exact", AUTO: "auto", } as const; -export interface ISpacingProperties { +export type ISpacingProperties = { readonly after?: number; readonly before?: number; readonly line?: number; readonly lineRule?: (typeof LineRuleType)[keyof typeof LineRuleType]; readonly beforeAutoSpacing?: boolean; readonly afterAutoSpacing?: boolean; -} +}; class SpacingAttributes extends XmlAttributeComponent { protected readonly xmlKeys = { diff --git a/src/file/paragraph/formatting/tab-stop.ts b/src/file/paragraph/formatting/tab-stop.ts index 20e7ec841c9..f69370d0454 100644 --- a/src/file/paragraph/formatting/tab-stop.ts +++ b/src/file/paragraph/formatting/tab-stop.ts @@ -1,11 +1,11 @@ // http://officeopenxml.com/WPtab.php import { XmlAttributeComponent, XmlComponent } from "@file/xml-components"; -export interface TabStopDefinition { +export type TabStopDefinition = { readonly type: (typeof TabStopType)[keyof typeof TabStopType]; readonly position: number | (typeof TabStopPosition)[keyof typeof TabStopPosition]; readonly leader?: (typeof LeaderType)[keyof typeof LeaderType]; -} +}; export class TabStop extends XmlComponent { public constructor(tabDefinitions: readonly TabStopDefinition[]) { @@ -32,7 +32,7 @@ export const TabStopType = { export const LeaderType = { DOT: "dot", HYPHEN: "hyphen", - // eslint-disable-next-line @typescript-eslint/naming-convention + MIDDLE_DOT: "middleDot", NONE: "none", UNDERSCORE: "underscore", diff --git a/src/file/paragraph/frame/frame-properties.ts b/src/file/paragraph/frame/frame-properties.ts index b72ced9f5fd..ea248257206 100644 --- a/src/file/paragraph/frame/frame-properties.ts +++ b/src/file/paragraph/frame/frame-properties.ts @@ -19,13 +19,13 @@ export const FrameWrap = { AROUND: "around", AUTO: "auto", NONE: "none", - // eslint-disable-next-line @typescript-eslint/naming-convention + NOT_BESIDE: "notBeside", THROUGH: "through", TIGHT: "tight", } as const; -interface IBaseFrameOptions { +type IBaseFrameOptions = { readonly anchorLock?: boolean; readonly dropCap?: (typeof DropCapType)[keyof typeof DropCapType]; readonly width: number; @@ -41,23 +41,23 @@ interface IBaseFrameOptions { readonly vertical: number; }; readonly rule?: (typeof HeightRule)[keyof typeof HeightRule]; -} +}; -export interface IXYFrameOptions extends IBaseFrameOptions { +export type IXYFrameOptions = { readonly type: "absolute"; readonly position: { readonly x: number; readonly y: number; }; -} +} & IBaseFrameOptions; -export interface IAlignmentFrameOptions extends IBaseFrameOptions { +export type IAlignmentFrameOptions = { readonly type: "alignment"; readonly alignment: { readonly x: (typeof HorizontalPositionAlign)[keyof typeof HorizontalPositionAlign]; readonly y: (typeof VerticalPositionAlign)[keyof typeof VerticalPositionAlign]; }; -} +} & IBaseFrameOptions; // Be wary of Typescript's Open types: // https://stackoverflow.com/q/46370222/3481582 diff --git a/src/file/paragraph/links/hyperlink-attributes.ts b/src/file/paragraph/links/hyperlink-attributes.ts index c31f943ce02..28c884cebaa 100644 --- a/src/file/paragraph/links/hyperlink-attributes.ts +++ b/src/file/paragraph/links/hyperlink-attributes.ts @@ -1,10 +1,10 @@ import { XmlAttributeComponent } from "@file/xml-components"; -export interface IHyperlinkAttributesProperties { +export type IHyperlinkAttributesProperties = { readonly id?: string; readonly anchor?: string; readonly history: number; -} +}; export class HyperlinkAttributes extends XmlAttributeComponent { protected readonly xmlKeys = { diff --git a/src/file/paragraph/links/pageref-field-instruction.spec.ts b/src/file/paragraph/links/pageref-field-instruction.spec.ts index ece399a385a..3a5dc227c84 100644 --- a/src/file/paragraph/links/pageref-field-instruction.spec.ts +++ b/src/file/paragraph/links/pageref-field-instruction.spec.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; + import { PageReferenceFieldInstruction } from "./pageref-field-instruction"; describe("PageReference field instruction", () => { diff --git a/src/file/paragraph/links/pageref-field-instruction.ts b/src/file/paragraph/links/pageref-field-instruction.ts index 4006549b6c0..da1ca03bfb8 100644 --- a/src/file/paragraph/links/pageref-field-instruction.ts +++ b/src/file/paragraph/links/pageref-field-instruction.ts @@ -1,8 +1,8 @@ import { SpaceType } from "@file/shared"; import { XmlComponent } from "@file/xml-components"; -import { TextAttributes } from "../run/text-attributes"; import { IPageReferenceOptions } from "./pageref"; +import { TextAttributes } from "../run/text-attributes"; export class PageReferenceFieldInstruction extends XmlComponent { public constructor(bookmarkId: string, options: IPageReferenceOptions = {}) { diff --git a/src/file/paragraph/links/pageref.spec.ts b/src/file/paragraph/links/pageref.spec.ts index ae214bfbc57..25b748dca9e 100644 --- a/src/file/paragraph/links/pageref.spec.ts +++ b/src/file/paragraph/links/pageref.spec.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; + import { PageReference } from "./pageref"; describe("PageReference", () => { diff --git a/src/file/paragraph/links/pageref.ts b/src/file/paragraph/links/pageref.ts index 6137aa92a8f..9305f0f305a 100644 --- a/src/file/paragraph/links/pageref.ts +++ b/src/file/paragraph/links/pageref.ts @@ -1,5 +1,6 @@ // See https://www.ecma-international.org/publications/standards/Ecma-376.htm (at Part 1, Page 1234) import { Begin, End } from "@file/paragraph/run/field"; + import { Run } from "../run"; import { PageReferenceFieldInstruction } from "./pageref-field-instruction"; diff --git a/src/file/paragraph/math/fraction/math-fraction.ts b/src/file/paragraph/math/fraction/math-fraction.ts index e18d92d9857..85e7afaf822 100644 --- a/src/file/paragraph/math/fraction/math-fraction.ts +++ b/src/file/paragraph/math/fraction/math-fraction.ts @@ -4,10 +4,10 @@ import { MathComponent } from "../math-component"; import { MathDenominator } from "./math-denominator"; import { MathNumerator } from "./math-numerator"; -export interface IMathFractionOptions { +export type IMathFractionOptions = { readonly numerator: readonly MathComponent[]; readonly denominator: readonly MathComponent[]; -} +}; export class MathFraction extends XmlComponent { public constructor(options: IMathFractionOptions) { diff --git a/src/file/paragraph/math/function/math-function-name.ts b/src/file/paragraph/math/function/math-function-name.ts index c6984bce02e..1a02f4ccb2f 100644 --- a/src/file/paragraph/math/function/math-function-name.ts +++ b/src/file/paragraph/math/function/math-function-name.ts @@ -1,5 +1,6 @@ // http://www.datypic.com/sc/ooxml/e-m_fName-1.html import { XmlComponent } from "@file/xml-components"; + import { MathComponent } from "../math-component"; export class MathFunctionName extends XmlComponent { diff --git a/src/file/paragraph/math/function/math-function.ts b/src/file/paragraph/math/function/math-function.ts index 307c8c43903..fff5fa2868f 100644 --- a/src/file/paragraph/math/function/math-function.ts +++ b/src/file/paragraph/math/function/math-function.ts @@ -6,10 +6,10 @@ import { MathBase } from "../n-ary"; import { MathFunctionName } from "./math-function-name"; import { MathFunctionProperties } from "./math-function-properties"; -export interface IMathFunctionOptions { +export type IMathFunctionOptions = { readonly children: readonly MathComponent[]; readonly name: readonly MathComponent[]; -} +}; export class MathFunction extends XmlComponent { public constructor(options: IMathFunctionOptions) { diff --git a/src/file/paragraph/math/math-component.ts b/src/file/paragraph/math/math-component.ts index ae30a7d3c68..dc148d8f84e 100644 --- a/src/file/paragraph/math/math-component.ts +++ b/src/file/paragraph/math/math-component.ts @@ -2,7 +2,7 @@ import { MathAngledBrackets, MathCurlyBrackets, MathRoundBrackets, MathSquareBra import { MathFraction } from "./fraction"; import { MathFunction } from "./function"; import { MathRun } from "./math-run"; -import { MathSum, MathIntegral } from "./n-ary"; +import { MathIntegral, MathSum } from "./n-ary"; import { MathRadical } from "./radical"; import { MathSubScript, MathSubSuperScript, MathSuperScript } from "./script"; diff --git a/src/file/paragraph/math/math.ts b/src/file/paragraph/math/math.ts index d0d3bcca411..187b92a95b3 100644 --- a/src/file/paragraph/math/math.ts +++ b/src/file/paragraph/math/math.ts @@ -3,9 +3,9 @@ import { XmlComponent } from "@file/xml-components"; import { MathComponent } from "./math-component"; -export interface IMathOptions { +export type IMathOptions = { readonly children: readonly MathComponent[]; -} +}; export class Math extends XmlComponent { public constructor(options: IMathOptions) { diff --git a/src/file/paragraph/math/n-ary/math-integral.ts b/src/file/paragraph/math/n-ary/math-integral.ts index 55d0cbbcea9..03d251e2805 100644 --- a/src/file/paragraph/math/n-ary/math-integral.ts +++ b/src/file/paragraph/math/n-ary/math-integral.ts @@ -6,11 +6,11 @@ import { MathNAryProperties } from "./math-n-ary-properties"; import { MathSubScriptElement } from "./math-sub-script"; import { MathSuperScriptElement } from "./math-super-script"; -export interface IMathIntegralOptions { +export type IMathIntegralOptions = { readonly children: readonly MathComponent[]; readonly subScript?: readonly MathComponent[]; readonly superScript?: readonly MathComponent[]; -} +}; export class MathIntegral extends XmlComponent { public constructor(options: IMathIntegralOptions) { diff --git a/src/file/paragraph/math/n-ary/math-limit-lower.ts b/src/file/paragraph/math/n-ary/math-limit-lower.ts index 0227694cba8..ce272a6557a 100644 --- a/src/file/paragraph/math/n-ary/math-limit-lower.ts +++ b/src/file/paragraph/math/n-ary/math-limit-lower.ts @@ -1,13 +1,14 @@ // http://www.datypic.com/sc/ooxml/e-m_limLow-1.html import { XmlComponent } from "@file/xml-components"; + import { MathComponent } from "../math-component"; import { MathBase } from "./math-base"; import { MathLimit } from "./math-limit"; -export interface IMathLimitLowerOptions { +export type IMathLimitLowerOptions = { readonly children: readonly MathComponent[]; readonly limit: readonly MathComponent[]; -} +}; export class MathLimitLower extends XmlComponent { public constructor(options: IMathLimitLowerOptions) { diff --git a/src/file/paragraph/math/n-ary/math-limit-upper.ts b/src/file/paragraph/math/n-ary/math-limit-upper.ts index d292c6db629..bb70a36f62a 100644 --- a/src/file/paragraph/math/n-ary/math-limit-upper.ts +++ b/src/file/paragraph/math/n-ary/math-limit-upper.ts @@ -1,13 +1,14 @@ // http://www.datypic.com/sc/ooxml/e-m_limUpp-1.html import { XmlComponent } from "@file/xml-components"; + import { MathComponent } from "../math-component"; import { MathBase } from "./math-base"; import { MathLimit } from "./math-limit"; -export interface IMathLimitUpperOptions { +export type IMathLimitUpperOptions = { readonly children: readonly MathComponent[]; readonly limit: readonly MathComponent[]; -} +}; export class MathLimitUpper extends XmlComponent { public constructor(options: IMathLimitUpperOptions) { diff --git a/src/file/paragraph/math/n-ary/math-limit.ts b/src/file/paragraph/math/n-ary/math-limit.ts index f66a54bc5c9..0827ff80a4b 100644 --- a/src/file/paragraph/math/n-ary/math-limit.ts +++ b/src/file/paragraph/math/n-ary/math-limit.ts @@ -1,5 +1,6 @@ // http://www.datypic.com/sc/ooxml/e-m_lim-1.html import { XmlComponent } from "@file/xml-components"; + import { MathComponent } from "../math-component"; export class MathLimit extends XmlComponent { diff --git a/src/file/paragraph/math/n-ary/math-sum.ts b/src/file/paragraph/math/n-ary/math-sum.ts index b5d0995147a..a4758e31a69 100644 --- a/src/file/paragraph/math/n-ary/math-sum.ts +++ b/src/file/paragraph/math/n-ary/math-sum.ts @@ -7,11 +7,11 @@ import { MathNAryProperties } from "./math-n-ary-properties"; import { MathSubScriptElement } from "./math-sub-script"; import { MathSuperScriptElement } from "./math-super-script"; -export interface IMathSumOptions { +export type IMathSumOptions = { readonly children: readonly MathComponent[]; readonly subScript?: readonly MathComponent[]; readonly superScript?: readonly MathComponent[]; -} +}; export class MathSum extends XmlComponent { public constructor(options: IMathSumOptions) { diff --git a/src/file/paragraph/math/radical/math-degree.ts b/src/file/paragraph/math/radical/math-degree.ts index 3942159674f..b9e3e0f6476 100644 --- a/src/file/paragraph/math/radical/math-degree.ts +++ b/src/file/paragraph/math/radical/math-degree.ts @@ -1,5 +1,6 @@ // http://www.datypic.com/sc/ooxml/e-m_deg-1.html import { XmlComponent } from "@file/xml-components"; + import { MathComponent } from "../math-component"; export class MathDegree extends XmlComponent { diff --git a/src/file/paragraph/math/radical/math-radical-properties.ts b/src/file/paragraph/math/radical/math-radical-properties.ts index 5bfdb1b3b29..923b975793d 100644 --- a/src/file/paragraph/math/radical/math-radical-properties.ts +++ b/src/file/paragraph/math/radical/math-radical-properties.ts @@ -1,5 +1,6 @@ // http://www.datypic.com/sc/ooxml/e-m_radPr-1.html import { XmlComponent } from "@file/xml-components"; + import { MathDegreeHide } from "./math-degree-hide"; export class MathRadicalProperties extends XmlComponent { diff --git a/src/file/paragraph/math/radical/math-radical.ts b/src/file/paragraph/math/radical/math-radical.ts index 1684024dc11..a42addc9dee 100644 --- a/src/file/paragraph/math/radical/math-radical.ts +++ b/src/file/paragraph/math/radical/math-radical.ts @@ -6,10 +6,10 @@ import { MathBase } from "../n-ary"; import { MathDegree } from "./math-degree"; import { MathRadicalProperties } from "./math-radical-properties"; -export interface IMathRadicalOptions { +export type IMathRadicalOptions = { readonly children: readonly MathComponent[]; readonly degree?: readonly MathComponent[]; -} +}; export class MathRadical extends XmlComponent { public constructor(options: IMathRadicalOptions) { diff --git a/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function-properties.spec.ts b/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function-properties.spec.ts index e91979d61a0..c111997650a 100644 --- a/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function-properties.spec.ts +++ b/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function-properties.spec.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; + import { MathPreSubSuperScriptProperties } from "./math-pre-sub-super-script-function-properties"; describe("MathPreSubSuperScriptProperties", () => { diff --git a/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.spec.ts b/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.spec.ts index 9fff56f5169..2ced225ca44 100644 --- a/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.spec.ts +++ b/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.spec.ts @@ -2,8 +2,8 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; -import { MathRun } from "../../math-run"; import { MathPreSubSuperScript } from "./math-pre-sub-super-script-function"; +import { MathRun } from "../../math-run"; describe("MathPreSubScript", () => { describe("#constructor()", () => { diff --git a/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.ts b/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.ts index 293a308a363..a6a5ee0ef6f 100644 --- a/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.ts +++ b/src/file/paragraph/math/script/pre-sub-super-script/math-pre-sub-super-script-function.ts @@ -1,15 +1,15 @@ // http://www.datypic.com/sc/ooxml/e-m_sPre-1.html import { XmlComponent } from "@file/xml-components"; +import { MathPreSubSuperScriptProperties } from "./math-pre-sub-super-script-function-properties"; import { MathComponent } from "../../math-component"; import { MathBase, MathSubScriptElement, MathSuperScriptElement } from "../../n-ary"; -import { MathPreSubSuperScriptProperties } from "./math-pre-sub-super-script-function-properties"; -export interface IMathPreSubSuperScriptOptions { +export type IMathPreSubSuperScriptOptions = { readonly children: readonly MathComponent[]; readonly subScript: readonly MathComponent[]; readonly superScript: readonly MathComponent[]; -} +}; export class MathPreSubSuperScript extends XmlComponent { public constructor(options: IMathPreSubSuperScriptOptions) { diff --git a/src/file/paragraph/math/script/sub-script/math-sub-script-function-properties.spec.ts b/src/file/paragraph/math/script/sub-script/math-sub-script-function-properties.spec.ts index 81009ce1eb5..3e1899a84ab 100644 --- a/src/file/paragraph/math/script/sub-script/math-sub-script-function-properties.spec.ts +++ b/src/file/paragraph/math/script/sub-script/math-sub-script-function-properties.spec.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; + import { MathSubScriptProperties } from "./math-sub-script-function-properties"; describe("MathSubScriptProperties", () => { diff --git a/src/file/paragraph/math/script/sub-script/math-sub-script-function.spec.ts b/src/file/paragraph/math/script/sub-script/math-sub-script-function.spec.ts index 235ac208985..01bc68962b2 100644 --- a/src/file/paragraph/math/script/sub-script/math-sub-script-function.spec.ts +++ b/src/file/paragraph/math/script/sub-script/math-sub-script-function.spec.ts @@ -2,8 +2,8 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; -import { MathRun } from "../../math-run"; import { MathSubScript } from "./math-sub-script-function"; +import { MathRun } from "../../math-run"; describe("MathSubScript", () => { describe("#constructor()", () => { diff --git a/src/file/paragraph/math/script/sub-script/math-sub-script-function.ts b/src/file/paragraph/math/script/sub-script/math-sub-script-function.ts index e0f70b2089b..ee8185b3e50 100644 --- a/src/file/paragraph/math/script/sub-script/math-sub-script-function.ts +++ b/src/file/paragraph/math/script/sub-script/math-sub-script-function.ts @@ -1,14 +1,14 @@ // http://www.datypic.com/sc/ooxml/e-m_sSub-1.html import { XmlComponent } from "@file/xml-components"; +import { MathSubScriptProperties } from "./math-sub-script-function-properties"; import { MathComponent } from "../../math-component"; import { MathBase, MathSubScriptElement } from "../../n-ary"; -import { MathSubScriptProperties } from "./math-sub-script-function-properties"; -export interface IMathSubScriptOptions { +export type IMathSubScriptOptions = { readonly children: readonly MathComponent[]; readonly subScript: readonly MathComponent[]; -} +}; export class MathSubScript extends XmlComponent { public constructor(options: IMathSubScriptOptions) { diff --git a/src/file/paragraph/math/script/sub-super-script/math-sub-super-script-function-properties.spec.ts b/src/file/paragraph/math/script/sub-super-script/math-sub-super-script-function-properties.spec.ts index 396c6c274b0..ea61bd31e40 100644 --- a/src/file/paragraph/math/script/sub-super-script/math-sub-super-script-function-properties.spec.ts +++ b/src/file/paragraph/math/script/sub-super-script/math-sub-super-script-function-properties.spec.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; + import { MathSubSuperScriptProperties } from "./math-sub-super-script-function-properties"; describe("MathSubSuperScriptProperties", () => { diff --git a/src/file/paragraph/math/script/sub-super-script/math-sub-super-script-function.spec.ts b/src/file/paragraph/math/script/sub-super-script/math-sub-super-script-function.spec.ts index 5a81747462e..34d364f9989 100644 --- a/src/file/paragraph/math/script/sub-super-script/math-sub-super-script-function.spec.ts +++ b/src/file/paragraph/math/script/sub-super-script/math-sub-super-script-function.spec.ts @@ -2,8 +2,8 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; -import { MathRun } from "../../math-run"; import { MathSubSuperScript } from "./math-sub-super-script-function"; +import { MathRun } from "../../math-run"; describe("MathSubScript", () => { describe("#constructor()", () => { diff --git a/src/file/paragraph/math/script/sub-super-script/math-sub-super-script-function.ts b/src/file/paragraph/math/script/sub-super-script/math-sub-super-script-function.ts index 20699561c6f..be64e6efc33 100644 --- a/src/file/paragraph/math/script/sub-super-script/math-sub-super-script-function.ts +++ b/src/file/paragraph/math/script/sub-super-script/math-sub-super-script-function.ts @@ -1,15 +1,15 @@ // http://www.datypic.com/sc/ooxml/e-m_sSubSup-1.html import { XmlComponent } from "@file/xml-components"; +import { MathSubSuperScriptProperties } from "./math-sub-super-script-function-properties"; import { MathComponent } from "../../math-component"; import { MathBase, MathSubScriptElement, MathSuperScriptElement } from "../../n-ary"; -import { MathSubSuperScriptProperties } from "./math-sub-super-script-function-properties"; -export interface IMathSubSuperScriptOptions { +export type IMathSubSuperScriptOptions = { readonly children: readonly MathComponent[]; readonly subScript: readonly MathComponent[]; readonly superScript: readonly MathComponent[]; -} +}; export class MathSubSuperScript extends XmlComponent { public constructor(options: IMathSubSuperScriptOptions) { diff --git a/src/file/paragraph/math/script/super-script/math-super-script-function-properties.spec.ts b/src/file/paragraph/math/script/super-script/math-super-script-function-properties.spec.ts index 0636ef7cd74..bcc2d335126 100644 --- a/src/file/paragraph/math/script/super-script/math-super-script-function-properties.spec.ts +++ b/src/file/paragraph/math/script/super-script/math-super-script-function-properties.spec.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; + import { MathSuperScriptProperties } from "./math-super-script-function-properties"; describe("MathSuperScriptProperties", () => { diff --git a/src/file/paragraph/math/script/super-script/math-super-script-function.spec.ts b/src/file/paragraph/math/script/super-script/math-super-script-function.spec.ts index 28bc6991145..3ed2eb4491e 100644 --- a/src/file/paragraph/math/script/super-script/math-super-script-function.spec.ts +++ b/src/file/paragraph/math/script/super-script/math-super-script-function.spec.ts @@ -2,8 +2,8 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; -import { MathRun } from "../../math-run"; import { MathSuperScript } from "./math-super-script-function"; +import { MathRun } from "../../math-run"; describe("MathSuperScript", () => { describe("#constructor()", () => { diff --git a/src/file/paragraph/math/script/super-script/math-super-script-function.ts b/src/file/paragraph/math/script/super-script/math-super-script-function.ts index 148b64d2fe2..25364fc53b0 100644 --- a/src/file/paragraph/math/script/super-script/math-super-script-function.ts +++ b/src/file/paragraph/math/script/super-script/math-super-script-function.ts @@ -1,14 +1,14 @@ // http://www.datypic.com/sc/ooxml/e-m_sSup-1.html import { XmlComponent } from "@file/xml-components"; +import { MathSuperScriptProperties } from "./math-super-script-function-properties"; import { MathComponent } from "../../math-component"; import { MathBase, MathSuperScriptElement } from "../../n-ary"; -import { MathSuperScriptProperties } from "./math-super-script-function-properties"; -export interface IMathSuperScriptOptions { +export type IMathSuperScriptOptions = { readonly children: readonly MathComponent[]; readonly superScript: readonly MathComponent[]; -} +}; export class MathSuperScript extends XmlComponent { public constructor(options: IMathSuperScriptOptions) { diff --git a/src/file/paragraph/paragraph.spec.ts b/src/file/paragraph/paragraph.spec.ts index 5c49ad0ae7e..e76d2be5197 100644 --- a/src/file/paragraph/paragraph.spec.ts +++ b/src/file/paragraph/paragraph.spec.ts @@ -1,11 +1,10 @@ import { afterEach, assert, beforeEach, describe, expect, it, vi } from "vitest"; -import * as convenienceFunctions from "@util/convenience-functions"; - -import { HorizontalPositionAlign, VerticalPositionAlign } from "@file/shared"; import { Formatter } from "@export/formatter"; import { BorderStyle } from "@file/border"; +import { HorizontalPositionAlign, VerticalPositionAlign } from "@file/shared"; import { EMPTY_OBJECT } from "@file/xml-components"; +import * as convenienceFunctions from "@util/convenience-functions"; import { IViewWrapper } from "../document-wrapper"; import { File } from "../file"; diff --git a/src/file/paragraph/paragraph.ts b/src/file/paragraph/paragraph.ts index feafb1450fe..665b1f2794f 100644 --- a/src/file/paragraph/paragraph.ts +++ b/src/file/paragraph/paragraph.ts @@ -1,12 +1,12 @@ // http://officeopenxml.com/WPparagraph.php +import { FileChild } from "@file/file-child"; import { FootnoteReferenceRun } from "@file/footnotes"; import { IContext, IXmlableObject } from "@file/xml-components"; import { uniqueId } from "@util/convenience-functions"; -import { FileChild } from "@file/file-child"; +import { CheckBox } from "../checkbox"; import { TargetModeType } from "../relationships/relationship/relationship"; import { DeletedTextRun, InsertedTextRun } from "../track-revision"; -import { CheckBox } from "../checkbox"; import { ColumnBreak, PageBreak } from "./formatting/break"; import { Bookmark, ConcreteHyperlink, ExternalHyperlink, InternalHyperlink } from "./links"; import { Math } from "./math"; @@ -37,10 +37,10 @@ export type ParagraphChild = | CommentReference | CheckBox; -export interface IParagraphOptions extends IParagraphPropertiesOptions { +export type IParagraphOptions = { readonly text?: string; readonly children?: readonly ParagraphChild[]; -} +} & IParagraphPropertiesOptions; export class Paragraph extends FileChild { private readonly properties: ParagraphProperties; diff --git a/src/file/paragraph/properties.spec.ts b/src/file/paragraph/properties.spec.ts index 6aaf76f033c..8e581b5d2a0 100644 --- a/src/file/paragraph/properties.spec.ts +++ b/src/file/paragraph/properties.spec.ts @@ -1,9 +1,9 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; + import { DocumentWrapper } from "../document-wrapper"; import { File } from "../file"; - import { ParagraphProperties } from "./properties"; describe("ParagraphProperties", () => { @@ -23,13 +23,11 @@ describe("ParagraphProperties", () => { }, }); const tree = new Formatter().format(properties, { - // tslint:disable-next-line: no-object-literal-type-assertion file: { Numbering: { createConcreteNumberingInstance: (_: string, __: number) => undefined, }, } as File, - // tslint:disable-next-line: no-object-literal-type-assertion viewWrapper: new DocumentWrapper({ background: {} }), stack: [], }); diff --git a/src/file/paragraph/properties.ts b/src/file/paragraph/properties.ts index 4105fa252f6..b8d050c6a2c 100644 --- a/src/file/paragraph/properties.ts +++ b/src/file/paragraph/properties.ts @@ -1,7 +1,9 @@ // http://officeopenxml.com/WPparagraphProperties.php // https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_suppressLineNumbers_topic_ID0ECJAO.html -/* eslint-disable functional/immutable-data */ -import { IContext, IgnoreIfEmptyXmlComponent, IXmlableObject, OnOffElement, XmlComponent } from "@file/xml-components"; + +import { IContext, IXmlableObject, IgnoreIfEmptyXmlComponent, OnOffElement, XmlComponent } from "@file/xml-components"; + +import { IRunOptions, RunProperties } from "."; import { DocumentWrapper } from "../document-wrapper"; import { IShadingAttributesProperties, Shading } from "../shading"; import { Alignment, AlignmentType } from "./formatting/alignment"; @@ -13,11 +15,10 @@ import { HeadingLevel, Style } from "./formatting/style"; import { TabStop, TabStopDefinition, TabStopType } from "./formatting/tab-stop"; import { NumberProperties } from "./formatting/unordered-list"; import { WordWrap } from "./formatting/word-wrap"; -import { createFrameProperties, IFrameOptions } from "./frame/frame-properties"; +import { IFrameOptions, createFrameProperties } from "./frame/frame-properties"; import { OutlineLevel } from "./links"; -import { IRunOptions, RunProperties } from "."; -export interface ILevelParagraphStylePropertiesOptions { +export type ILevelParagraphStylePropertiesOptions = { readonly alignment?: (typeof AlignmentType)[keyof typeof AlignmentType]; readonly thematicBreak?: boolean; readonly contextualSpacing?: boolean; @@ -34,9 +35,9 @@ export interface ILevelParagraphStylePropertiesOptions { */ readonly keepLines?: boolean; readonly outlineLevel?: number; -} +}; -export interface IParagraphStylePropertiesOptions extends ILevelParagraphStylePropertiesOptions { +export type IParagraphStylePropertiesOptions = { readonly numbering?: | { readonly reference: string; @@ -45,9 +46,9 @@ export interface IParagraphStylePropertiesOptions extends ILevelParagraphStylePr readonly custom?: boolean; } | false; -} +} & ILevelParagraphStylePropertiesOptions; -export interface IParagraphPropertiesOptions extends IParagraphStylePropertiesOptions { +export type IParagraphPropertiesOptions = { readonly border?: IBordersOptions; readonly heading?: (typeof HeadingLevel)[keyof typeof HeadingLevel]; readonly bidirectional?: boolean; @@ -73,7 +74,7 @@ export interface IParagraphPropertiesOptions extends IParagraphStylePropertiesOp * Reference: ECMA-376, 3rd Edition (June, 2011), Fundamentals and Markup Language Reference ยง 17.3.1.29. */ readonly run?: IRunOptions; -} +} & IParagraphStylePropertiesOptions; export class ParagraphProperties extends IgnoreIfEmptyXmlComponent { // eslint-disable-next-line functional/prefer-readonly-type diff --git a/src/file/paragraph/run/comment-run.ts b/src/file/paragraph/run/comment-run.ts index f204f7ddcdd..0ffc9fe2573 100644 --- a/src/file/paragraph/run/comment-run.ts +++ b/src/file/paragraph/run/comment-run.ts @@ -1,17 +1,17 @@ import { FileChild } from "@file/file-child"; import { XmlAttributeComponent, XmlComponent } from "@file/xml-components"; -export interface ICommentOptions { +export type ICommentOptions = { readonly id: number; readonly children: readonly FileChild[]; readonly initials?: string; readonly author?: string; readonly date?: Date; -} +}; -export interface ICommentsOptions { +export type ICommentsOptions = { readonly children: readonly ICommentOptions[]; -} +}; class CommentAttributes extends XmlAttributeComponent<{ readonly id: number; diff --git a/src/file/paragraph/run/empty-children.spec.ts b/src/file/paragraph/run/empty-children.spec.ts index 24615575e1b..aed7142f4f5 100644 --- a/src/file/paragraph/run/empty-children.spec.ts +++ b/src/file/paragraph/run/empty-children.spec.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; + import { AnnotationReference, CarriageReturn, diff --git a/src/file/paragraph/run/formatting.ts b/src/file/paragraph/run/formatting.ts index 3629dd36ee1..50c14ac568d 100644 --- a/src/file/paragraph/run/formatting.ts +++ b/src/file/paragraph/run/formatting.ts @@ -1,5 +1,5 @@ import { Attributes, XmlComponent } from "@file/xml-components"; -import { hexColorValue, signedTwipsMeasureValue, UniversalMeasure } from "@util/values"; +import { UniversalMeasure, hexColorValue, signedTwipsMeasureValue } from "@util/values"; export class CharacterSpacing extends XmlComponent { public constructor(value: number | UniversalMeasure) { diff --git a/src/file/paragraph/run/image-run.ts b/src/file/paragraph/run/image-run.ts index b73d5ee8745..d909e95808e 100644 --- a/src/file/paragraph/run/image-run.ts +++ b/src/file/paragraph/run/image-run.ts @@ -1,10 +1,9 @@ -import { hashedId } from "@util/convenience-functions"; - -import { IContext, IXmlableObject } from "@file/xml-components"; import { DocPropertiesOptions } from "@file/drawing/doc-properties/doc-properties"; +import { IContext, IXmlableObject } from "@file/xml-components"; +import { hashedId } from "@util/convenience-functions"; -import { OutlineOptions } from "../../drawing/inline/graphic/graphic-data/pic/shape-properties/outline/outline"; import { Drawing, IFloating } from "../../drawing"; +import { OutlineOptions } from "../../drawing/inline/graphic/graphic-data/pic/shape-properties/outline/outline"; import { IMediaTransformation } from "../../media"; import { IMediaData } from "../../media/data"; import { Run } from "../run"; diff --git a/src/file/paragraph/run/language.ts b/src/file/paragraph/run/language.ts index b0978b38bc9..4b9088ac281 100644 --- a/src/file/paragraph/run/language.ts +++ b/src/file/paragraph/run/language.ts @@ -5,11 +5,11 @@ import { BuilderElement, XmlComponent } from "@file/xml-components"; // // // -export interface ILanguageOptions { +export type ILanguageOptions = { readonly value?: string; readonly eastAsia?: string; readonly bidirectional?: string; -} +}; export const createLanguageComponent = (options: ILanguageOptions): XmlComponent => new BuilderElement<{ diff --git a/src/file/paragraph/run/positional-tab.ts b/src/file/paragraph/run/positional-tab.ts index c9f97ca2dc4..bb8c6fc2177 100644 --- a/src/file/paragraph/run/positional-tab.ts +++ b/src/file/paragraph/run/positional-tab.ts @@ -38,15 +38,14 @@ export const PositionalTabLeader = { DOT: "dot", HYPHEN: "hyphen", UNDERSCORE: "underscore", - // eslint-disable-next-line @typescript-eslint/naming-convention MIDDLE_DOT: "middleDot", } as const; -export interface PositionalTabOptions { +export type PositionalTabOptions = { readonly alignment: (typeof PositionalTabAlignment)[keyof typeof PositionalTabAlignment]; readonly relativeTo: (typeof PositionalTabRelativeTo)[keyof typeof PositionalTabRelativeTo]; readonly leader: (typeof PositionalTabLeader)[keyof typeof PositionalTabLeader]; -} +}; // // diff --git a/src/file/paragraph/run/properties.ts b/src/file/paragraph/run/properties.ts index 25e63a0cc7e..756d99c3202 100644 --- a/src/file/paragraph/run/properties.ts +++ b/src/file/paragraph/run/properties.ts @@ -1,5 +1,5 @@ // https://www.ecma-international.org/wp-content/uploads/ECMA-376-1_5th_edition_december_2016.zip page 297, section 17.3.2.21 -/* eslint-disable functional/immutable-data */ + import { BorderElement, IBorderOptions } from "@file/border"; import { IShadingAttributesProperties, Shading } from "@file/shading"; import { ChangeAttributes, IChangedAttributesProperties } from "@file/track-revision/track-revision"; @@ -15,17 +15,16 @@ import { PositiveUniversalMeasure, UniversalMeasure } from "@util/values"; import { EmphasisMark, EmphasisMarkType } from "./emphasis-mark"; import { CharacterSpacing, Color, Highlight, HighlightComplexScript } from "./formatting"; -import { createLanguageComponent, ILanguageOptions } from "./language"; +import { ILanguageOptions, createLanguageComponent } from "./language"; import { IFontAttributesProperties, RunFonts } from "./run-fonts"; import { SubScript, SuperScript } from "./script"; import { Underline, UnderlineType } from "./underline"; -interface IFontOptions { +type IFontOptions = { readonly name: string; readonly hint?: string; -} +}; -/* eslint-disable @typescript-eslint/naming-convention */ export const TextEffect = { BLINK_BACKGROUND: "blinkBackground", LIGHTS: "lights", @@ -63,9 +62,7 @@ export const HighlightColor = { YELLOW: "yellow", } as const; -/* eslint-enable */ - -export interface IRunStylePropertiesOptions { +export type IRunStylePropertiesOptions = { readonly noProof?: boolean; readonly bold?: boolean; readonly boldComplexScript?: boolean; @@ -106,13 +103,13 @@ export interface IRunStylePropertiesOptions { readonly specVanish?: boolean; readonly scale?: number; readonly math?: boolean; -} +}; -export interface IRunPropertiesOptions extends IRunStylePropertiesOptions { +export type IRunPropertiesOptions = { readonly style?: string; -} +} & IRunStylePropertiesOptions; -export interface IRunPropertiesChangeOptions extends IRunPropertiesOptions, IChangedAttributesProperties {} +export type IRunPropertiesChangeOptions = {} & IRunPropertiesOptions & IChangedAttributesProperties; // // @@ -157,7 +154,6 @@ export interface IRunPropertiesChangeOptions extends IRunPropertiesOptions, ICha // // // -/* eslint-disable functional/immutable-data */ export class RunProperties extends IgnoreIfEmptyXmlComponent { public constructor(options?: IRunPropertiesOptions) { @@ -326,8 +322,6 @@ export class RunProperties extends IgnoreIfEmptyXmlComponent { } } -/* eslint-enable */ - export class RunPropertiesChange extends XmlComponent { public constructor(options: IRunPropertiesChangeOptions) { super("w:rPrChange"); diff --git a/src/file/paragraph/run/run-components/text.ts b/src/file/paragraph/run/run-components/text.ts index db6c8d77b09..4edaf321ba7 100644 --- a/src/file/paragraph/run/run-components/text.ts +++ b/src/file/paragraph/run/run-components/text.ts @@ -11,10 +11,10 @@ import { TextAttributes } from "../text-attributes"; // // -interface ITextOptions { +type ITextOptions = { readonly space?: (typeof SpaceType)[keyof typeof SpaceType]; readonly text?: string; -} +}; export class Text extends XmlComponent { public constructor(options: string | ITextOptions) { diff --git a/src/file/paragraph/run/run-fonts.ts b/src/file/paragraph/run/run-fonts.ts index 6eafd998f80..d6a184c934a 100644 --- a/src/file/paragraph/run/run-fonts.ts +++ b/src/file/paragraph/run/run-fonts.ts @@ -1,12 +1,12 @@ import { XmlAttributeComponent, XmlComponent } from "@file/xml-components"; -export interface IFontAttributesProperties { +export type IFontAttributesProperties = { readonly ascii?: string; readonly cs?: string; readonly eastAsia?: string; readonly hAnsi?: string; readonly hint?: string; -} +}; class RunFontAttributes extends XmlAttributeComponent { protected readonly xmlKeys = { diff --git a/src/file/paragraph/run/run.spec.ts b/src/file/paragraph/run/run.spec.ts index 8939f68c4a4..0ed444371de 100644 --- a/src/file/paragraph/run/run.spec.ts +++ b/src/file/paragraph/run/run.spec.ts @@ -5,9 +5,10 @@ import { BorderStyle } from "@file/border"; import { ShadingType } from "@file/shading"; import { EmphasisMarkType } from "./emphasis-mark"; +import { HighlightColor, TextEffect } from "./properties"; import { PageNumber, Run } from "./run"; import { UnderlineType } from "./underline"; -import { HighlightColor, TextEffect } from "./properties"; + describe("Run", () => { describe("#noProof()", () => { it("turns off spelling and grammar checkers for a run", () => { diff --git a/src/file/paragraph/run/run.ts b/src/file/paragraph/run/run.ts index d3dba0e230e..9f79925113c 100644 --- a/src/file/paragraph/run/run.ts +++ b/src/file/paragraph/run/run.ts @@ -1,14 +1,9 @@ // http://officeopenxml.com/WPtext.php -import { XmlComponent } from "@file/xml-components"; - import { FootnoteReferenceRun } from "@file/footnotes/footnote/run/reference-run"; import { FieldInstruction } from "@file/table-of-contents/field-instruction"; +import { XmlComponent } from "@file/xml-components"; import { Break } from "./break"; -import { Begin, End, Separate } from "./field"; -import { NumberOfPages, NumberOfPagesSection, Page, CurrentSection } from "./page-number"; -import { IRunPropertiesOptions, RunProperties } from "./properties"; -import { Text } from "./run-components/text"; import { AnnotationReference, CarriageReturn, @@ -28,9 +23,13 @@ import { YearLong, YearShort, } from "./empty-children"; +import { Begin, End, Separate } from "./field"; +import { CurrentSection, NumberOfPages, NumberOfPagesSection, Page } from "./page-number"; import { PositionalTab } from "./positional-tab"; +import { IRunPropertiesOptions, RunProperties } from "./properties"; +import { Text } from "./run-components/text"; -export interface IRunOptions extends IRunPropertiesOptions { +export type IRunOptions = { // // // @@ -96,9 +95,8 @@ export interface IRunOptions extends IRunPropertiesOptions { )[]; readonly break?: number; readonly text?: string; -} +} & IRunPropertiesOptions; -/* eslint-disable @typescript-eslint/naming-convention */ export const PageNumber = { CURRENT: "CURRENT", TOTAL_PAGES: "TOTAL_PAGES", @@ -106,8 +104,6 @@ export const PageNumber = { CURRENT_SECTION: "SECTION", } as const; -/* eslint-enable */ - export class Run extends XmlComponent { protected readonly properties: RunProperties; diff --git a/src/file/paragraph/run/sequential-identifier.ts b/src/file/paragraph/run/sequential-identifier.ts index 109ddd4a18d..4dc9c98ef8b 100644 --- a/src/file/paragraph/run/sequential-identifier.ts +++ b/src/file/paragraph/run/sequential-identifier.ts @@ -1,5 +1,6 @@ import { Run } from "@file/paragraph/run"; import { Begin, End, Separate } from "@file/paragraph/run/field"; + import { SequentialIdentifierInstruction } from "./sequential-identifier-instruction"; export class SequentialIdentifier extends Run { diff --git a/src/file/paragraph/run/simple-field.ts b/src/file/paragraph/run/simple-field.ts index 83bfc17e755..1a4e7a9b60e 100644 --- a/src/file/paragraph/run/simple-field.ts +++ b/src/file/paragraph/run/simple-field.ts @@ -1,5 +1,6 @@ // http://www.datypic.com/sc/ooxml/e-w_fldSimple-1.html import { XmlAttributeComponent, XmlComponent } from "@file/xml-components"; + import { TextRun } from "./text-run"; class FldSimpleAttrs extends XmlAttributeComponent<{ readonly instr: string }> { diff --git a/src/file/paragraph/run/symbol-run.spec.ts b/src/file/paragraph/run/symbol-run.spec.ts index 47db16466c4..afdd32c328c 100644 --- a/src/file/paragraph/run/symbol-run.spec.ts +++ b/src/file/paragraph/run/symbol-run.spec.ts @@ -3,8 +3,8 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; import { EmphasisMarkType } from "./emphasis-mark"; -import { UnderlineType } from "./underline"; import { SymbolRun } from "./symbol-run"; +import { UnderlineType } from "./underline"; describe("SymbolRun", () => { let run: SymbolRun; diff --git a/src/file/paragraph/run/symbol-run.ts b/src/file/paragraph/run/symbol-run.ts index 5848016ecc9..df9ac67aa79 100644 --- a/src/file/paragraph/run/symbol-run.ts +++ b/src/file/paragraph/run/symbol-run.ts @@ -1,10 +1,10 @@ import { IRunOptions, Run } from "./run"; import { Symbol } from "./run-components/symbol"; -export interface ISymbolRunOptions extends IRunOptions { +export type ISymbolRunOptions = { readonly char: string; readonly symbolfont?: string; -} +} & IRunOptions; export class SymbolRun extends Run { public constructor(options: ISymbolRunOptions | string) { diff --git a/src/file/relationships/relationship/relationship.ts b/src/file/relationships/relationship/relationship.ts index 4734d61d583..8cfa46f1428 100644 --- a/src/file/relationships/relationship/relationship.ts +++ b/src/file/relationships/relationship/relationship.ts @@ -1,4 +1,5 @@ import { XmlComponent } from "@file/xml-components"; + import { RelationshipAttributes } from "./relationship-attributes"; export type RelationshipType = diff --git a/src/file/relationships/relationships.spec.ts b/src/file/relationships/relationships.spec.ts index c21c9d0dd23..d0f745bf40d 100644 --- a/src/file/relationships/relationships.spec.ts +++ b/src/file/relationships/relationships.spec.ts @@ -1,4 +1,3 @@ -// tslint:disable:no-string-literal import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; diff --git a/src/file/relationships/relationships.ts b/src/file/relationships/relationships.ts index f66eea8c19a..ca019ab498f 100644 --- a/src/file/relationships/relationships.ts +++ b/src/file/relationships/relationships.ts @@ -1,4 +1,5 @@ import { XmlComponent } from "@file/xml-components"; + import { RelationshipsAttributes } from "./attributes"; import { Relationship, RelationshipType, TargetModeType } from "./relationship/relationship"; diff --git a/src/file/settings/compatibility.ts b/src/file/settings/compatibility.ts index 1f2160c91af..fdda107967d 100644 --- a/src/file/settings/compatibility.ts +++ b/src/file/settings/compatibility.ts @@ -1,5 +1,6 @@ // http://www.datypic.com/sc/ooxml/e-w_compat-1.html import { OnOffElement, XmlComponent } from "@file/xml-components"; + import { CompatibilitySetting } from "./compatibility-setting/compatibility-setting"; // @@ -74,7 +75,7 @@ import { CompatibilitySetting } from "./compatibility-setting/compatibility-sett // // -export interface ICompatibilityOptions { +export type ICompatibilityOptions = { readonly version?: number; /** Use Simplified Rules For Table Border Conflicts */ readonly useSingleBorderforContiguousCells?: boolean; @@ -206,7 +207,7 @@ export interface ICompatibilityOptions { readonly useAnsiKerningPairs?: boolean; /** Use Cached Paragraph Information for Column Balancing */ readonly cachedColumnBalance?: boolean; -} +}; export class Compatibility extends XmlComponent { public constructor(options: ICompatibilityOptions) { diff --git a/src/file/settings/settings.ts b/src/file/settings/settings.ts index ad89de7b497..393c84ed727 100644 --- a/src/file/settings/settings.ts +++ b/src/file/settings/settings.ts @@ -146,14 +146,14 @@ export class SettingsAttributes extends XmlAttributeComponent<{ // // -export interface ISettingsOptions { +export type ISettingsOptions = { readonly compatibilityModeVersion?: number; readonly evenAndOddHeaders?: boolean; readonly trackRevisions?: boolean; readonly updateFields?: boolean; readonly compatibility?: ICompatibilityOptions; readonly defaultTabStop?: number; -} +}; export class Settings extends XmlComponent { public constructor(options: ISettingsOptions) { diff --git a/src/file/shading/shading.ts b/src/file/shading/shading.ts index e2d9369c1d7..56c4d59a4e4 100644 --- a/src/file/shading/shading.ts +++ b/src/file/shading/shading.ts @@ -20,11 +20,11 @@ import { XmlAttributeComponent, XmlComponent } from "@file/xml-components"; import { hexColorValue } from "@util/values"; -export interface IShadingAttributesProperties { +export type IShadingAttributesProperties = { readonly fill?: string; readonly color?: string; readonly type?: (typeof ShadingType)[keyof typeof ShadingType]; -} +}; class ShadingAttributes extends XmlAttributeComponent { protected readonly xmlKeys = { @@ -47,7 +47,6 @@ export class Shading extends XmlComponent { } } -/* eslint-disable @typescript-eslint/naming-convention */ export const ShadingType = { CLEAR: "clear", DIAGONAL_CROSS: "diagCross", @@ -87,4 +86,3 @@ export const ShadingType = { THIN_VERTICAL_STRIPE: "thinVertStripe", VERTICAL_STRIPE: "vertStripe", } as const; -/* eslint-enable */ diff --git a/src/file/shared/number-format.ts b/src/file/shared/number-format.ts index 58e37f87c39..06adfbb8278 100644 --- a/src/file/shared/number-format.ts +++ b/src/file/shared/number-format.ts @@ -66,7 +66,6 @@ // // -/* eslint-disable @typescript-eslint/naming-convention*/ export const NumberFormat = { DECIMAL: "decimal", UPPER_ROMAN: "upperRoman", @@ -132,4 +131,3 @@ export const NumberFormat = { DOLLAR_TEXT: "dollarText", // } as const; -/* eslint-enable */ diff --git a/src/file/styles/defaults/document-defaults.ts b/src/file/styles/defaults/document-defaults.ts index 57724758f42..fe1b9aa5fb4 100644 --- a/src/file/styles/defaults/document-defaults.ts +++ b/src/file/styles/defaults/document-defaults.ts @@ -1,13 +1,14 @@ import { IParagraphStylePropertiesOptions } from "@file/paragraph/properties"; import { IRunStylePropertiesOptions } from "@file/paragraph/run/properties"; import { XmlComponent } from "@file/xml-components"; + import { ParagraphPropertiesDefaults } from "./paragraph-properties"; import { RunPropertiesDefaults } from "./run-properties"; -export interface IDocumentDefaultsOptions { +export type IDocumentDefaultsOptions = { readonly paragraph?: IParagraphStylePropertiesOptions; readonly run?: IRunStylePropertiesOptions; -} +}; export class DocumentDefaults extends XmlComponent { private readonly runPropertiesDefaults: RunPropertiesDefaults; diff --git a/src/file/styles/external-styles-factory.ts b/src/file/styles/external-styles-factory.ts index 19dc3963785..a0cd0099dba 100644 --- a/src/file/styles/external-styles-factory.ts +++ b/src/file/styles/external-styles-factory.ts @@ -1,5 +1,7 @@ -import { convertToXmlComponent, ImportedRootElementAttributes, ImportedXmlComponent } from "@file/xml-components"; import { Element as XMLElement, xml2js } from "xml-js"; + +import { ImportedRootElementAttributes, ImportedXmlComponent, convertToXmlComponent } from "@file/xml-components"; + import { Styles } from "./"; export class ExternalStylesFactory { diff --git a/src/file/styles/factory.ts b/src/file/styles/factory.ts index 63ac2571d2c..382175cb325 100644 --- a/src/file/styles/factory.ts +++ b/src/file/styles/factory.ts @@ -1,6 +1,3 @@ -import { DocumentAttributes } from "../document/document-attributes"; -import { IStylesOptions } from "./styles"; - import { DocumentDefaults, IDocumentDefaultsOptions } from "./defaults"; import { FootnoteReferenceStyle, @@ -19,8 +16,10 @@ import { StrongStyle, TitleStyle, } from "./style"; +import { IStylesOptions } from "./styles"; +import { DocumentAttributes } from "../document/document-attributes"; -export interface IDefaultStylesOptions { +export type IDefaultStylesOptions = { readonly document?: IDocumentDefaultsOptions; readonly title?: IBaseParagraphStyleOptions; readonly heading1?: IBaseParagraphStyleOptions; @@ -35,7 +34,7 @@ export interface IDefaultStylesOptions { readonly footnoteReference?: IBaseCharacterStyleOptions; readonly footnoteText?: IBaseParagraphStyleOptions; readonly footnoteTextChar?: IBaseCharacterStyleOptions; -} +}; export class DefaultStylesFactory { public newInstance(options: IDefaultStylesOptions = {}): IStylesOptions { diff --git a/src/file/styles/latent-styles/exceptions.ts b/src/file/styles/latent-styles/exceptions.ts index b4da25c10b8..174d6c3421d 100644 --- a/src/file/styles/latent-styles/exceptions.ts +++ b/src/file/styles/latent-styles/exceptions.ts @@ -1,12 +1,12 @@ import { XmlAttributeComponent, XmlComponent } from "@file/xml-components"; -export interface ILatentStyleExceptionAttributesProperties { +export type ILatentStyleExceptionAttributesProperties = { readonly name?: string; readonly uiPriority?: string; readonly qFormat?: string; readonly semiHidden?: string; readonly unhideWhenUsed?: string; -} +}; export class LatentStyleExceptionAttributes extends XmlAttributeComponent { protected readonly xmlKeys = { diff --git a/src/file/styles/latent-styles/latent-styles.ts b/src/file/styles/latent-styles/latent-styles.ts index 5c9c94b29e4..e77678bf075 100644 --- a/src/file/styles/latent-styles/latent-styles.ts +++ b/src/file/styles/latent-styles/latent-styles.ts @@ -1,4 +1,5 @@ import { XmlComponent } from "@file/xml-components"; + import { LatentStyleException } from "./exceptions"; export class LatentStyles extends XmlComponent { diff --git a/src/file/styles/style/character-style.spec.ts b/src/file/styles/style/character-style.spec.ts index 16f85e3d438..68a62135b19 100644 --- a/src/file/styles/style/character-style.spec.ts +++ b/src/file/styles/style/character-style.spec.ts @@ -2,8 +2,8 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; import { EmphasisMarkType } from "@file/paragraph/run/emphasis-mark"; -import { UnderlineType } from "@file/paragraph/run/underline"; import { HighlightColor } from "@file/paragraph/run/properties"; +import { UnderlineType } from "@file/paragraph/run/underline"; import { ShadingType } from "@file/shading"; import { EMPTY_OBJECT } from "@file/xml-components"; diff --git a/src/file/styles/style/character-style.ts b/src/file/styles/style/character-style.ts index f2743e2c03e..188f5741957 100644 --- a/src/file/styles/style/character-style.ts +++ b/src/file/styles/style/character-style.ts @@ -2,13 +2,13 @@ import { IRunStylePropertiesOptions, RunProperties } from "@file/paragraph/run/p import { IStyleOptions, Style } from "./style"; -export interface IBaseCharacterStyleOptions extends IStyleOptions { +export type IBaseCharacterStyleOptions = { readonly run?: IRunStylePropertiesOptions; -} +} & IStyleOptions; -export interface ICharacterStyleOptions extends IBaseCharacterStyleOptions { +export type ICharacterStyleOptions = { readonly id: string; -} +} & IBaseCharacterStyleOptions; export class StyleForCharacter extends Style { private readonly runProperties: RunProperties; diff --git a/src/file/styles/style/default-styles.ts b/src/file/styles/style/default-styles.ts index 2a3e6fd3185..50a01f854ef 100644 --- a/src/file/styles/style/default-styles.ts +++ b/src/file/styles/style/default-styles.ts @@ -1,6 +1,5 @@ -import { UnderlineType } from "@file/paragraph/run/underline"; - import { LineRuleType } from "@file/paragraph"; +import { UnderlineType } from "@file/paragraph/run/underline"; import { IBaseCharacterStyleOptions, StyleForCharacter } from "./character-style"; import { IBaseParagraphStyleOptions, IParagraphStyleOptions, StyleForParagraph } from "./paragraph-style"; diff --git a/src/file/styles/style/paragraph-style.spec.ts b/src/file/styles/style/paragraph-style.spec.ts index 429c5d0e8fd..1f06b04ae9c 100644 --- a/src/file/styles/style/paragraph-style.spec.ts +++ b/src/file/styles/style/paragraph-style.spec.ts @@ -2,8 +2,8 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; import { AlignmentType, EmphasisMarkType, TabStopPosition } from "@file/paragraph"; -import { UnderlineType } from "@file/paragraph/run/underline"; import { HighlightColor } from "@file/paragraph/run"; +import { UnderlineType } from "@file/paragraph/run/underline"; import { ShadingType } from "@file/shading"; import { EMPTY_OBJECT } from "@file/xml-components"; diff --git a/src/file/styles/style/paragraph-style.ts b/src/file/styles/style/paragraph-style.ts index 84b9dd909e3..7dc4eeb887e 100644 --- a/src/file/styles/style/paragraph-style.ts +++ b/src/file/styles/style/paragraph-style.ts @@ -1,15 +1,16 @@ import { IParagraphStylePropertiesOptions, IRunStylePropertiesOptions, ParagraphProperties } from "@file/paragraph"; import { RunProperties } from "@file/paragraph/run/properties"; + import { IStyleOptions, Style } from "./style"; -export interface IBaseParagraphStyleOptions extends IStyleOptions { +export type IBaseParagraphStyleOptions = { readonly paragraph?: IParagraphStylePropertiesOptions; readonly run?: IRunStylePropertiesOptions; -} +} & IStyleOptions; -export interface IParagraphStyleOptions extends IBaseParagraphStyleOptions { +export type IParagraphStyleOptions = { readonly id: string; -} +} & IBaseParagraphStyleOptions; export class StyleForParagraph extends Style { private readonly paragraphProperties: ParagraphProperties; diff --git a/src/file/styles/style/style.ts b/src/file/styles/style/style.ts index e6c78780d40..12dbe339002 100644 --- a/src/file/styles/style/style.ts +++ b/src/file/styles/style/style.ts @@ -1,4 +1,5 @@ import { OnOffElement, StringValueElement, XmlAttributeComponent, XmlComponent } from "@file/xml-components"; + import { Name, UiPriority } from "./components"; // @@ -32,14 +33,14 @@ import { Name, UiPriority } from "./components"; // // -export interface IStyleAttributes { +export type IStyleAttributes = { readonly type?: string; readonly styleId?: string; readonly default?: boolean; readonly customStyle?: string; -} +}; -export interface IStyleOptions { +export type IStyleOptions = { readonly name?: string; /** * Specifies the style upon which the current style is based-that is, the style from which the current style inherits. It is the mechanism for implementing style inheritance. @@ -55,7 +56,7 @@ export interface IStyleOptions { readonly semiHidden?: boolean; readonly unhideWhenUsed?: boolean; readonly quickFormat?: boolean; -} +}; class StyleAttributes extends XmlAttributeComponent { protected readonly xmlKeys = { diff --git a/src/file/styles/styles.ts b/src/file/styles/styles.ts index eff550ade47..4e269f48d4c 100644 --- a/src/file/styles/styles.ts +++ b/src/file/styles/styles.ts @@ -1,16 +1,17 @@ import { IDefaultStylesOptions } from "@file/styles/factory"; import { BaseXmlComponent, ImportedXmlComponent, XmlComponent } from "@file/xml-components"; + import { StyleForCharacter, StyleForParagraph } from "./style"; import { ICharacterStyleOptions } from "./style/character-style"; import { IParagraphStyleOptions } from "./style/paragraph-style"; -export interface IStylesOptions { +export type IStylesOptions = { readonly default?: IDefaultStylesOptions; readonly initialStyles?: BaseXmlComponent; readonly paragraphStyles?: readonly IParagraphStyleOptions[]; readonly characterStyles?: readonly ICharacterStyleOptions[]; readonly importedStyles?: readonly (XmlComponent | StyleForParagraph | StyleForCharacter | ImportedXmlComponent)[]; -} +}; // // diff --git a/src/file/table-of-contents/table-of-contents-properties.ts b/src/file/table-of-contents/table-of-contents-properties.ts index f53299d795b..86aeedb8231 100644 --- a/src/file/table-of-contents/table-of-contents-properties.ts +++ b/src/file/table-of-contents/table-of-contents-properties.ts @@ -16,7 +16,7 @@ export class StyleLevel { * Short Guide: * http://officeopenxml.com/WPtableOfContents.php */ -export interface ITableOfContentsOptions { +export type ITableOfContentsOptions = { /** * \a option - Includes captioned items, but omits caption labels and numbers. * The identifier designated by text in this switch's field-argument corresponds to the caption label. @@ -119,4 +119,4 @@ export interface ITableOfContentsOptions { * \z Hides tab leader and page numbers in web page view (ยง17.18.102). */ readonly hideTabAndPageNumbersInWebView?: boolean; -} +}; diff --git a/src/file/table-of-contents/table-of-contents.ts b/src/file/table-of-contents/table-of-contents.ts index da11a28719e..e3a110bb4a7 100644 --- a/src/file/table-of-contents/table-of-contents.ts +++ b/src/file/table-of-contents/table-of-contents.ts @@ -1,9 +1,10 @@ // http://officeopenxml.com/WPtableOfContents.php // http://www.datypic.com/sc/ooxml/e-w_sdt-1.html +import { FileChild } from "@file/file-child"; import { Paragraph } from "@file/paragraph"; import { Run } from "@file/paragraph/run"; import { Begin, End, Separate } from "@file/paragraph/run/field"; -import { FileChild } from "@file/file-child"; + import { FieldInstruction } from "./field-instruction"; import { StructuredDocumentTagContent } from "./sdt-content"; import { StructuredDocumentTagProperties } from "./sdt-properties"; diff --git a/src/file/table/grid.spec.ts b/src/file/table/grid.spec.ts index 64e45018648..e50974bc132 100644 --- a/src/file/table/grid.spec.ts +++ b/src/file/table/grid.spec.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from "vitest"; -import { EMPTY_OBJECT } from "@file/xml-components"; import { Formatter } from "@export/formatter"; +import { EMPTY_OBJECT } from "@file/xml-components"; import { GridCol, TableGrid } from "./grid"; diff --git a/src/file/table/table-cell/table-cell-components.ts b/src/file/table/table-cell/table-cell-components.ts index 11e9dc711f4..160b54a9bf0 100644 --- a/src/file/table/table-cell/table-cell-components.ts +++ b/src/file/table/table-cell/table-cell-components.ts @@ -17,14 +17,14 @@ import { decimalNumber } from "@util/values"; // // -export interface ITableCellBorders { +export type ITableCellBorders = { readonly top?: IBorderOptions; readonly start?: IBorderOptions; readonly left?: IBorderOptions; readonly bottom?: IBorderOptions; readonly end?: IBorderOptions; readonly right?: IBorderOptions; -} +}; export class TableCellBorders extends IgnoreIfEmptyXmlComponent { public constructor(options: ITableCellBorders) { @@ -113,11 +113,8 @@ export class VerticalMerge extends XmlComponent { } export const TextDirection = { - // eslint-disable-next-line @typescript-eslint/naming-convention BOTTOM_TO_TOP_LEFT_TO_RIGHT: "btLr", - // eslint-disable-next-line @typescript-eslint/naming-convention LEFT_TO_RIGHT_TOP_TO_BOTTOM: "lrTb", - // eslint-disable-next-line @typescript-eslint/naming-convention TOP_TO_BOTTOM_RIGHT_TO_LEFT: "tbRl", } as const; diff --git a/src/file/table/table-cell/table-cell-properties.spec.ts b/src/file/table/table-cell/table-cell-properties.spec.ts index 504dc2229ed..995459a3c5c 100644 --- a/src/file/table/table-cell/table-cell-properties.spec.ts +++ b/src/file/table/table-cell/table-cell-properties.spec.ts @@ -5,7 +5,6 @@ import { BorderStyle } from "@file/border"; import { VerticalAlign } from "@file/vertical-align"; import { WidthType } from "../table-width"; - import { VerticalMergeType } from "./table-cell-components"; import { TableCellProperties } from "./table-cell-properties"; diff --git a/src/file/table/table-cell/table-cell-properties.ts b/src/file/table/table-cell/table-cell-properties.ts index 21c8c9a4a3f..f9dcb12875b 100644 --- a/src/file/table/table-cell/table-cell-properties.ts +++ b/src/file/table/table-cell/table-cell-properties.ts @@ -7,14 +7,14 @@ import { ITableWidthProperties, TableWidthElement } from "../table-width"; import { GridSpan, ITableCellBorders, - TableCellBorders, TDirection, + TableCellBorders, TextDirection, VerticalMerge, VerticalMergeType, } from "./table-cell-components"; -export interface ITableCellPropertiesOptions { +export type ITableCellPropertiesOptions = { readonly shading?: IShadingAttributesProperties; readonly margins?: ITableCellMarginOptions; readonly verticalAlign?: (typeof VerticalAlign)[keyof typeof VerticalAlign]; @@ -24,7 +24,7 @@ export interface ITableCellPropertiesOptions { readonly columnSpan?: number; readonly rowSpan?: number; readonly borders?: ITableCellBorders; -} +}; export class TableCellProperties extends IgnoreIfEmptyXmlComponent { public constructor(options: ITableCellPropertiesOptions) { diff --git a/src/file/table/table-cell/table-cell.ts b/src/file/table/table-cell/table-cell.ts index f9547d9ba5d..66aef552a73 100644 --- a/src/file/table/table-cell/table-cell.ts +++ b/src/file/table/table-cell/table-cell.ts @@ -5,9 +5,9 @@ import { IContext, IXmlableObject, XmlComponent } from "@file/xml-components"; import { Table } from "../table"; import { ITableCellPropertiesOptions, TableCellProperties } from "./table-cell-properties"; -export interface ITableCellOptions extends ITableCellPropertiesOptions { +export type ITableCellOptions = { readonly children: readonly (Paragraph | Table)[]; -} +} & ITableCellPropertiesOptions; export class TableCell extends XmlComponent { public constructor(public readonly options: ITableCellOptions) { diff --git a/src/file/table/table-properties/table-borders.ts b/src/file/table/table-properties/table-borders.ts index dee2e5cd908..f31f0255a05 100644 --- a/src/file/table/table-properties/table-borders.ts +++ b/src/file/table/table-properties/table-borders.ts @@ -2,14 +2,14 @@ import { BorderElement, BorderStyle, IBorderOptions } from "@file/border"; import { XmlComponent } from "@file/xml-components"; -export interface ITableBordersOptions { +export type ITableBordersOptions = { readonly top?: IBorderOptions; readonly bottom?: IBorderOptions; readonly left?: IBorderOptions; readonly right?: IBorderOptions; readonly insideHorizontal?: IBorderOptions; readonly insideVertical?: IBorderOptions; -} +}; const NONE_BORDER = { style: BorderStyle.NONE, diff --git a/src/file/table/table-properties/table-cell-margin.spec.ts b/src/file/table/table-properties/table-cell-margin.spec.ts index c4fa4239bf2..0fdffed12a7 100644 --- a/src/file/table/table-properties/table-cell-margin.spec.ts +++ b/src/file/table/table-properties/table-cell-margin.spec.ts @@ -1,8 +1,8 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; -import { WidthType } from "../table-width"; +import { WidthType } from "../table-width"; import { TableCellMargin, TableCellMarginElementType } from "./table-cell-margin"; describe("TableCellMargin", () => { diff --git a/src/file/table/table-properties/table-cell-margin.ts b/src/file/table/table-properties/table-cell-margin.ts index e3a76ee34c9..e862de2bf31 100644 --- a/src/file/table/table-properties/table-cell-margin.ts +++ b/src/file/table/table-properties/table-cell-margin.ts @@ -1,13 +1,13 @@ -import { IgnoreIfEmptyXmlComponent } from "@file/xml-components"; import { TableWidthElement, WidthType } from "@file/table"; +import { IgnoreIfEmptyXmlComponent } from "@file/xml-components"; -export interface ITableCellMarginOptions { +export type ITableCellMarginOptions = { readonly marginUnitType?: (typeof WidthType)[keyof typeof WidthType]; readonly top?: number; readonly bottom?: number; readonly left?: number; readonly right?: number; -} +}; // Technically two different types, but they're identical // @@ -35,7 +35,6 @@ export interface ITableCellMarginOptions { export const TableCellMarginElementType = { TABLE: "w:tblCellMar", - // eslint-disable-next-line @typescript-eslint/naming-convention TABLE_CELL: "w:tcMar", } as const; diff --git a/src/file/table/table-properties/table-float-properties.ts b/src/file/table/table-properties/table-float-properties.ts index 3d077fa1b88..9067c918421 100644 --- a/src/file/table/table-properties/table-float-properties.ts +++ b/src/file/table/table-properties/table-float-properties.ts @@ -1,5 +1,5 @@ import { NextAttributeComponent, StringEnumValueElement, XmlComponent } from "@file/xml-components"; -import { PositiveUniversalMeasure, signedTwipsMeasureValue, twipsMeasureValue, UniversalMeasure } from "@util/values"; +import { PositiveUniversalMeasure, UniversalMeasure, signedTwipsMeasureValue, twipsMeasureValue } from "@util/values"; export const TableAnchorType = { MARGIN: "margin", diff --git a/src/file/table/table-properties/table-properties.spec.ts b/src/file/table/table-properties/table-properties.spec.ts index 2d0665182a7..cebe7153b67 100644 --- a/src/file/table/table-properties/table-properties.spec.ts +++ b/src/file/table/table-properties/table-properties.spec.ts @@ -1,7 +1,6 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; - import { AlignmentType } from "@file/paragraph"; import { ShadingType } from "@file/shading"; diff --git a/src/file/table/table-properties/table-properties.ts b/src/file/table/table-properties/table-properties.ts index d731693fac5..08cfe80b68f 100644 --- a/src/file/table/table-properties/table-properties.ts +++ b/src/file/table/table-properties/table-properties.ts @@ -31,7 +31,7 @@ import { ITableCellMarginOptions, TableCellMargin, TableCellMarginElementType } import { ITableFloatOptions, TableFloatProperties } from "./table-float-properties"; import { TableLayout, TableLayoutType } from "./table-layout"; -export interface ITablePropertiesOptions { +export type ITablePropertiesOptions = { readonly width?: ITableWidthProperties; readonly indent?: ITableWidthProperties; readonly layout?: (typeof TableLayoutType)[keyof typeof TableLayoutType]; @@ -42,7 +42,7 @@ export interface ITablePropertiesOptions { readonly alignment?: (typeof AlignmentType)[keyof typeof AlignmentType]; readonly cellMargin?: ITableCellMarginOptions; readonly visuallyRightToLeft?: boolean; -} +}; export class TableProperties extends IgnoreIfEmptyXmlComponent { public constructor(options: ITablePropertiesOptions) { diff --git a/src/file/table/table-row/table-row-properties.ts b/src/file/table/table-row/table-row-properties.ts index b7d3c7018f2..40605869cde 100644 --- a/src/file/table/table-row/table-row-properties.ts +++ b/src/file/table/table-row/table-row-properties.ts @@ -32,14 +32,14 @@ import { PositiveUniversalMeasure } from "@util/values"; import { HeightRule, TableRowHeight } from "./table-row-height"; -export interface ITableRowPropertiesOptions { +export type ITableRowPropertiesOptions = { readonly cantSplit?: boolean; readonly tableHeader?: boolean; readonly height?: { readonly value: number | PositiveUniversalMeasure; readonly rule: (typeof HeightRule)[keyof typeof HeightRule]; }; -} +}; export class TableRowProperties extends IgnoreIfEmptyXmlComponent { public constructor(options: ITableRowPropertiesOptions) { diff --git a/src/file/table/table-row/table-row.spec.ts b/src/file/table/table-row/table-row.spec.ts index d662e9073dc..e335ffd2faf 100644 --- a/src/file/table/table-row/table-row.spec.ts +++ b/src/file/table/table-row/table-row.spec.ts @@ -1,10 +1,10 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; - import { Paragraph } from "@file/paragraph"; import { HeightRule } from "@file/table/table-row/table-row-height"; import { EMPTY_OBJECT } from "@file/xml-components"; + import { TableCell } from "../table-cell"; import { TableRow } from "./table-row"; diff --git a/src/file/table/table-row/table-row.ts b/src/file/table/table-row/table-row.ts index 863274bccfa..9850c19f64d 100644 --- a/src/file/table/table-row/table-row.ts +++ b/src/file/table/table-row/table-row.ts @@ -1,10 +1,11 @@ import { XmlComponent } from "@file/xml-components"; + import { TableCell } from "../table-cell"; import { ITableRowPropertiesOptions, TableRowProperties } from "./table-row-properties"; -export interface ITableRowOptions extends ITableRowPropertiesOptions { +export type ITableRowOptions = { readonly children: readonly TableCell[]; -} +} & ITableRowPropertiesOptions; export class TableRow extends XmlComponent { public constructor(private readonly options: ITableRowOptions) { diff --git a/src/file/table/table-width.ts b/src/file/table/table-width.ts index 4a950566eba..3bb16c6654c 100644 --- a/src/file/table/table-width.ts +++ b/src/file/table/table-width.ts @@ -1,6 +1,6 @@ // http://officeopenxml.com/WPtableWidth.php import { NextAttributeComponent, XmlComponent } from "@file/xml-components"; -import { measurementOrPercentValue, Percentage, UniversalMeasure } from "@util/values"; +import { Percentage, UniversalMeasure, measurementOrPercentValue } from "@util/values"; // // diff --git a/src/file/table/table.spec.ts b/src/file/table/table.spec.ts index a3e98d80c50..e4694e16447 100644 --- a/src/file/table/table.spec.ts +++ b/src/file/table/table.spec.ts @@ -5,9 +5,8 @@ import { Formatter } from "@export/formatter"; import { AlignmentType, Paragraph } from "../paragraph"; import { Table } from "./table"; -import { RelativeHorizontalPosition, RelativeVerticalPosition, TableAnchorType } from "./table-properties"; - import { TableCell } from "./table-cell"; +import { RelativeHorizontalPosition, RelativeVerticalPosition, TableAnchorType } from "./table-properties"; import { TableLayoutType } from "./table-properties/table-layout"; import { TableRow } from "./table-row"; import { WidthType } from "./table-width"; diff --git a/src/file/table/table.ts b/src/file/table/table.ts index 91269bc3190..0cf2e6e6ee4 100644 --- a/src/file/table/table.ts +++ b/src/file/table/table.ts @@ -20,7 +20,7 @@ import { ITableWidthProperties } from "./table-width"; table will make it look reasonable, as the layout algorithm will expand columns to fit its content */ -export interface ITableOptions { +export type ITableOptions = { readonly rows: readonly TableRow[]; readonly width?: ITableWidthProperties; readonly columnWidths?: readonly number[]; @@ -32,7 +32,7 @@ export interface ITableOptions { readonly borders?: ITableBordersOptions; readonly alignment?: (typeof AlignmentType)[keyof typeof AlignmentType]; readonly visuallyRightToLeft?: boolean; -} +}; export class Table extends FileChild { public constructor({ diff --git a/src/file/track-revision/track-revision-components/deleted-text-run.ts b/src/file/track-revision/track-revision-components/deleted-text-run.ts index 50cb82ad425..30fe7fbec03 100644 --- a/src/file/track-revision/track-revision-components/deleted-text-run.ts +++ b/src/file/track-revision/track-revision-components/deleted-text-run.ts @@ -1,14 +1,14 @@ import { XmlComponent } from "@file/xml-components"; +import { DeletedNumberOfPages, DeletedNumberOfPagesSection, DeletedPage } from "./deleted-page-number"; +import { DeletedText } from "./deleted-text"; import { Break } from "../../paragraph/run/break"; import { Begin, End, Separate } from "../../paragraph/run/field"; +import { RunProperties } from "../../paragraph/run/properties"; import { IRunOptions, PageNumber } from "../../paragraph/run/run"; import { ChangeAttributes, IChangedAttributesProperties } from "../track-revision"; -import { RunProperties } from "../../paragraph/run/properties"; -import { DeletedNumberOfPages, DeletedNumberOfPagesSection, DeletedPage } from "./deleted-page-number"; -import { DeletedText } from "./deleted-text"; -interface IDeletedRunOptions extends IRunOptions, IChangedAttributesProperties {} +type IDeletedRunOptions = IRunOptions & IChangedAttributesProperties; export class DeletedTextRun extends XmlComponent { protected readonly deletedTextRunWrapper: DeletedTextRunWrapper; diff --git a/src/file/track-revision/track-revision-components/inserted-text-run.ts b/src/file/track-revision/track-revision-components/inserted-text-run.ts index 6b667976537..90846745906 100644 --- a/src/file/track-revision/track-revision-components/inserted-text-run.ts +++ b/src/file/track-revision/track-revision-components/inserted-text-run.ts @@ -3,7 +3,7 @@ import { XmlComponent } from "@file/xml-components"; import { IRunOptions, TextRun } from "../../index"; import { ChangeAttributes, IChangedAttributesProperties } from "../track-revision"; -interface IInsertedRunOptions extends IChangedAttributesProperties, IRunOptions {} +type IInsertedRunOptions = IChangedAttributesProperties & IRunOptions; export class InsertedTextRun extends XmlComponent { public constructor(options: IInsertedRunOptions) { diff --git a/src/file/track-revision/track-revision.ts b/src/file/track-revision/track-revision.ts index 37fe5ef951f..d5a666abb8c 100644 --- a/src/file/track-revision/track-revision.ts +++ b/src/file/track-revision/track-revision.ts @@ -1,10 +1,10 @@ import { XmlAttributeComponent } from "@file/xml-components"; -export interface IChangedAttributesProperties { +export type IChangedAttributesProperties = { readonly id: number; readonly author: string; readonly date: string; -} +}; export class ChangeAttributes extends XmlAttributeComponent { protected readonly xmlKeys = { diff --git a/src/file/xml-components/base.ts b/src/file/xml-components/base.ts index 4bd1043b901..3b89f8fa49f 100644 --- a/src/file/xml-components/base.ts +++ b/src/file/xml-components/base.ts @@ -2,12 +2,12 @@ import { IViewWrapper } from "../document-wrapper"; import { File } from "../file"; import { IXmlableObject } from "./xmlable-object"; -export interface IContext { +export type IContext = { readonly file: File; readonly viewWrapper: IViewWrapper; // eslint-disable-next-line functional/prefer-readonly-type readonly stack: IXmlableObject[]; -} +}; export abstract class BaseXmlComponent { protected readonly rootKey: string; diff --git a/src/file/xml-components/default-attributes.ts b/src/file/xml-components/default-attributes.ts index 881765ed207..373b1728127 100644 --- a/src/file/xml-components/default-attributes.ts +++ b/src/file/xml-components/default-attributes.ts @@ -1,13 +1,13 @@ import { BaseXmlComponent, IContext } from "./base"; -import { IXmlableObject, IXmlAttribute } from "./xmlable-object"; +import { IXmlAttribute, IXmlableObject } from "./xmlable-object"; type AttributeMap = Record; -export type AttributeData = { readonly [key: string]: boolean | number | string }; +export type AttributeData = Record; export type AttributePayload = { readonly [P in keyof T]: { readonly key: string; readonly value: T[P] } }; // eslint-disable-next-line @typescript-eslint/no-explicit-any -export abstract class XmlAttributeComponent extends BaseXmlComponent { +export abstract class XmlAttributeComponent> extends BaseXmlComponent { protected readonly xmlKeys?: AttributeMap; public constructor(private readonly root: T) { @@ -15,12 +15,9 @@ export abstract class XmlAttributeComponent = {}; Object.entries(this.root).forEach(([key, value]) => { - // eslint-disable-next-line @typescript-eslint/no-explicit-any if (value !== undefined) { - // eslint-disable-next-line @typescript-eslint/no-explicit-any const newKey = (this.xmlKeys && this.xmlKeys[key]) || key; // eslint-disable-next-line functional/immutable-data attrs[newKey] = value; diff --git a/src/file/xml-components/imported-xml-component.spec.ts b/src/file/xml-components/imported-xml-component.spec.ts index 6f71fb82231..48747e3a86d 100644 --- a/src/file/xml-components/imported-xml-component.spec.ts +++ b/src/file/xml-components/imported-xml-component.spec.ts @@ -3,8 +3,8 @@ import { Element, xml2js } from "xml-js"; import { EMPTY_OBJECT } from "@file/xml-components"; -import { convertToXmlComponent, ImportedRootElementAttributes, ImportedXmlComponent } from "./imported-xml-component"; import { IContext } from "./base"; +import { ImportedRootElementAttributes, ImportedXmlComponent, convertToXmlComponent } from "./imported-xml-component"; const xmlString = ` @@ -55,13 +55,12 @@ describe("ImportedXmlComponent", () => { otherAttr: "2", }; importedXmlComponent = new ImportedXmlComponent("w:test", attributes); - // eslint-disable-next-line functional/immutable-data + importedXmlComponent.push(new ImportedXmlComponent("w:child")); }); describe("#prepForXml()", () => { it("should transform for xml", () => { - // tslint:disable-next-line: no-object-literal-type-assertion const converted = importedXmlComponent.prepForXml({ stack: [] } as unknown as IContext); expect(JSON.parse(JSON.stringify(converted))).to.deep.equal({ "w:test": [ @@ -108,7 +107,6 @@ describe("ImportedRootElementAttributes", () => { describe("#prepForXml()", () => { it("should work", () => { - // tslint:disable-next-line: no-object-literal-type-assertion const converted = attributes.prepForXml({} as IContext); expect(converted).to.deep.equal({ _attr: {}, diff --git a/src/file/xml-components/imported-xml-component.ts b/src/file/xml-components/imported-xml-component.ts index e90c169dd9d..1db2e4dd91b 100644 --- a/src/file/xml-components/imported-xml-component.ts +++ b/src/file/xml-components/imported-xml-component.ts @@ -21,7 +21,6 @@ export const convertToXmlComponent = (element: XmlElement): ImportedXmlComponent for (const childElm of childElements) { const child = convertToXmlComponent(childElm); if (child !== undefined) { - // eslint-disable-next-line functional/immutable-data xmlComponent.push(child); } } @@ -62,7 +61,6 @@ export class ImportedXmlComponent extends XmlComponent { public constructor(rootKey: string, _attr?: any) { super(rootKey); if (_attr) { - // eslint-disable-next-line functional/immutable-data this.root.push(new ImportedXmlComponentAttributes(_attr)); } } diff --git a/src/file/xml-components/simple-elements.ts b/src/file/xml-components/simple-elements.ts index 3a4651e4c9b..c941b35c4da 100644 --- a/src/file/xml-components/simple-elements.ts +++ b/src/file/xml-components/simple-elements.ts @@ -1,6 +1,5 @@ import { AttributeData, AttributePayload, Attributes, NextAttributeComponent, XmlComponent } from "@file/xml-components"; - -import { hpsMeasureValue, PositiveUniversalMeasure } from "@util/values"; +import { PositiveUniversalMeasure, hpsMeasureValue } from "@util/values"; // This represents element type CT_OnOff, which indicate a boolean value. // diff --git a/src/file/xml-components/xml-component.spec.ts b/src/file/xml-components/xml-component.spec.ts index 559072e235b..8c1234d2bc5 100644 --- a/src/file/xml-components/xml-component.spec.ts +++ b/src/file/xml-components/xml-component.spec.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from "vitest"; import { Formatter } from "@export/formatter"; + import { Attributes, BaseXmlComponent, XmlComponent } from "./"; class TestComponent extends XmlComponent { @@ -20,13 +21,13 @@ describe("XmlComponent", () => { }); it("should handle children elements", () => { const xmlComponent = new TestComponent("w:test"); - // eslint-disable-next-line functional/immutable-data + xmlComponent.push( new Attributes({ val: "test", }), ); - // eslint-disable-next-line functional/immutable-data + xmlComponent.push(new TestComponent("innerTest")); const tree = new Formatter().format(xmlComponent); @@ -45,7 +46,7 @@ describe("XmlComponent", () => { }); it("should hoist attrs if only attrs are present", () => { const xmlComponent = new TestComponent("w:test"); - // eslint-disable-next-line functional/immutable-data + xmlComponent.push( new Attributes({ val: "test", diff --git a/src/file/xml-components/xmlable-object.ts b/src/file/xml-components/xmlable-object.ts index ac6811e37ff..f1fcf935105 100644 --- a/src/file/xml-components/xmlable-object.ts +++ b/src/file/xml-components/xmlable-object.ts @@ -1,12 +1,11 @@ -export interface IXmlAttribute { - readonly [key: string]: string | number | boolean; -} +export type IXmlAttribute = Readonly>; + +// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style, @typescript-eslint/consistent-type-definitions export interface IXmlableObject extends Record { // readonly _attr?: IXmlAttribute; // eslint-disable-next-line @typescript-eslint/no-explicit-any readonly [key: string]: any; } - // Needed because of: https://github.com/s-panferov/awesome-typescript-loader/issues/432 /** * @ignore diff --git a/src/patcher/content-types-manager.spec.ts b/src/patcher/content-types-manager.spec.ts index 7e4554cf5bb..4dd6527015a 100644 --- a/src/patcher/content-types-manager.spec.ts +++ b/src/patcher/content-types-manager.spec.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from "vitest"; + import { appendContentType } from "./content-types-manager"; describe("content-types-manager", () => { diff --git a/src/patcher/from-docx.spec.ts b/src/patcher/from-docx.spec.ts index cb8032fac6c..8eee52260c7 100644 --- a/src/patcher/from-docx.spec.ts +++ b/src/patcher/from-docx.spec.ts @@ -1,9 +1,9 @@ -import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import JSZip from "jszip"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { ExternalHyperlink, ImageRun, Paragraph, TextRun } from "@file/paragraph"; -import { patchDocument, PatchType } from "./from-docx"; +import { PatchType, patchDocument } from "./from-docx"; const MOCK_XML = ` diff --git a/src/patcher/from-docx.ts b/src/patcher/from-docx.ts index 8418b0c9659..fd472bdaccd 100644 --- a/src/patcher/from-docx.ts +++ b/src/patcher/from-docx.ts @@ -1,20 +1,20 @@ import JSZip from "jszip"; import { Element, js2xml } from "xml-js"; -import { ConcreteHyperlink, ExternalHyperlink, ParagraphChild } from "@file/paragraph"; -import { FileChild } from "@file/file-child"; -import { IMediaData, Media } from "@file/media"; +import { ImageReplacer } from "@export/packer/image-replacer"; import { IViewWrapper } from "@file/document-wrapper"; import { File } from "@file/file"; -import { IContext } from "@file/xml-components"; -import { ImageReplacer } from "@export/packer/image-replacer"; +import { FileChild } from "@file/file-child"; +import { IMediaData, Media } from "@file/media"; +import { ConcreteHyperlink, ExternalHyperlink, ParagraphChild } from "@file/paragraph"; import { TargetModeType } from "@file/relationships/relationship/relationship"; +import { IContext } from "@file/xml-components"; import { uniqueId } from "@util/convenience-functions"; +import { appendContentType } from "./content-types-manager"; +import { appendRelationship, getNextRelationshipIndex } from "./relationship-manager"; import { replacer } from "./replacer"; import { toJson } from "./util"; -import { appendRelationship, getNextRelationshipIndex } from "./relationship-manager"; -import { appendContentType } from "./content-types-manager"; // eslint-disable-next-line functional/prefer-readonly-type export type InputDataType = Buffer | string | number[] | Uint8Array | ArrayBuffer | Blob | NodeJS.ReadableStream; @@ -34,15 +34,15 @@ type FilePatch = { readonly children: readonly FileChild[]; }; -interface IImageRelationshipAddition { +type IImageRelationshipAddition = { readonly key: string; readonly mediaDatas: readonly IMediaData[]; -} +}; -interface IHyperlinkRelationshipAddition { +type IHyperlinkRelationshipAddition = { readonly key: string; readonly hyperlink: { readonly id: string; readonly link: string }; -} +}; export type IPatch = ParagraphPatch | FilePatch; @@ -65,7 +65,7 @@ export type PatchDocumentOutputType = keyof OutputByType; export type PatchDocumentOptions = { readonly outputType: T; readonly data: InputDataType; - readonly patches: { readonly [key: string]: IPatch }; + readonly patches: Readonly>; readonly keepOriginalStyles?: boolean; }; diff --git a/src/patcher/paragraph-split-inject.ts b/src/patcher/paragraph-split-inject.ts index 008d47c7fc2..c3033732cdc 100644 --- a/src/patcher/paragraph-split-inject.ts +++ b/src/patcher/paragraph-split-inject.ts @@ -1,4 +1,5 @@ import { Element } from "xml-js"; + import { createTextElementContents, patchSpaceAttribute } from "./util"; export const findRunElementIndexWithToken = (paragraphElement: Element, token: string): number => { diff --git a/src/patcher/paragraph-token-replacer.ts b/src/patcher/paragraph-token-replacer.ts index 906fcbf79e4..32eec3bbcc4 100644 --- a/src/patcher/paragraph-token-replacer.ts +++ b/src/patcher/paragraph-token-replacer.ts @@ -1,7 +1,7 @@ import { Element } from "xml-js"; -import { createTextElementContents, patchSpaceAttribute } from "./util"; import { IRenderedParagraphNode } from "./run-renderer"; +import { createTextElementContents, patchSpaceAttribute } from "./util"; const ReplaceMode = { START: 0, diff --git a/src/patcher/patch-detector.spec.ts b/src/patcher/patch-detector.spec.ts index dee2bb7ecc4..d239ae4f6bb 100644 --- a/src/patcher/patch-detector.spec.ts +++ b/src/patcher/patch-detector.spec.ts @@ -1,5 +1,6 @@ -import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import JSZip from "jszip"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; + import { patchDetector } from "./patch-detector"; const MOCK_XML = ` diff --git a/src/patcher/patch-detector.ts b/src/patcher/patch-detector.ts index 7ebcede0500..31756f0a6e5 100644 --- a/src/patcher/patch-detector.ts +++ b/src/patcher/patch-detector.ts @@ -1,7 +1,8 @@ import JSZip from "jszip"; -import { toJson } from "./util"; -import { traverse } from "./traverser"; + import { InputDataType } from "./from-docx"; +import { traverse } from "./traverser"; +import { toJson } from "./util"; type PatchDetectorOptions = { readonly data: InputDataType; diff --git a/src/patcher/relationship-manager.spec.ts b/src/patcher/relationship-manager.spec.ts index 32bf414423a..f4228f4e733 100644 --- a/src/patcher/relationship-manager.spec.ts +++ b/src/patcher/relationship-manager.spec.ts @@ -1,6 +1,7 @@ -import { TargetModeType } from "@file/relationships/relationship/relationship"; import { describe, expect, it } from "vitest"; +import { TargetModeType } from "@file/relationships/relationship/relationship"; + import { appendRelationship, getNextRelationshipIndex } from "./relationship-manager"; describe("relationship-manager", () => { diff --git a/src/patcher/relationship-manager.ts b/src/patcher/relationship-manager.ts index dbaf734b8a5..295c540662b 100644 --- a/src/patcher/relationship-manager.ts +++ b/src/patcher/relationship-manager.ts @@ -1,6 +1,7 @@ import { Element } from "xml-js"; import { RelationshipType, TargetModeType } from "@file/relationships/relationship/relationship"; + import { getFirstLevelElements } from "./util"; const getIdFromRelationshipId = (relationshipId: string): number => { diff --git a/src/patcher/replacer.spec.ts b/src/patcher/replacer.spec.ts index 12fdb27dc7e..f1e9650fcc8 100644 --- a/src/patcher/replacer.spec.ts +++ b/src/patcher/replacer.spec.ts @@ -1,11 +1,11 @@ +import { describe, expect, it, vi } from "vitest"; + import { IViewWrapper } from "@file/document-wrapper"; import { File } from "@file/file"; import { Paragraph, TextRun } from "@file/paragraph"; import { IContext } from "@file/xml-components"; -import { describe, expect, it, vi } from "vitest"; import { PatchType } from "./from-docx"; - import { replacer } from "./replacer"; export const MOCK_JSON = { diff --git a/src/patcher/replacer.ts b/src/patcher/replacer.ts index f9670c1fb02..ba4dc4334ab 100644 --- a/src/patcher/replacer.ts +++ b/src/patcher/replacer.ts @@ -1,14 +1,14 @@ -import { Element } from "xml-js"; import xml from "xml"; +import { Element } from "xml-js"; import { Formatter } from "@export/formatter"; import { IContext, XmlComponent } from "@file/xml-components"; import { IPatch, PatchType } from "./from-docx"; -import { toJson } from "./util"; -import { replaceTokenInParagraphElement } from "./paragraph-token-replacer"; import { findRunElementIndexWithToken, splitRunElement } from "./paragraph-split-inject"; +import { replaceTokenInParagraphElement } from "./paragraph-token-replacer"; import { findLocationOfText } from "./traverser"; +import { toJson } from "./util"; const formatter = new Formatter(); @@ -34,16 +34,13 @@ export const replacer = ({ } for (const renderedParagraph of renderedParagraphs) { - const textJson = patch.children - // eslint-disable-next-line no-loop-func - .map((c) => toJson(xml(formatter.format(c as XmlComponent, context)))) - .map((c) => c.elements![0]); + const textJson = patch.children.map((c) => toJson(xml(formatter.format(c as XmlComponent, context)))).map((c) => c.elements![0]); switch (patch.type) { case PatchType.DOCUMENT: { const parentElement = goToParentElementFromPath(json, renderedParagraph.pathToParagraph); const elementIndex = getLastElementIndexFromPath(renderedParagraph.pathToParagraph); - // eslint-disable-next-line functional/immutable-data, prefer-destructuring + // eslint-disable-next-line functional/immutable-data parentElement.elements!.splice(elementIndex, 1, ...textJson); break; } @@ -67,7 +64,7 @@ export const replacer = ({ if (keepOriginalStyles) { const runElementNonTextualElements = runElementToBeReplaced.elements!.filter( - (e) => e.type === "element" && e.name !== "w:t" && e.name !== "w:br", + (e) => e.type === "element" && e.name !== "w:t" && e.name !== "w:br" && e.name !== "w:tab", ); newRunElements = textJson.map((e) => ({ diff --git a/src/patcher/run-renderer.spec.ts b/src/patcher/run-renderer.spec.ts index 7d17d6c7ca4..8aca6090f8c 100644 --- a/src/patcher/run-renderer.spec.ts +++ b/src/patcher/run-renderer.spec.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from "vitest"; + import { renderParagraphNode } from "./run-renderer"; describe("run-renderer", () => { diff --git a/src/patcher/run-renderer.ts b/src/patcher/run-renderer.ts index 005ad71fe79..af0482cc4cf 100644 --- a/src/patcher/run-renderer.ts +++ b/src/patcher/run-renderer.ts @@ -2,17 +2,17 @@ import { Element } from "xml-js"; import { ElementWrapper } from "./traverser"; -export interface IRenderedParagraphNode { +export type IRenderedParagraphNode = { readonly text: string; readonly runs: readonly IRenderedRunNode[]; readonly index: number; readonly pathToParagraph: readonly number[]; -} +}; -interface StartAndEnd { +type StartAndEnd = { readonly start: number; readonly end: number; -} +}; type IParts = { readonly text: string; diff --git a/src/patcher/traverser.ts b/src/patcher/traverser.ts index 1ae16b57281..2df41859bc4 100644 --- a/src/patcher/traverser.ts +++ b/src/patcher/traverser.ts @@ -2,11 +2,11 @@ import { Element } from "xml-js"; import { IRenderedParagraphNode, renderParagraphNode } from "./run-renderer"; -export interface ElementWrapper { +export type ElementWrapper = { readonly element: Element; readonly index: number; readonly parent: ElementWrapper | undefined; -} +}; const elementsToWrapper = (wrapper: ElementWrapper): readonly ElementWrapper[] => wrapper.element.elements?.map((e, i) => ({ diff --git a/src/patcher/util.ts b/src/patcher/util.ts index 7bbc0a2dfd4..17159ebb127 100644 --- a/src/patcher/util.ts +++ b/src/patcher/util.ts @@ -1,5 +1,5 @@ -import { xml2js, Element } from "xml-js"; import xml from "xml"; +import { Element, xml2js } from "xml-js"; import { Formatter } from "@export/formatter"; import { Text } from "@file/paragraph/run/run-components/text"; diff --git a/src/util/convenience-functions.spec.ts b/src/util/convenience-functions.spec.ts index c283bdf14fd..29b1b745f45 100644 --- a/src/util/convenience-functions.spec.ts +++ b/src/util/convenience-functions.spec.ts @@ -7,8 +7,8 @@ import { convertInchesToTwip, convertMillimetersToTwip, docPropertiesUniqueNumericIdGen, - uniqueId, hashedId, + uniqueId, uniqueNumericIdCreator, uniqueUuid, } from "./convenience-functions"; diff --git a/src/util/convenience-functions.ts b/src/util/convenience-functions.ts index 7e9a69bf90f..6c9eb3e3884 100644 --- a/src/util/convenience-functions.ts +++ b/src/util/convenience-functions.ts @@ -1,5 +1,5 @@ -import { nanoid, customAlphabet } from "nanoid/non-secure"; import hash from "hash.js"; +import { customAlphabet, nanoid } from "nanoid/non-secure"; // Twip - twentieths of a point export const convertMillimetersToTwip = (millimeters: number): number => Math.floor((millimeters / 25.4) * 72 * 20); diff --git a/src/util/values.spec.ts b/src/util/values.spec.ts index 0506f9589dc..e68713e7dd5 100644 --- a/src/util/values.spec.ts +++ b/src/util/values.spec.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from "vitest"; + import { dateTimeValue, hexColorValue,