diff --git a/package-lock.json b/package-lock.json index 0cf0860d28..878af22c12 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "docx", - "version": "5.2.2", + "version": "5.3.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1029,7 +1029,7 @@ }, "util": { "version": "0.10.3", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", + "resolved": "http://registry.npmjs.org/util/-/util-0.10.3.tgz", "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", "dev": true, "requires": { @@ -1058,7 +1058,7 @@ }, "async": { "version": "0.9.2", - "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", + "resolved": "http://registry.npmjs.org/async/-/async-0.9.2.tgz", "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=", "dev": true }, @@ -1132,7 +1132,7 @@ }, "chalk": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { @@ -1881,7 +1881,7 @@ }, "commander": { "version": "2.15.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "resolved": "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz", "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", "dev": true }, @@ -3015,7 +3015,7 @@ }, "fast-deep-equal": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", + "resolved": "http://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=", "dev": true }, @@ -4843,7 +4843,7 @@ }, "jsesc": { "version": "1.3.0", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz", + "resolved": "http://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz", "integrity": "sha1-RsP+yMGJKxKwgz25vHYiF226s0s=", "dev": true }, @@ -5098,7 +5098,7 @@ }, "load-json-file": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "dev": true, "requires": { @@ -5430,7 +5430,7 @@ }, "mkdirp": { "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, "requires": { @@ -6103,7 +6103,7 @@ }, "os-locale": { "version": "1.4.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", + "resolved": "http://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", "dev": true, "requires": { @@ -6315,7 +6315,7 @@ }, "path-is-absolute": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, @@ -6392,7 +6392,7 @@ }, "pify": { "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true }, @@ -6492,9 +6492,9 @@ "dev": true }, "prettier": { - "version": "1.18.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.18.2.tgz", - "integrity": "sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.5.tgz", + "integrity": "sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==", "dev": true }, "prismjs": { @@ -7701,7 +7701,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { @@ -8195,7 +8195,7 @@ }, "yargs": { "version": "3.10.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", + "resolved": "http://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", "dev": true, "requires": { @@ -8620,7 +8620,7 @@ }, "load-json-file": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", + "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", "dev": true, "requires": { @@ -8836,13 +8836,13 @@ "dependencies": { "async": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/async/-/async-1.0.0.tgz", + "resolved": "http://registry.npmjs.org/async/-/async-1.0.0.tgz", "integrity": "sha1-+PwEyjoTeErenhZBr5hXjPvWR6k=", "dev": true }, "colors": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz", + "resolved": "http://registry.npmjs.org/colors/-/colors-1.0.3.tgz", "integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=", "dev": true }, @@ -8856,7 +8856,7 @@ }, "wrap-ansi": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", "dev": true, "requires": { @@ -8989,7 +8989,7 @@ }, "yargs": { "version": "4.8.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-4.8.1.tgz", + "resolved": "http://registry.npmjs.org/yargs/-/yargs-4.8.1.tgz", "integrity": "sha1-wMQpJMpKqmsObaFznfshZDn53cA=", "dev": true, "requires": { @@ -9033,7 +9033,7 @@ }, "yargs-parser": { "version": "2.4.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-2.4.1.tgz", + "resolved": "http://registry.npmjs.org/yargs-parser/-/yargs-parser-2.4.1.tgz", "integrity": "sha1-hVaN488VD/SfpRgl8DqMiA3cxcQ=", "dev": true, "requires": { diff --git a/package.json b/package.json index a772332568..f00c621bad 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "mocha-webpack": "^1.0.1", "nyc": "^15.1.0", "pre-commit": "^1.2.2", - "prettier": "^1.15.2", + "prettier": "^2.0.5", "prompt": "^1.0.0", "replace-in-file": "^3.1.0", "request": "^2.88.0", diff --git a/src/export/packer/next-compiler.spec.ts b/src/export/packer/next-compiler.spec.ts index 7c48569793..7c9bcda904 100644 --- a/src/export/packer/next-compiler.spec.ts +++ b/src/export/packer/next-compiler.spec.ts @@ -16,7 +16,7 @@ describe("Compiler", () => { }); describe("#compile()", () => { - it("should pack all the content", async function() { + it("should pack all the content", async function () { this.timeout(99999999); const zipFile = compiler.compile(file); const fileNames = Object.keys(zipFile.files).map((f) => zipFile.files[f].name); @@ -35,7 +35,7 @@ describe("Compiler", () => { expect(fileNames).to.include("_rels/.rels"); }); - it("should pack all additional headers and footers", async function() { + it("should pack all additional headers and footers", async function () { file.addSection({ headers: { default: new Header(), diff --git a/src/export/packer/packer.spec.ts b/src/export/packer/packer.spec.ts index 8235649f15..18ae459b49 100644 --- a/src/export/packer/packer.spec.ts +++ b/src/export/packer/packer.spec.ts @@ -36,7 +36,7 @@ describe("Packer", () => { }); describe("#toBuffer()", () => { - it("should create a standard docx file", async function() { + it("should create a standard docx file", async function () { this.timeout(99999999); const buffer = await Packer.toBuffer(file); @@ -61,7 +61,7 @@ describe("Packer", () => { }); describe("#toBase64String()", () => { - it("should create a standard docx file", async function() { + it("should create a standard docx file", async function () { this.timeout(99999999); const str = await Packer.toBase64String(file); diff --git a/src/file/media/media.ts b/src/file/media/media.ts index 0d062c6d64..71e7c6f60e 100644 --- a/src/file/media/media.ts +++ b/src/file/media/media.ts @@ -21,14 +21,7 @@ export class Media { private static generateId(): string { // https://gist.github.com/6174/6062387 - return ( - Math.random() - .toString(36) - .substring(2, 15) + - Math.random() - .toString(36) - .substring(2, 15) - ); + return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15); } private readonly map: Map; diff --git a/src/file/paragraph/paragraph.spec.ts b/src/file/paragraph/paragraph.spec.ts index cdbe99c7d8..04cc8af8e4 100644 --- a/src/file/paragraph/paragraph.spec.ts +++ b/src/file/paragraph/paragraph.spec.ts @@ -542,14 +542,8 @@ describe("Paragraph", () => { }, }); const tree = new Formatter().format(paragraph); - expect(tree) - .to.have.property("w:p") - .which.is.an("array") - .which.has.length.at.least(1); - expect(tree["w:p"][0]) - .to.have.property("w:pPr") - .which.is.an("array") - .which.has.length.at.least(1); + expect(tree).to.have.property("w:p").which.is.an("array").which.has.length.at.least(1); + expect(tree["w:p"][0]).to.have.property("w:pPr").which.is.an("array").which.has.length.at.least(1); expect(tree["w:p"][0]["w:pPr"][0]).to.deep.equal({ "w:pStyle": { _attr: { "w:val": "ListParagraph" } }, }); @@ -562,14 +556,8 @@ describe("Paragraph", () => { }, }); const tree = new Formatter().format(paragraph); - expect(tree) - .to.have.property("w:p") - .which.is.an("array") - .which.has.length.at.least(1); - expect(tree["w:p"][0]) - .to.have.property("w:pPr") - .which.is.an("array") - .which.has.length.at.least(1); + expect(tree).to.have.property("w:p").which.is.an("array").which.has.length.at.least(1); + expect(tree["w:p"][0]).to.have.property("w:pPr").which.is.an("array").which.has.length.at.least(1); expect(tree["w:p"][0]["w:pPr"][0]).to.deep.equal({ "w:pStyle": { _attr: { "w:val": "ListParagraph" } }, }); @@ -582,14 +570,8 @@ describe("Paragraph", () => { }, }); const tree = new Formatter().format(paragraph); - expect(tree) - .to.have.property("w:p") - .which.is.an("array") - .which.has.length.at.least(1); - expect(tree["w:p"][0]) - .to.have.property("w:pPr") - .which.is.an("array") - .which.has.length.at.least(2); + expect(tree).to.have.property("w:p").which.is.an("array").which.has.length.at.least(1); + expect(tree["w:p"][0]).to.have.property("w:pPr").which.is.an("array").which.has.length.at.least(2); expect(tree["w:p"][0]["w:pPr"][1]).to.deep.equal({ "w:numPr": [{ "w:ilvl": { _attr: { "w:val": 1 } } }, { "w:numId": { _attr: { "w:val": 1 } } }], }); @@ -605,14 +587,8 @@ describe("Paragraph", () => { }, }); const tree = new Formatter().format(paragraph); - expect(tree) - .to.have.property("w:p") - .which.is.an("array") - .which.has.length.at.least(1); - expect(tree["w:p"][0]) - .to.have.property("w:pPr") - .which.is.an("array") - .which.has.length.at.least(1); + expect(tree).to.have.property("w:p").which.is.an("array").which.has.length.at.least(1); + expect(tree["w:p"][0]).to.have.property("w:pPr").which.is.an("array").which.has.length.at.least(1); expect(tree["w:p"][0]["w:pPr"][0]).to.deep.equal({ "w:pStyle": { _attr: { "w:val": "ListParagraph" } }, }); diff --git a/src/file/table/table.spec.ts b/src/file/table/table.spec.ts index 49eb7a3f46..3165330047 100644 --- a/src/file/table/table.spec.ts +++ b/src/file/table/table.spec.ts @@ -268,10 +268,7 @@ describe("Table", () => { layout: TableLayoutType.FIXED, }); const tree = new Formatter().format(table); - expect(tree) - .to.have.property("w:tbl") - .which.is.an("array") - .with.has.length.at.least(1); + expect(tree).to.have.property("w:tbl").which.is.an("array").with.has.length.at.least(1); expect(tree["w:tbl"][0]).to.deep.equal({ "w:tblPr": [DEFAULT_TABLE_PROPERTIES, BORDERS, WIDTHS, { "w:tblLayout": { _attr: { "w:type": "fixed" } } }], }); @@ -291,10 +288,7 @@ describe("Table", () => { alignment: AlignmentType.CENTER, }); const tree = new Formatter().format(table); - expect(tree) - .to.have.property("w:tbl") - .which.is.an("array") - .with.has.length.at.least(1); + expect(tree).to.have.property("w:tbl").which.is.an("array").with.has.length.at.least(1); expect(tree["w:tbl"][0]).to.deep.equal({ "w:tblPr": [DEFAULT_TABLE_PROPERTIES, BORDERS, WIDTHS, { "w:jc": { _attr: { "w:val": "center" } } }], }); @@ -318,10 +312,7 @@ describe("Table", () => { layout: TableLayoutType.FIXED, }); const tree = new Formatter().format(table); - expect(tree) - .to.have.property("w:tbl") - .which.is.an("array") - .with.has.length.at.least(1); + expect(tree).to.have.property("w:tbl").which.is.an("array").with.has.length.at.least(1); expect(tree["w:tbl"][0]).to.deep.equal({ "w:tblPr": [ DEFAULT_TABLE_PROPERTIES, @@ -355,14 +346,10 @@ describe("Table", () => { ], }); const tree = new Formatter().format(table); - expect(tree) - .to.have.property("w:tbl") - .which.is.an("array"); + expect(tree).to.have.property("w:tbl").which.is.an("array"); const row = tree["w:tbl"].find((x) => x["w:tr"]); expect(row).not.to.be.undefined; - expect(row["w:tr"]) - .to.be.an("array") - .which.has.length.at.least(1); + expect(row["w:tr"]).to.be.an("array").which.has.length.at.least(1); expect(row["w:tr"].find((x) => x["w:tc"])).to.deep.equal({ "w:tc": [ { @@ -487,10 +474,7 @@ describe("Table", () => { }, }); const tree = new Formatter().format(table); - expect(tree) - .to.have.property("w:tbl") - .which.is.an("array") - .with.has.length.at.least(1); + expect(tree).to.have.property("w:tbl").which.is.an("array").with.has.length.at.least(1); expect(tree["w:tbl"][0]).to.deep.equal({ "w:tblPr": [ DEFAULT_TABLE_PROPERTIES,