build(deps-dev): bump eslint from 8.57.1 to 9.13.0 (#2792)

* build(deps-dev): bump eslint from 8.57.1 to 9.13.0

Bumps [eslint](https://github.com/eslint/eslint) from 8.57.1 to 9.13.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.57.1...v9.13.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Upgrade EsLint

* Fix all new lint errors

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dolan Miu <dolan_miu@hotmail.com>
This commit is contained in:
dependabot[bot]
2024-10-21 03:57:15 +01:00
committed by GitHub
parent 9cff0b2a57
commit 2381ba8a05
214 changed files with 1583 additions and 1586 deletions

View File

@ -1,4 +1,5 @@
import { describe, expect, it } from "vitest";
import { appendContentType } from "./content-types-manager";
describe("content-types-manager", () => {

View File

@ -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 = `
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

View File

@ -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<T extends PatchDocumentOutputType = PatchDocumentOutputType> = {
readonly outputType: T;
readonly data: InputDataType;
readonly patches: { readonly [key: string]: IPatch };
readonly patches: Readonly<Record<string, IPatch>>;
readonly keepOriginalStyles?: boolean;
};
@ -134,7 +134,6 @@ export const patchDocument = async <T extends PatchDocumentOutputType = PatchDoc
// This algorithm is limited to one patch per text run
// Once it cannot find any more occurrences, it will throw an error, and then we break out of the loop
// https://github.com/dolanmiu/docx/issues/2267
// eslint-disable-next-line no-constant-condition
while (true) {
try {
replacer({

View File

@ -1,4 +1,5 @@
import { Element } from "xml-js";
import { createTextElementContents, patchSpaceAttribute } from "./util";
export const findRunElementIndexWithToken = (paragraphElement: Element, token: string): number => {

View File

@ -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,

View File

@ -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 = `

View File

@ -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;

View File

@ -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", () => {

View File

@ -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 => {

View File

@ -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 = {

View File

@ -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) => ({

View File

@ -1,4 +1,5 @@
import { describe, expect, it } from "vitest";
import { renderParagraphNode } from "./run-renderer";
describe("run-renderer", () => {

View File

@ -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;

View File

@ -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) => ({
@ -27,7 +27,6 @@ export const traverse = (node: Element): readonly IRenderedParagraphNode[] => {
}),
];
// eslint-disable-next-line functional/immutable-data
let currentNode: ElementWrapper | undefined;
while (queue.length > 0) {
// eslint-disable-next-line functional/immutable-data

View File

@ -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";