From 13a4e0ba33673de55d2f5f4c3ea5706ad8468345 Mon Sep 17 00:00:00 2001 From: Andreas Lubbe Date: Mon, 28 Sep 2020 12:13:37 +0200 Subject: [PATCH 1/4] Run linter with prettier 2.0 --- benchmark.js | 4 +- lib/csv/csv.js | 8 +- lib/csv/line-buffer.js | 2 +- lib/csv/stream-converter.js | 2 +- lib/doc/cell.js | 6 +- lib/doc/column.js | 2 +- lib/doc/defined-names.js | 20 +- lib/doc/modelcontainer.js | 2 +- lib/doc/range.js | 2 +- lib/doc/row.js | 12 +- lib/doc/table.js | 10 +- lib/doc/workbook.js | 14 +- lib/doc/worksheet.js | 40 ++-- lib/exceljs.bare.js | 2 +- lib/exceljs.browser.js | 2 +- lib/stream/xlsx/sheet-comments-writer.js | 4 +- lib/stream/xlsx/workbook-writer.js | 26 +-- lib/stream/xlsx/worksheet-writer.js | 10 +- lib/utils/cell-matrix.js | 4 +- lib/utils/iterate-stream.js | 8 +- lib/utils/parse-sax.js | 10 +- lib/utils/stream-base64.js | 2 +- lib/utils/stream-buf.js | 12 +- lib/utils/under-dash.js | 15 +- lib/utils/utils.js | 14 +- lib/xlsx/xform/base-xform.js | 2 +- lib/xlsx/xform/book/defined-name-xform.js | 2 +- lib/xlsx/xform/book/workbook-xform.js | 8 +- lib/xlsx/xform/comment/comment-xform.js | 2 +- lib/xlsx/xform/comment/comments-xform.js | 2 +- lib/xlsx/xform/comment/vml-notes-xform.js | 2 +- lib/xlsx/xform/comment/vml-textbox-xform.js | 4 +- .../xform/core/app-titles-of-parts-xform.js | 2 +- lib/xlsx/xform/core/content-types-xform.js | 8 +- lib/xlsx/xform/core/relationships-xform.js | 2 +- lib/xlsx/xform/drawing/drawing-xform.js | 4 +- lib/xlsx/xform/list-xform.js | 2 +- lib/xlsx/xform/sheet/cell-xform.js | 2 +- .../conditional-formatting-ext-xform.js | 4 +- .../conditional-formattings-ext-xform.js | 100 +++++----- .../xform/sheet/cf-ext/databar-ext-xform.js | 2 +- .../xform/sheet/cf-ext/icon-set-ext-xform.js | 2 +- lib/xlsx/xform/sheet/cf/cf-rule-xform.js | 8 +- lib/xlsx/xform/sheet/cf/color-scale-xform.js | 4 +- .../sheet/cf/conditional-formatting-xform.js | 2 +- .../sheet/cf/conditional-formattings-xform.js | 178 +++++++++--------- lib/xlsx/xform/sheet/cf/databar-xform.js | 2 +- lib/xlsx/xform/sheet/cf/icon-set-xform.js | 2 +- .../xform/sheet/data-validations-xform.js | 8 +- lib/xlsx/xform/sheet/merges.js | 4 +- .../xform/sheet/outline-properties-xform.js | 2 +- lib/xlsx/xform/sheet/page-margins-xform.js | 2 +- lib/xlsx/xform/sheet/page-setup-xform.js | 2 +- lib/xlsx/xform/sheet/print-options-xform.js | 2 +- lib/xlsx/xform/sheet/row-breaks-xform.js | 2 +- lib/xlsx/xform/sheet/row-xform.js | 8 +- .../sheet/sheet-format-properties-xform.js | 2 +- .../xform/sheet/sheet-protection-xform.js | 2 +- lib/xlsx/xform/sheet/worksheet-xform.js | 30 +-- lib/xlsx/xform/static-xform.js | 2 +- lib/xlsx/xform/strings/phonetic-text-xform.js | 2 +- lib/xlsx/xform/strings/shared-string-xform.js | 2 +- .../xform/strings/shared-strings-xform.js | 2 +- lib/xlsx/xform/style/fill-xform.js | 2 +- lib/xlsx/xform/style/styles-xform.js | 12 +- lib/xlsx/xform/table/auto-filter-xform.js | 2 +- lib/xlsx/xform/table/table-xform.js | 2 +- lib/xlsx/xlsx.js | 30 +-- package.json | 24 +-- spec/browser/exceljs.spec.js | 18 +- ...ue-1328-xlsx-worksheet-reader-date.spec.js | 35 ++-- .../issues/issue-219-1904-dates.spec.js | 2 +- .../issue-234-vertical-tab-char.spec.js | 2 +- .../issues/issue-257-sheet-order.spec.js | 2 +- .../issue-275-hyperlink-query-param.spec.js | 2 +- .../issue-623-borders-for-merged-cell.spec.js | 4 +- .../issue-703-speciel-cell-file.spec.js | 2 +- ...e-771-data-validation-without-type.spec.js | 4 +- .../issues/issue-991-csv-read-dates.spec.js | 2 +- .../integration/pr/pr-896/test-pr-896.spec.js | 2 +- spec/integration/pr/test-pr-1431.spec.js | 23 ++- spec/integration/pr/test-pr-896.spec.js | 4 +- spec/integration/workbook-xlsx-reader.spec.js | 28 +-- .../workbook-xlsx-writer.spec.js | 26 +-- spec/integration/workbook/images.spec.js | 12 +- spec/integration/workbook/styles.spec.js | 6 +- spec/integration/workbook/workbook.spec.js | 62 +++--- .../integration/worksheet-xlsx-writer.spec.js | 2 +- spec/integration/worksheet.spec.js | 12 +- spec/unit/doc/defined-names.spec.js | 4 +- spec/unit/doc/workbook.spec.js | 2 +- spec/unit/doc/worksheet-table.spec.js | 2 +- spec/unit/doc/worksheet.values.spec.js | 4 +- spec/unit/utils/stream-buf.spec.js | 2 +- spec/unit/utils/utils.spec.js | 4 +- .../xform/book/defined-name-xform.spec.js | 2 +- .../workbook-calc-properties-xform.spec.js | 2 +- .../book/workbook-properties-xform.spec.js | 2 +- .../xform/book/workbook-view-xform.spec.js | 2 +- spec/unit/xlsx/xform/compy-xform.js | 154 +++++++-------- .../xform/core/content-types-xform.spec.js | 2 +- spec/unit/xlsx/xform/core/core-xform.spec.js | 2 +- .../xform/core/relationships-xform.spec.js | 2 +- .../xform/drawing/blip-fill-xform.spec.js | 2 +- .../xlsx/xform/drawing/blip-xform.spec.js | 2 +- .../xform/drawing/cell-position-xform.spec.js | 2 +- .../xlsx/xform/drawing/drawing-xform.spec.js | 2 +- .../xform/sheet/auto-filter-xform.spec.js | 2 +- spec/unit/xlsx/xform/sheet/cell-xform.spec.js | 2 +- spec/unit/xlsx/xform/sheet/col-xform.spec.js | 2 +- .../sheet/data-validations-xform.spec.js | 2 +- .../xlsx/xform/sheet/dimension-xform.spec.js | 2 +- .../xform/sheet/header-footer-xform.spec.js | 2 +- .../xlsx/xform/sheet/hyperlink-xform.spec.js | 2 +- .../xlsx/xform/sheet/merge-cell-xform.spec.js | 2 +- .../sheet/outline-properties-xform.spec.js | 2 +- .../xform/sheet/page-breaks-xform.spec.js | 2 +- .../xform/sheet/page-margins-xform.spec.js | 2 +- .../sheet/page-setup-properties-xform.spec.js | 2 +- .../xlsx/xform/sheet/page-setup-xform.spec.js | 2 +- .../xform/sheet/print-options-xform.spec.js | 2 +- spec/unit/xlsx/xform/sheet/row-xform.spec.js | 2 +- .../sheet-format-properties-xform.spec.js | 2 +- .../sheet/sheet-properties-xform.spec.js | 2 +- .../xlsx/xform/sheet/sheet-view-xform.spec.js | 2 +- .../xlsx/xform/simple/boolean-xform.spec.js | 2 +- .../unit/xlsx/xform/simple/date-xform.spec.js | 2 +- .../xlsx/xform/simple/float-xform.spec.js | 2 +- .../xlsx/xform/simple/integer-xform.spec.js | 2 +- .../xlsx/xform/simple/string-xform.spec.js | 2 +- .../xform/strings/phonetic-text-xform.spec.js | 2 +- .../xlsx/xform/style/alignment-xform.spec.js | 2 +- .../xlsx/xform/style/border-xform.spec.js | 2 +- .../unit/xlsx/xform/style/color-xform.spec.js | 2 +- spec/unit/xlsx/xform/style/fill-xform.spec.js | 2 +- spec/unit/xlsx/xform/style/font-xform.spec.js | 2 +- .../xlsx/xform/style/numfmt-xform.spec.js | 2 +- .../xlsx/xform/style/styles-xform.spec.js | 2 +- .../xlsx/xform/style/underline-xform.spec.js | 2 +- .../xform/table/auto-filter-xform.spec.js | 84 ++++----- .../xform/table/filter-column-xform.spec.js | 76 ++++---- .../xform/table/table-column-xform.spec.js | 60 +++--- .../table/table-style-info-xform.spec.js | 96 +++++----- .../unit/xlsx/xform/table/table-xform.spec.js | 46 ++--- spec/unit/xlsx/xform/test-xform-helper.js | 18 +- spec/utils/index.js | 4 +- .../test-conditional-formatting-sheet.js | 4 +- spec/utils/test-data-validation-sheet.js | 6 +- spec/utils/test-spliced-sheet.js | 72 +++---- spec/utils/test-values-sheet.js | 2 +- spec/utils/test-workbook-reader.js | 4 +- spec/utils/tools.js | 2 +- test/test-a1.js | 2 +- test/test-cf.js | 2 +- test/test-chart.js | 2 +- test/test-colour-cell.js | 2 +- test/test-comment-new.js | 2 +- test/test-comment-stream-writer.js | 2 +- test/test-comments.js | 2 +- test/test-copy.js | 2 +- test/test-default-height.js | 2 +- test/test-formula.js | 4 +- test/test-header-footer.js | 2 +- test/test-hyperlink.js | 2 +- test/test-image-one-cell-anchor.js | 2 +- test/test-image-oneCell.js | 2 +- test/test-image-out.js | 2 +- test/test-image-stream-writer.js | 2 +- test/test-jszip.js | 4 +- test/test-merge-align.js | 2 +- test/test-newline.js | 2 +- test/test-protection-spinCount.js | 2 +- test/test-protection.js | 2 +- test/test-table.js | 2 +- test/testArray.js | 2 +- test/testBigBookIn.js | 6 +- test/testBigBookOut.js | 2 +- test/testBookFont.js | 8 +- test/testBookOut.js | 2 +- test/testBookOutS.js | 2 +- test/testBookRead.js | 4 +- test/testCsvOut.js | 2 +- test/testImageIn.js | 2 +- test/testMergedBorder.js | 2 +- test/testMultiplePrintAreaOut.js | 2 +- test/testPerformance.js | 12 +- test/testPrintAreaOut.js | 2 +- test/testPrintColRowOut.js | 2 +- test/testProcess.js | 4 +- test/testSax2.js | 6 +- test/testSharedStrings.js | 2 +- test/testStringBuf.js | 2 +- test/testStringtable.js | 2 +- test/testTemplate.js | 4 +- test/testXlsxIn.js | 2 +- test/utils/column-sum.js | 6 +- test/utils/utils.js | 4 +- 197 files changed, 921 insertions(+), 914 deletions(-) diff --git a/benchmark.js b/benchmark.js index ca698f02d..ce854a0ba 100644 --- a/benchmark.js +++ b/benchmark.js @@ -13,10 +13,10 @@ const runs = 3; let worksheetCount = 0; let rowCount = 0; - workbookReader.on('worksheet', worksheet => { + workbookReader.on('worksheet', (worksheet) => { worksheetCount += 1; console.log(`Reading worksheet ${worksheetCount}`); - worksheet.on('row', row => { + worksheet.on('row', (row) => { rowCount += 1; if (rowCount % 50000 === 0) console.log(`Reading row ${rowCount}`); }); diff --git a/lib/csv/csv.js b/lib/csv/csv.js index 79c99daf0..8bb95c840 100644 --- a/lib/csv/csv.js +++ b/lib/csv/csv.js @@ -2,9 +2,7 @@ const fs = require('fs'); const fastCsv = require('fast-csv'); const customParseFormat = require('dayjs/plugin/customParseFormat'); const utc = require('dayjs/plugin/utc'); -const dayjs = require('dayjs') - .extend(customParseFormat) - .extend(utc); +const dayjs = require('dayjs').extend(customParseFormat).extend(utc); const StreamBuf = require('../utils/stream-buf'); const { @@ -81,7 +79,7 @@ class CSV { const csvStream = fastCsv .parse(options.parserOptions) - .on('data', data => { + .on('data', (data) => { worksheet.addRow(data.map(map)); }) .on('end', () => { @@ -122,7 +120,7 @@ class CSV { const {dateFormat, dateUTC} = options; const map = options.map || - (value => { + ((value) => { if (value) { if (value.text || value.hyperlink) { return value.hyperlink || value.text || ''; diff --git a/lib/csv/line-buffer.js b/lib/csv/line-buffer.js index 8ea489c96..a97ea4254 100644 --- a/lib/csv/line-buffer.js +++ b/lib/csv/line-buffer.js @@ -63,7 +63,7 @@ class LineBuffer extends EventEmitter { _flush() { if (!this.corked) { - this.queue.forEach(line => { + this.queue.forEach((line) => { this.emit('line', line); }); this.queue = []; diff --git a/lib/csv/stream-converter.js b/lib/csv/stream-converter.js index 639aa5b7d..49638c4ab 100644 --- a/lib/csv/stream-converter.js +++ b/lib/csv/stream-converter.js @@ -105,7 +105,7 @@ class StreamConverter { on(type, callback) { switch (type) { case 'data': - this.inner.on('data', chunk => { + this.inner.on('data', (chunk) => { callback(this.convertOutwards(chunk)); }); return this; diff --git a/lib/doc/cell.js b/lib/doc/cell.js index 3ae2457a8..cf7fb3750 100644 --- a/lib/doc/cell.js +++ b/lib/doc/cell.js @@ -292,7 +292,7 @@ class Cell { set names(value) { const {definedNames} = this.workbook; definedNames.removeAllNames(this.fullAddress); - value.forEach(name => { + value.forEach((name) => { definedNames.addEx(this.fullAddress, name); }); } @@ -509,7 +509,7 @@ class RichTextValue { } toString() { - return this.model.value.richText.map(t => t.text).join(''); + return this.model.value.richText.map((t) => t.text).join(''); } get type() { @@ -748,7 +748,7 @@ class FormulaValue { _copyModel(model) { const copy = {}; - const cp = name => { + const cp = (name) => { const value = model[name]; if (value) { copy[name] = value; diff --git a/lib/doc/column.js b/lib/doc/column.js index e5f8ceef0..6283407e2 100644 --- a/lib/doc/column.js +++ b/lib/doc/column.js @@ -198,7 +198,7 @@ class Column { // styles _applyStyle(name, value) { this.style[name] = value; - this.eachCell(cell => { + this.eachCell((cell) => { cell[name] = value; }); return value; diff --git a/lib/doc/defined-names.js b/lib/doc/defined-names.js index 597744207..522792f8a 100644 --- a/lib/doc/defined-names.js +++ b/lib/doc/defined-names.js @@ -54,14 +54,14 @@ class DefinedNames { } removeAllNames(location) { - _.each(this.matrixMap, matrix => { + _.each(this.matrixMap, (matrix) => { matrix.removeCellEx(location); }); } forEach(callback) { _.each(this.matrixMap, (matrix, name) => { - matrix.forEach(cell => { + matrix.forEach((cell) => { callback(name, cell); }); }); @@ -128,13 +128,13 @@ class DefinedNames { } // mark and sweep! - matrix.forEach(cell => { + matrix.forEach((cell) => { cell.mark = true; }); const ranges = matrix - .map(cell => cell.mark && this._explore(matrix, cell)) + .map((cell) => cell.mark && this._explore(matrix, cell)) .filter(Boolean) - .map(range => range.$shortRange); + .map((range) => range.$shortRange); return { name, @@ -157,14 +157,14 @@ class DefinedNames { } spliceRows(sheetName, start, numDelete, numInsert) { - _.each(this.matrixMap, matrix => { + _.each(this.matrixMap, (matrix) => { matrix.spliceRows(sheetName, start, numDelete, numInsert); this.normaliseMatrix(matrix, sheetName); }); } spliceColumns(sheetName, start, numDelete, numInsert) { - _.each(this.matrixMap, matrix => { + _.each(this.matrixMap, (matrix) => { matrix.spliceColumns(sheetName, start, numDelete, numInsert); this.normaliseMatrix(matrix, sheetName); }); @@ -172,15 +172,15 @@ class DefinedNames { get model() { // To get names per cell - just iterate over all names finding cells if they exist - return _.map(this.matrixMap, (matrix, name) => this.getRanges(name, matrix)).filter(definedName => definedName.ranges.length); + return _.map(this.matrixMap, (matrix, name) => this.getRanges(name, matrix)).filter((definedName) => definedName.ranges.length); } set model(value) { // value is [ { name, ranges }, ... ] const matrixMap = (this.matrixMap = {}); - value.forEach(definedName => { + value.forEach((definedName) => { const matrix = (matrixMap[definedName.name] = new CellMatrix()); - definedName.ranges.forEach(rangeStr => { + definedName.ranges.forEach((rangeStr) => { if (rangeRegexp.test(rangeStr.split('!').pop() || '')) { matrix.addCell(rangeStr); } diff --git a/lib/doc/modelcontainer.js b/lib/doc/modelcontainer.js index b60e1a3d2..ef0fb9249 100644 --- a/lib/doc/modelcontainer.js +++ b/lib/doc/modelcontainer.js @@ -1,6 +1,6 @@ 'use strict'; -const XLSX = require('./../xlsx/xlsx'); +const XLSX = require('../xlsx/xlsx'); class ModelContainer { constructor(model) { diff --git a/lib/doc/range.js b/lib/doc/range.js index acba915b4..ff0ef8c00 100644 --- a/lib/doc/range.js +++ b/lib/doc/range.js @@ -1,4 +1,4 @@ -const colCache = require('./../utils/col-cache'); +const colCache = require('../utils/col-cache'); // used by worksheet to calculate sheet dimensions class Range { diff --git a/lib/doc/row.js b/lib/doc/row.js index 520cc7fe9..caa1c1895 100644 --- a/lib/doc/row.js +++ b/lib/doc/row.js @@ -165,7 +165,7 @@ class Row { // return a sparse array of cell values get values() { const values = []; - this._cells.forEach(cell => { + this._cells.forEach((cell) => { if (cell && cell.type !== Enums.ValueType.Null) { values[cell.col] = cell.value; } @@ -210,7 +210,7 @@ class Row { // returns true if the row includes at least one cell with a value get hasValues() { - return _.some(this._cells, cell => cell && cell.type !== Enums.ValueType.Null); + return _.some(this._cells, (cell) => cell && cell.type !== Enums.ValueType.Null); } get cellCount() { @@ -229,7 +229,7 @@ class Row { get dimensions() { let min = 0; let max = 0; - this._cells.forEach(cell => { + this._cells.forEach((cell) => { if (cell && cell.type !== Enums.ValueType.Null) { if (!min || min > cell.col) { min = cell.col; @@ -251,7 +251,7 @@ class Row { // styles _applyStyle(name, value) { this.style[name] = value; - this._cells.forEach(cell => { + this._cells.forEach((cell) => { if (cell) { cell[name] = value; } @@ -332,7 +332,7 @@ class Row { const cells = []; let min = 0; let max = 0; - this._cells.forEach(cell => { + this._cells.forEach((cell) => { if (cell) { const cellModel = cell.model; if (cellModel) { @@ -368,7 +368,7 @@ class Row { } this._cells = []; let previousAddress; - value.cells.forEach(cellModel => { + value.cells.forEach((cellModel) => { switch (cellModel.type) { case Cell.Types.Merge: // special case - don't add this types diff --git a/lib/doc/table.js b/lib/doc/table.js index 112b2e80b..a5c565ed8 100644 --- a/lib/doc/table.js +++ b/lib/doc/table.js @@ -1,5 +1,5 @@ /* eslint-disable max-classes-per-file */ -const colCache = require('./../utils/col-cache'); +const colCache = require('../utils/col-cache'); class Column { // wrapper around column model, allowing access and manipulation @@ -182,7 +182,7 @@ class Table { // the sheet... const assignStyle = (cell, style) => { if (style) { - Object.keys(style).forEach(key => { + Object.keys(style).forEach((key) => { cell[key] = style[key]; }); } @@ -200,7 +200,7 @@ class Table { assignStyle(cell, style); }); } - table.rows.forEach(data => { + table.rows.forEach((data) => { const r = worksheet.getRow(row + count++); data.forEach((value, j) => { const cell = r.getCell(col + j); @@ -245,7 +245,7 @@ class Table { cell.value = column.name; }); } - table.rows.forEach(data => { + table.rows.forEach((data) => { const r = worksheet.getRow(row + count++); data.forEach((value, j) => { const cell = r.getCell(col + j); @@ -379,7 +379,7 @@ class Table { this.cacheState(); this.table.columns.splice(colIndex, count); - this.table.rows.forEach(row => { + this.table.rows.forEach((row) => { row.splice(colIndex, count); }); } diff --git a/lib/doc/workbook.js b/lib/doc/workbook.js index 98c42c0ea..a828b1259 100644 --- a/lib/doc/workbook.js +++ b/lib/doc/workbook.js @@ -51,7 +51,7 @@ class Workbook { console.warn(`Worksheet name ${name} exceeds 31 chars. This will be truncated`); } name = (name || `sheet${id}`).substring(0, 31); - if (this._worksheets.find(ws => ws && ws.name.toLowerCase() === name.toLowerCase())) { + if (this._worksheets.find((ws) => ws && ws.name.toLowerCase() === name.toLowerCase())) { throw new Error(`Worksheet name already exists: ${name}`); } @@ -109,7 +109,7 @@ class Workbook { return this._worksheets[id]; } if (typeof id === 'string') { - return this._worksheets.find(worksheet => worksheet && worksheet.name === id); + return this._worksheets.find((worksheet) => worksheet && worksheet.name === id); } return undefined; } @@ -123,7 +123,7 @@ class Workbook { } eachSheet(iteratee) { - this.worksheets.forEach(sheet => { + this.worksheets.forEach((sheet) => { iteratee(sheet, sheet.id); }); } @@ -156,8 +156,8 @@ class Workbook { created: this.created, modified: this.modified, properties: this.properties, - worksheets: this.worksheets.map(worksheet => worksheet.model), - sheets: this.worksheets.map(ws => ws.model).filter(Boolean), + worksheets: this.worksheets.map((worksheet) => worksheet.model), + sheets: this.worksheets.map((ws) => ws.model).filter(Boolean), definedNames: this._definedNames.model, views: this.views, company: this.company, @@ -196,9 +196,9 @@ class Workbook { this.properties = value.properties; this.calcProperties = value.calcProperties; this._worksheets = []; - value.worksheets.forEach(worksheetModel => { + value.worksheets.forEach((worksheetModel) => { const {id, name, state} = worksheetModel; - const orderNo = value.sheets && value.sheets.findIndex(ws => ws.id === id); + const orderNo = value.sheets && value.sheets.findIndex((ws) => ws.id === id); const worksheet = (this._worksheets[id] = new Worksheet({ id, name, diff --git a/lib/doc/worksheet.js b/lib/doc/worksheet.js index b1ca37852..f738318d0 100644 --- a/lib/doc/worksheet.js +++ b/lib/doc/worksheet.js @@ -135,7 +135,7 @@ class Worksheet { // Get the bounding range of the cells in this worksheet get dimensions() { const dimensions = new Range(); - this._rows.forEach(row => { + this._rows.forEach((row) => { if (row) { const rowDims = row.dimensions; if (rowDims) { @@ -166,7 +166,7 @@ class Worksheet { // construct Column objects let count = 1; const columns = (this._columns = []); - value.forEach(defn => { + value.forEach((defn) => { const column = new Column(this, count++, false); columns.push(column); column.defn = defn; @@ -219,7 +219,7 @@ class Worksheet { for (let i = 0; i < nRows; i++) { const rowArguments = [start, count]; // eslint-disable-next-line no-loop-func - inserts.forEach(insert => { + inserts.forEach((insert) => { rowArguments.push(insert[i] || null); }); const row = this.getRow(i + 1); @@ -228,7 +228,7 @@ class Worksheet { } } else { // nothing to insert, so just splice all rows - this._rows.forEach(r => { + this._rows.forEach((r) => { if (r) { r.splice(start, count); } @@ -258,7 +258,7 @@ class Worksheet { get columnCount() { let maxCount = 0; - this.eachRow(row => { + this.eachRow((row) => { maxCount = Math.max(maxCount, row.cellCount); }); return maxCount; @@ -268,7 +268,7 @@ class Worksheet { // performance nightmare - for each row, counts all the columns used const counts = []; let count = 0; - this.eachRow(row => { + this.eachRow((row) => { row.eachCell(({col}) => { if (!counts[col]) { counts[col] = true; @@ -359,7 +359,7 @@ class Worksheet { addRows(value, style = 'n') { const rows = []; - value.forEach(row => { + value.forEach((row) => { rows.push(this.addRow(row, style)); }); return rows; @@ -493,7 +493,7 @@ class Worksheet { iteratee(this.getRow(i), i); } } else { - this._rows.forEach(row => { + this._rows.forEach((row) => { if (row && row.hasValues) { iteratee(row, row.number); } @@ -504,7 +504,7 @@ class Worksheet { // return all rows as sparse array getSheetValues() { const rows = []; - this._rows.forEach(row => { + this._rows.forEach((row) => { if (row) { rows[row.number] = row.values; } @@ -545,7 +545,7 @@ class Worksheet { _mergeCellsInternal(dimensions, ignoreStyle) { // check cells aren't already merged - _.each(this._merges, merge => { + _.each(this._merges, (merge) => { if (merge.intersects(dimensions)) { throw new Error('Cannot merge already merged cells'); } @@ -666,7 +666,7 @@ class Worksheet { } getImages() { - return this._media.filter(m => m.type === 'image'); + return this._media.filter((m) => m.type === 'image'); } addBackgroundImage(imageId) { @@ -678,7 +678,7 @@ class Worksheet { } getBackgroundImageId() { - const image = this._media.find(m => m.type === 'background'); + const image = this._media.find((m) => m.type === 'background'); return image && image.imageId; } @@ -687,7 +687,7 @@ class Worksheet { protect(password, options) { // TODO: make this function truly async // perhaps marshal to worker thread or something - return new Promise(resolve => { + return new Promise((resolve) => { this.sheetProtection = { sheet: true, }; @@ -780,9 +780,9 @@ class Worksheet { rowBreaks: this.rowBreaks, views: this.views, autoFilter: this.autoFilter, - media: this._media.map(medium => medium.model), + media: this._media.map((medium) => medium.model), sheetProtection: this.sheetProtection, - tables: Object.values(this.tables).map(table => table.model), + tables: Object.values(this.tables).map((table) => table.model), conditionalFormattings: this.conditionalFormattings, }; @@ -794,7 +794,7 @@ class Worksheet { // Rows const rows = (model.rows = []); const dimensions = (model.dimensions = new Range()); - this._rows.forEach(row => { + this._rows.forEach((row) => { const rowModel = row && row.model; if (rowModel) { dimensions.expand(rowModel.number, rowModel.min, rowModel.number, rowModel.max); @@ -805,7 +805,7 @@ class Worksheet { // ========================================================== // Merges model.merges = []; - _.each(this._merges, merge => { + _.each(this._merges, (merge) => { model.merges.push(merge.range); }); @@ -814,7 +814,7 @@ class Worksheet { _parseRows(model) { this._rows = []; - model.rows.forEach(rowModel => { + model.rows.forEach((rowModel) => { const row = new Row(this, rowModel.number); this._rows[row.number - 1] = row; row.model = rowModel; @@ -822,7 +822,7 @@ class Worksheet { } _parseMergeCells(model) { - _.each(model.mergeCells, merge => { + _.each(model.mergeCells, (merge) => { // Do not merge styles when importing an Excel file // since each cell may have different styles intentionally. this.mergeCellsWithoutStyle(merge); @@ -841,7 +841,7 @@ class Worksheet { this.headerFooter = value.headerFooter; this.views = value.views; this.autoFilter = value.autoFilter; - this._media = value.media.map(medium => new Image(this, medium)); + this._media = value.media.map((medium) => new Image(this, medium)); this.sheetProtection = value.sheetProtection; this.tables = value.tables.reduce((tables, table) => { const t = new Table(); diff --git a/lib/exceljs.bare.js b/lib/exceljs.bare.js index 9f00471f8..922831efc 100644 --- a/lib/exceljs.bare.js +++ b/lib/exceljs.bare.js @@ -6,7 +6,7 @@ const ExcelJS = { // Object.assign mono-fill const Enums = require('./doc/enums'); -Object.keys(Enums).forEach(key => { +Object.keys(Enums).forEach((key) => { ExcelJS[key] = Enums[key]; }); diff --git a/lib/exceljs.browser.js b/lib/exceljs.browser.js index 3a3d631dc..aecd27422 100644 --- a/lib/exceljs.browser.js +++ b/lib/exceljs.browser.js @@ -13,7 +13,7 @@ const ExcelJS = { // Object.assign mono-fill const Enums = require('./doc/enums'); -Object.keys(Enums).forEach(key => { +Object.keys(Enums).forEach((key) => { ExcelJS[key] = Enums[key]; }); diff --git a/lib/stream/xlsx/sheet-comments-writer.js b/lib/stream/xlsx/sheet-comments-writer.js index e241e9add..fb86ea7fd 100644 --- a/lib/stream/xlsx/sheet-comments-writer.js +++ b/lib/stream/xlsx/sheet-comments-writer.js @@ -98,11 +98,11 @@ class SheetCommentsWriter { this.startedData = true; } - comments.forEach(item => { + comments.forEach((item) => { item.refAddress = colCache.decodeAddress(item.ref); }); - comments.forEach(comment => { + comments.forEach((comment) => { this._writeComment(comment, this.count); this.count += 1; }); diff --git a/lib/stream/xlsx/workbook-writer.js b/lib/stream/xlsx/workbook-writer.js index 6816c58d6..31eb056e7 100644 --- a/lib/stream/xlsx/workbook-writer.js +++ b/lib/stream/xlsx/workbook-writer.js @@ -77,7 +77,7 @@ class WorkbookWriter { _commitWorksheets() { const commitWorksheet = function(worksheet) { if (!worksheet.committed) { - return new Promise(resolve => { + return new Promise((resolve) => { worksheet.stream.on('zipped', () => { resolve(); }); @@ -172,27 +172,27 @@ class WorkbookWriter { return this._worksheets[id]; } if (typeof id === 'string') { - return this._worksheets.find(worksheet => worksheet && worksheet.name === id); + return this._worksheets.find((worksheet) => worksheet && worksheet.name === id); } return undefined; } addStyles() { - return new Promise(resolve => { + return new Promise((resolve) => { this.zip.append(this.styles.xml, {name: 'xl/styles.xml'}); resolve(); }); } addThemes() { - return new Promise(resolve => { + return new Promise((resolve) => { this.zip.append(theme1Xml, {name: 'xl/theme/theme1.xml'}); resolve(); }); } addOfficeRels() { - return new Promise(resolve => { + return new Promise((resolve) => { const xform = new RelationshipsXform(); const xml = xform.toXml([ {Id: 'rId1', Type: RelType.OfficeDocument, Target: 'xl/workbook.xml'}, @@ -205,7 +205,7 @@ class WorkbookWriter { } addContentTypes() { - return new Promise(resolve => { + return new Promise((resolve) => { const model = { worksheets: this._worksheets.filter(Boolean), sharedStrings: this.sharedStrings, @@ -221,7 +221,7 @@ class WorkbookWriter { addMedia() { return Promise.all( - this.media.map(medium => { + this.media.map((medium) => { if (medium.type === 'image') { const filename = `xl/media/${medium.name}`; if (medium.filename) { @@ -242,7 +242,7 @@ class WorkbookWriter { } addApp() { - return new Promise(resolve => { + return new Promise((resolve) => { const model = { worksheets: this._worksheets.filter(Boolean), }; @@ -254,7 +254,7 @@ class WorkbookWriter { } addCore() { - return new Promise(resolve => { + return new Promise((resolve) => { const coreXform = new CoreXform(); const xml = coreXform.toXml(this); this.zip.append(xml, {name: 'docProps/core.xml'}); @@ -264,7 +264,7 @@ class WorkbookWriter { addSharedStrings() { if (this.sharedStrings.count) { - return new Promise(resolve => { + return new Promise((resolve) => { const sharedStringsXform = new SharedStringsXform(); const xml = sharedStringsXform.toXml(this.sharedStrings); this.zip.append(xml, {name: '/xl/sharedStrings.xml'}); @@ -283,13 +283,13 @@ class WorkbookWriter { if (this.sharedStrings.count) { relationships.push({Id: `rId${count++}`, Type: RelType.SharedStrings, Target: 'sharedStrings.xml'}); } - this._worksheets.forEach(worksheet => { + this._worksheets.forEach((worksheet) => { if (worksheet) { worksheet.rId = `rId${count++}`; relationships.push({Id: worksheet.rId, Type: RelType.Worksheet, Target: `worksheets/sheet${worksheet.id}.xml`}); } }); - return new Promise(resolve => { + return new Promise((resolve) => { const xform = new RelationshipsXform(); const xml = xform.toXml(relationships); this.zip.append(xml, {name: '/xl/_rels/workbook.xml.rels'}); @@ -307,7 +307,7 @@ class WorkbookWriter { calcProperties: {}, }; - return new Promise(resolve => { + return new Promise((resolve) => { const xform = new WorkbookXform(); xform.prepare(model); zip.append(xform.toXml(model), {name: '/xl/workbook.xml'}); diff --git a/lib/stream/xlsx/worksheet-writer.js b/lib/stream/xlsx/worksheet-writer.js index 47a199c62..ea34aa8fb 100644 --- a/lib/stream/xlsx/worksheet-writer.js +++ b/lib/stream/xlsx/worksheet-writer.js @@ -209,7 +209,7 @@ class WorksheetWriter { return; } // commit all rows - this._rows.forEach(cRow => { + this._rows.forEach((cRow) => { if (cRow) { // write the row to the stream this._writeRow(cRow); @@ -282,7 +282,7 @@ class WorksheetWriter { // construct Column objects let count = 1; const columns = (this._columns = []); - value.forEach(defn => { + value.forEach((defn) => { const column = new Column(this, count++, false); columns.push(column); column.defn = defn; @@ -346,7 +346,7 @@ class WorksheetWriter { iteratee(this.getRow(i), i); } } else { - this._rows.forEach(row => { + this._rows.forEach((row) => { if (row.hasValues) { iteratee(row, row.number); } @@ -425,7 +425,7 @@ class WorksheetWriter { const dimensions = new Dimensions(cells); // check cells aren't already merged - this._merges.forEach(merge => { + this._merges.forEach((merge) => { if (merge.intersects(dimensions)) { throw new Error('Cannot merge already merged cells'); } @@ -581,7 +581,7 @@ class WorksheetWriter { if (this._merges.length) { xmlBuffer.reset(); xmlBuffer.addText(``); - this._merges.forEach(merge => { + this._merges.forEach((merge) => { xmlBuffer.addText(``); }); xmlBuffer.addText(''); diff --git a/lib/utils/cell-matrix.js b/lib/utils/cell-matrix.js index 121b5141d..92ec91b40 100644 --- a/lib/utils/cell-matrix.js +++ b/lib/utils/cell-matrix.js @@ -96,7 +96,7 @@ class CellMatrix { map(callback) { const results = []; - this.forEach(cell => { + this.forEach((cell) => { results.push(callback(cell)); }); return results; @@ -153,7 +153,7 @@ class CellMatrix { for (let i = 0; i < numInsert; i++) { inserts.push(null); } - _.each(sheet, row => { + _.each(sheet, (row) => { row.splice(start, numDelete, ...inserts); }); } diff --git a/lib/utils/iterate-stream.js b/lib/utils/iterate-stream.js index 08b974e9a..aa8d62597 100644 --- a/lib/utils/iterate-stream.js +++ b/lib/utils/iterate-stream.js @@ -1,9 +1,9 @@ module.exports = async function* iterateStream(stream) { const contents = []; - stream.on('data', data => contents.push(data)); + stream.on('data', (data) => contents.push(data)); let resolveStreamEndedPromise; - const streamEndedPromise = new Promise(resolve => (resolveStreamEndedPromise = resolve)); + const streamEndedPromise = new Promise((resolve) => (resolveStreamEndedPromise = resolve)); let ended = false; stream.on('end', () => { @@ -12,7 +12,7 @@ module.exports = async function* iterateStream(stream) { }); let error = false; - stream.on('error', err => { + stream.on('error', (err) => { error = err; resolveStreamEndedPromise(); }); @@ -34,7 +34,7 @@ module.exports = async function* iterateStream(stream) { function once(eventEmitter, type) { // TODO: Use require('events').once when node v10 is dropped - return new Promise(resolve => { + return new Promise((resolve) => { let fired = false; const handler = () => { if (!fired) { diff --git a/lib/utils/parse-sax.js b/lib/utils/parse-sax.js index b9c830917..474a8d998 100644 --- a/lib/utils/parse-sax.js +++ b/lib/utils/parse-sax.js @@ -1,7 +1,7 @@ const {SaxesParser} = require('saxes'); const {PassThrough} = require('readable-stream'); -module.exports = async function*(iterable) { +module.exports = async function* (iterable) { // TODO: Remove once node v8 is deprecated // Detect and upgrade old streams if (iterable.pipe && !iterable[Symbol.asyncIterator]) { @@ -9,13 +9,13 @@ module.exports = async function*(iterable) { } const saxesParser = new SaxesParser(); let error; - saxesParser.on('error', err => { + saxesParser.on('error', (err) => { error = err; }); let events = []; - saxesParser.on('opentag', value => events.push({eventType: 'opentag', value})); - saxesParser.on('text', value => events.push({eventType: 'text', value})); - saxesParser.on('closetag', value => events.push({eventType: 'closetag', value})); + saxesParser.on('opentag', (value) => events.push({eventType: 'opentag', value})); + saxesParser.on('text', (value) => events.push({eventType: 'text', value})); + saxesParser.on('closetag', (value) => events.push({eventType: 'closetag', value})); for await (const chunk of iterable) { saxesParser.write(chunk.toString()); // saxesParser.write and saxesParser.on() are synchronous, diff --git a/lib/utils/stream-base64.js b/lib/utils/stream-base64.js index b73002081..249ea643f 100644 --- a/lib/utils/stream-base64.js +++ b/lib/utils/stream-base64.js @@ -54,7 +54,7 @@ class StreamBase64 extends Stream.Duplex { unpipe(destination) { // remove destination from pipe list - this.pipes = this.pipes.filter(pipe => pipe !== destination); + this.pipes = this.pipes.filter((pipe) => pipe !== destination); } unshift(/* chunk */) { diff --git a/lib/utils/stream-buf.js b/lib/utils/stream-buf.js index 90a46b28a..b31eb75b9 100644 --- a/lib/utils/stream-buf.js +++ b/lib/utils/stream-buf.js @@ -176,7 +176,7 @@ utils.inherits(StreamBuf, Stream.Duplex, { case 1: return this.buffers[0].toBuffer(); default: - return Buffer.concat(this.buffers.map(rwBuf => rwBuf.toBuffer())); + return Buffer.concat(this.buffers.map((rwBuf) => rwBuf.toBuffer())); } }, @@ -201,7 +201,7 @@ utils.inherits(StreamBuf, Stream.Duplex, { async _pipe(chunk) { const write = function(pipe) { - return new Promise(resolve => { + return new Promise((resolve) => { pipe.write(chunk.toBuffer(), () => { resolve(); }); @@ -281,12 +281,12 @@ utils.inherits(StreamBuf, Stream.Duplex, { this._flush(); }, end(chunk, encoding, callback) { - const writeComplete = error => { + const writeComplete = (error) => { if (error) { callback(error); } else { this._flush(); - this.pipes.forEach(pipe => { + this.pipes.forEach((pipe) => { pipe.end(); }); this.emit('finish'); @@ -322,7 +322,7 @@ utils.inherits(StreamBuf, Stream.Duplex, { return Buffer.concat(buffers); } - buffers = this.buffers.map(buf => buf.toBuffer()).filter(Boolean); + buffers = this.buffers.map((buf) => buf.toBuffer()).filter(Boolean); this.buffers = []; return Buffer.concat(buffers); }, @@ -348,7 +348,7 @@ utils.inherits(StreamBuf, Stream.Duplex, { }, unpipe(destination) { // remove destination from pipe list - this.pipes = this.pipes.filter(pipe => pipe !== destination); + this.pipes = this.pipes.filter((pipe) => pipe !== destination); }, unshift(/* chunk */) { // some numpty has read some data that's not for them and they want to put it back! diff --git a/lib/utils/under-dash.js b/lib/utils/under-dash.js index 47a12b0fb..89ca2c92a 100644 --- a/lib/utils/under-dash.js +++ b/lib/utils/under-dash.js @@ -6,7 +6,7 @@ const _ = { if (Array.isArray(obj)) { obj.forEach(cb); } else { - Object.keys(obj).forEach(key => { + Object.keys(obj).forEach((key) => { cb(obj[key], key); }); } @@ -18,7 +18,7 @@ const _ = { if (Array.isArray(obj)) { return obj.some(cb); } - return Object.keys(obj).some(key => cb(obj[key], key)); + return Object.keys(obj).some((key) => cb(obj[key], key)); } return false; }, @@ -28,7 +28,7 @@ const _ = { if (Array.isArray(obj)) { return obj.every(cb); } - return Object.keys(obj).every(key => cb(obj[key], key)); + return Object.keys(obj).every((key) => cb(obj[key], key)); } return true; }, @@ -38,7 +38,7 @@ const _ = { if (Array.isArray(obj)) { return obj.map(cb); } - return Object.keys(obj).map(key => cb(obj[key], key)); + return Object.keys(obj).map((key) => cb(obj[key], key)); } return []; }, @@ -84,12 +84,7 @@ const _ = { }, escapeHtml(html) { - return html - .replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, '''); + return html.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, '''); }, strcmp(a, b) { diff --git a/lib/utils/utils.js b/lib/utils/utils.js index f13669a87..63c7c5a9e 100644 --- a/lib/utils/utils.js +++ b/lib/utils/utils.js @@ -11,7 +11,7 @@ const inherits = function(cls, superCtor, statics, prototype) { } if (statics) { - Object.keys(statics).forEach(i => { + Object.keys(statics).forEach((i) => { Object.defineProperty(cls, i, Object.getOwnPropertyDescriptor(statics, i)); }); } @@ -25,7 +25,7 @@ const inherits = function(cls, superCtor, statics, prototype) { }, }; if (prototype) { - Object.keys(prototype).forEach(i => { + Object.keys(prototype).forEach((i) => { properties[i] = Object.getOwnPropertyDescriptor(prototype, i); }); } @@ -36,7 +36,7 @@ const inherits = function(cls, superCtor, statics, prototype) { const utils = { nop() {}, promiseImmediate(value) { - return new Promise(resolve => { + return new Promise((resolve) => { if (global.setImmediate) { setImmediate(() => { resolve(value); @@ -70,7 +70,7 @@ const utils = { }, xmlEncode(text) { // eslint-disable-next-line no-control-regex - return text.replace(/[<>&'"\x7F\x00-\x08\x0B-\x0C\x0E-\x1F]/g, c => { + return text.replace(/[<>&'"\x7F\x00-\x08\x0B-\x0C\x0E-\x1F]/g, (c) => { switch (c) { case '<': return '<'; @@ -88,7 +88,7 @@ const utils = { }); }, xmlDecode(text) { - return text.replace(/&([a-z]*);/, c => { + return text.replace(/&([a-z]*);/, (c) => { switch (c) { case '<': return '<'; @@ -125,8 +125,8 @@ const utils = { fs: { exists(path) { - return new Promise(resolve => { - fs.access(path, fs.constants.F_OK, err => { + return new Promise((resolve) => { + fs.access(path, fs.constants.F_OK, (err) => { resolve(!err); }); }); diff --git a/lib/xlsx/xform/base-xform.js b/lib/xlsx/xform/base-xform.js index cb48cfa09..6e4efa0e3 100644 --- a/lib/xlsx/xform/base-xform.js +++ b/lib/xlsx/xform/base-xform.js @@ -41,7 +41,7 @@ class BaseXform { // if we have a map - reset them too if (this.map) { - Object.values(this.map).forEach(xform => { + Object.values(this.map).forEach((xform) => { if (xform instanceof BaseXform) { xform.reset(); } else if (xform.xform) { diff --git a/lib/xlsx/xform/book/defined-name-xform.js b/lib/xlsx/xform/book/defined-name-xform.js index 9ed8fec0d..1beafd284 100644 --- a/lib/xlsx/xform/book/defined-name-xform.js +++ b/lib/xlsx/xform/book/defined-name-xform.js @@ -56,7 +56,7 @@ function extractRanges(parsedText) { const ranges = []; let quotesOpened = false; let last = ''; - parsedText.split(',').forEach(item => { + parsedText.split(',').forEach((item) => { if (!item) { return; } diff --git a/lib/xlsx/xform/book/workbook-xform.js b/lib/xlsx/xform/book/workbook-xform.js index 2047d72c8..418b848a5 100644 --- a/lib/xlsx/xform/book/workbook-xform.js +++ b/lib/xlsx/xform/book/workbook-xform.js @@ -32,9 +32,9 @@ class WorkbookXform extends BaseXform { // collate all the print areas from all of the sheets and add them to the defined names const printAreas = []; let index = 0; // sheets is sparse array - calc index manually - model.sheets.forEach(sheet => { + model.sheets.forEach((sheet) => { if (sheet.pageSetup && sheet.pageSetup.printArea) { - sheet.pageSetup.printArea.split('&&').forEach(printArea => { + sheet.pageSetup.printArea.split('&&').forEach((printArea) => { const printAreaComponents = printArea.split(':'); const definedName = { name: '_xlnm.Print_Area', @@ -152,7 +152,7 @@ class WorkbookXform extends BaseXform { let worksheet; let index = 0; - (model.sheets || []).forEach(sheet => { + (model.sheets || []).forEach((sheet) => { const rel = rels[sheet.rId]; if (!rel) { return; @@ -175,7 +175,7 @@ class WorkbookXform extends BaseXform { // reconcile print areas const definedNames = []; - _.each(model.definedNames, definedName => { + _.each(model.definedNames, (definedName) => { if (definedName.name === '_xlnm.Print_Area') { worksheet = worksheets[definedName.localSheetId]; if (worksheet) { diff --git a/lib/xlsx/xform/comment/comment-xform.js b/lib/xlsx/xform/comment/comment-xform.js index 16363bfea..59b49c77a 100644 --- a/lib/xlsx/xform/comment/comment-xform.js +++ b/lib/xlsx/xform/comment/comment-xform.js @@ -51,7 +51,7 @@ utils.inherits(CommentXform, BaseXform, { }); xmlStream.openNode('text'); if (model && model.note && model.note.texts) { - model.note.texts.forEach(text => { + model.note.texts.forEach((text) => { this.richTextXform.render(xmlStream, text); }); } diff --git a/lib/xlsx/xform/comment/comments-xform.js b/lib/xlsx/xform/comment/comments-xform.js index c301bb00e..b3ca65b7f 100644 --- a/lib/xlsx/xform/comment/comments-xform.js +++ b/lib/xlsx/xform/comment/comments-xform.js @@ -32,7 +32,7 @@ utils.inherits( // comments xmlStream.openNode('commentList'); - model.comments.forEach(comment => { + model.comments.forEach((comment) => { this.map.comment.render(xmlStream, comment); }); xmlStream.closeNode(); diff --git a/lib/xlsx/xform/comment/vml-notes-xform.js b/lib/xlsx/xform/comment/vml-notes-xform.js index 28fe95474..e8dceeff1 100644 --- a/lib/xlsx/xform/comment/vml-notes-xform.js +++ b/lib/xlsx/xform/comment/vml-notes-xform.js @@ -83,7 +83,7 @@ class VmlNotesXform extends BaseXform { } reconcile(model, options) { - model.anchors.forEach(anchor => { + model.anchors.forEach((anchor) => { if (anchor.br) { this.map['xdr:twoCellAnchor'].reconcile(anchor, options); } else { diff --git a/lib/xlsx/xform/comment/vml-textbox-xform.js b/lib/xlsx/xform/comment/vml-textbox-xform.js index 95f28d934..a664dc86c 100644 --- a/lib/xlsx/xform/comment/vml-textbox-xform.js +++ b/lib/xlsx/xform/comment/vml-textbox-xform.js @@ -10,7 +10,7 @@ class VmlTextboxXform extends BaseXform { } reverseConversionUnit(inset) { - return (inset || '').split(',').map(margin => { + return (inset || '').split(',').map((margin) => { return Number(parseFloat(this.conversionUnit(parseFloat(margin), 0.1, '')).toFixed(2)); }); } @@ -23,7 +23,7 @@ class VmlTextboxXform extends BaseXform { let {inset} = model.note && model.note.margins; if (Array.isArray(inset)) { inset = inset - .map(margin => { + .map((margin) => { return this.conversionUnit(margin, 10, 'mm'); }) .join(','); diff --git a/lib/xlsx/xform/core/app-titles-of-parts-xform.js b/lib/xlsx/xform/core/app-titles-of-parts-xform.js index e276a6fef..06eac551c 100644 --- a/lib/xlsx/xform/core/app-titles-of-parts-xform.js +++ b/lib/xlsx/xform/core/app-titles-of-parts-xform.js @@ -5,7 +5,7 @@ class AppTitlesOfPartsXform extends BaseXform { xmlStream.openNode('TitlesOfParts'); xmlStream.openNode('vt:vector', {size: model.length, baseType: 'lpstr'}); - model.forEach(sheet => { + model.forEach((sheet) => { xmlStream.leafNode('vt:lpstr', undefined, sheet.name); }); diff --git a/lib/xlsx/xform/core/content-types-xform.js b/lib/xlsx/xform/core/content-types-xform.js index d3babcf61..98b0d1ab9 100644 --- a/lib/xlsx/xform/core/content-types-xform.js +++ b/lib/xlsx/xform/core/content-types-xform.js @@ -11,7 +11,7 @@ class ContentTypesXform extends BaseXform { xmlStream.openNode('Types', ContentTypesXform.PROPERTY_ATTRIBUTES); const mediaHash = {}; - (model.media || []).forEach(medium => { + (model.media || []).forEach((medium) => { if (medium.type === 'image') { const imageType = medium.extension; if (!mediaHash[imageType]) { @@ -29,7 +29,7 @@ class ContentTypesXform extends BaseXform { ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml', }); - model.worksheets.forEach(worksheet => { + model.worksheets.forEach((worksheet) => { const name = `/xl/worksheets/sheet${worksheet.id}.xml`; xmlStream.leafNode('Override', {PartName: name, ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml'}); }); @@ -46,7 +46,7 @@ class ContentTypesXform extends BaseXform { } if (model.tables) { - model.tables.forEach(table => { + model.tables.forEach((table) => { xmlStream.leafNode('Override', { PartName: `/xl/tables/${table.target}`, ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml', @@ -55,7 +55,7 @@ class ContentTypesXform extends BaseXform { } if (model.drawings) { - model.drawings.forEach(drawing => { + model.drawings.forEach((drawing) => { xmlStream.leafNode('Override', { PartName: `/xl/drawings/${drawing.name}.xml`, ContentType: 'application/vnd.openxmlformats-officedocument.drawing+xml', diff --git a/lib/xlsx/xform/core/relationships-xform.js b/lib/xlsx/xform/core/relationships-xform.js index ead7227d4..a2ce46642 100644 --- a/lib/xlsx/xform/core/relationships-xform.js +++ b/lib/xlsx/xform/core/relationships-xform.js @@ -17,7 +17,7 @@ class RelationshipsXform extends BaseXform { xmlStream.openXml(XmlStream.StdDocAttributes); xmlStream.openNode('Relationships', RelationshipsXform.RELATIONSHIPS_ATTRIBUTES); - model.forEach(relationship => { + model.forEach((relationship) => { this.map.Relationship.render(xmlStream, relationship); }); diff --git a/lib/xlsx/xform/drawing/drawing-xform.js b/lib/xlsx/xform/drawing/drawing-xform.js index 6bc4c43d8..1f782cf71 100644 --- a/lib/xlsx/xform/drawing/drawing-xform.js +++ b/lib/xlsx/xform/drawing/drawing-xform.js @@ -37,7 +37,7 @@ class DrawingXform extends BaseXform { xmlStream.openXml(XmlStream.StdDocAttributes); xmlStream.openNode(this.tag, DrawingXform.DRAWING_ATTRIBUTES); - model.anchors.forEach(item => { + model.anchors.forEach((item) => { const anchor = this.map[item.anchorType]; anchor.render(xmlStream, item); }); @@ -91,7 +91,7 @@ class DrawingXform extends BaseXform { } reconcile(model, options) { - model.anchors.forEach(anchor => { + model.anchors.forEach((anchor) => { if (anchor.br) { this.map['xdr:twoCellAnchor'].reconcile(anchor, options); } else { diff --git a/lib/xlsx/xform/list-xform.js b/lib/xlsx/xform/list-xform.js index aeac91f4e..dac28904d 100644 --- a/lib/xlsx/xform/list-xform.js +++ b/lib/xlsx/xform/list-xform.js @@ -85,7 +85,7 @@ class ListXform extends BaseXform { reconcile(model, options) { if (model) { const {childXform} = this; - model.forEach(childModel => { + model.forEach((childModel) => { childXform.reconcile(childModel, options); }); } diff --git a/lib/xlsx/xform/sheet/cell-xform.js b/lib/xlsx/xform/sheet/cell-xform.js index 2e78bf36c..7fe3cedfd 100644 --- a/lib/xlsx/xform/sheet/cell-xform.js +++ b/lib/xlsx/xform/sheet/cell-xform.js @@ -233,7 +233,7 @@ class CellXform extends BaseXform { } else if (model.value && model.value.richText) { xmlStream.addAttribute('t', 'inlineStr'); xmlStream.openNode('is'); - model.value.richText.forEach(text => { + model.value.richText.forEach((text) => { this.richTextXForm.render(xmlStream, text); }); xmlStream.closeNode('is'); diff --git a/lib/xlsx/xform/sheet/cf-ext/conditional-formatting-ext-xform.js b/lib/xlsx/xform/sheet/cf-ext/conditional-formatting-ext-xform.js index d0e9c3bc0..8043099be 100644 --- a/lib/xlsx/xform/sheet/cf-ext/conditional-formatting-ext-xform.js +++ b/lib/xlsx/xform/sheet/cf-ext/conditional-formatting-ext-xform.js @@ -18,7 +18,7 @@ class ConditionalFormattingExtXform extends CompositeXform { } prepare(model, options) { - model.rules.forEach(rule => { + model.rules.forEach((rule) => { this.cfRule.prepare(rule, options); }); } @@ -32,7 +32,7 @@ class ConditionalFormattingExtXform extends CompositeXform { 'xmlns:xm': 'http://schemas.microsoft.com/office/excel/2006/main', }); - model.rules.filter(CfRuleExtXform.isExt).forEach(rule => this.cfRule.render(xmlStream, rule)); + model.rules.filter(CfRuleExtXform.isExt).forEach((rule) => this.cfRule.render(xmlStream, rule)); // for some odd reason, Excel needs the node to be after the rules this.sqRef.render(xmlStream, model.ref); diff --git a/lib/xlsx/xform/sheet/cf-ext/conditional-formattings-ext-xform.js b/lib/xlsx/xform/sheet/cf-ext/conditional-formattings-ext-xform.js index 1d1db23b8..aad91fa64 100644 --- a/lib/xlsx/xform/sheet/cf-ext/conditional-formattings-ext-xform.js +++ b/lib/xlsx/xform/sheet/cf-ext/conditional-formattings-ext-xform.js @@ -1,50 +1,50 @@ -const CompositeXform = require('../../composite-xform'); - -const CfRuleExtXform = require('./cf-rule-ext-xform'); -const ConditionalFormattingExtXform = require('./conditional-formatting-ext-xform'); - -class ConditionalFormattingsExtXform extends CompositeXform { - constructor() { - super(); - - this.map = { - 'x14:conditionalFormatting': (this.cfXform = new ConditionalFormattingExtXform()), - }; - } - - get tag() { - return 'x14:conditionalFormattings'; - } - - hasContent(model) { - if (model.hasExtContent === undefined) { - model.hasExtContent = model.some(cf => cf.rules.some(CfRuleExtXform.isExt)); - } - return model.hasExtContent; - } - - prepare(model, options) { - model.forEach(cf => { - this.cfXform.prepare(cf, options); - }); - } - - render(xmlStream, model) { - if (this.hasContent(model)) { - xmlStream.openNode(this.tag); - model.forEach(cf => this.cfXform.render(xmlStream, cf)); - xmlStream.closeNode(); - } - } - - createNewModel() { - return []; - } - - onParserClose(name, parser) { - // model is array of conditional formatting objects - this.model.push(parser.model); - } -} - -module.exports = ConditionalFormattingsExtXform; +const CompositeXform = require('../../composite-xform'); + +const CfRuleExtXform = require('./cf-rule-ext-xform'); +const ConditionalFormattingExtXform = require('./conditional-formatting-ext-xform'); + +class ConditionalFormattingsExtXform extends CompositeXform { + constructor() { + super(); + + this.map = { + 'x14:conditionalFormatting': (this.cfXform = new ConditionalFormattingExtXform()), + }; + } + + get tag() { + return 'x14:conditionalFormattings'; + } + + hasContent(model) { + if (model.hasExtContent === undefined) { + model.hasExtContent = model.some((cf) => cf.rules.some(CfRuleExtXform.isExt)); + } + return model.hasExtContent; + } + + prepare(model, options) { + model.forEach((cf) => { + this.cfXform.prepare(cf, options); + }); + } + + render(xmlStream, model) { + if (this.hasContent(model)) { + xmlStream.openNode(this.tag); + model.forEach((cf) => this.cfXform.render(xmlStream, cf)); + xmlStream.closeNode(); + } + } + + createNewModel() { + return []; + } + + onParserClose(name, parser) { + // model is array of conditional formatting objects + this.model.push(parser.model); + } +} + +module.exports = ConditionalFormattingsExtXform; diff --git a/lib/xlsx/xform/sheet/cf-ext/databar-ext-xform.js b/lib/xlsx/xform/sheet/cf-ext/databar-ext-xform.js index 05feeb3e6..47c537fc9 100644 --- a/lib/xlsx/xform/sheet/cf-ext/databar-ext-xform.js +++ b/lib/xlsx/xform/sheet/cf-ext/databar-ext-xform.js @@ -39,7 +39,7 @@ class DatabarExtXform extends CompositeXform { direction: BaseXform.toAttribute(model.direction, 'leftToRight'), }); - model.cfvo.forEach(cfvo => { + model.cfvo.forEach((cfvo) => { this.cfvoXform.render(xmlStream, cfvo); }); diff --git a/lib/xlsx/xform/sheet/cf-ext/icon-set-ext-xform.js b/lib/xlsx/xform/sheet/cf-ext/icon-set-ext-xform.js index ef0e16d30..318a323ac 100644 --- a/lib/xlsx/xform/sheet/cf-ext/icon-set-ext-xform.js +++ b/lib/xlsx/xform/sheet/cf-ext/icon-set-ext-xform.js @@ -26,7 +26,7 @@ class IconSetExtXform extends CompositeXform { custom: BaseXform.toBoolAttribute(model.icons, false), }); - model.cfvo.forEach(cfvo => { + model.cfvo.forEach((cfvo) => { this.cfvoXform.render(xmlStream, cfvo); }); diff --git a/lib/xlsx/xform/sheet/cf/cf-rule-xform.js b/lib/xlsx/xform/sheet/cf/cf-rule-xform.js index 22b3e44ec..6cb20235c 100644 --- a/lib/xlsx/xform/sheet/cf/cf-rule-xform.js +++ b/lib/xlsx/xform/sheet/cf/cf-rule-xform.js @@ -15,7 +15,7 @@ const extIcons = { '5Boxes': true, }; -const getTextFormula = model => { +const getTextFormula = (model) => { if (model.formulae && model.formulae[0]) { return model.formulae[0]; } @@ -38,7 +38,7 @@ const getTextFormula = model => { } }; -const getTimePeriodFormula = model => { +const getTimePeriodFormula = (model) => { if (model.formulae && model.formulae[0]) { return model.formulae[0]; } @@ -71,7 +71,7 @@ const getTimePeriodFormula = model => { } }; -const opType = attributes => { +const opType = (attributes) => { const {type, operator} = attributes; switch (type) { case 'containsText': @@ -168,7 +168,7 @@ class CfRuleXform extends CompositeXform { operator: model.operator, }); - model.formulae.forEach(formula => { + model.formulae.forEach((formula) => { this.formulaXform.render(xmlStream, formula); }); diff --git a/lib/xlsx/xform/sheet/cf/color-scale-xform.js b/lib/xlsx/xform/sheet/cf/color-scale-xform.js index 66293068c..c636ce11f 100644 --- a/lib/xlsx/xform/sheet/cf/color-scale-xform.js +++ b/lib/xlsx/xform/sheet/cf/color-scale-xform.js @@ -20,10 +20,10 @@ class ColorScaleXform extends CompositeXform { render(xmlStream, model) { xmlStream.openNode(this.tag); - model.cfvo.forEach(cfvo => { + model.cfvo.forEach((cfvo) => { this.cfvoXform.render(xmlStream, cfvo); }); - model.color.forEach(color => { + model.color.forEach((color) => { this.colorXform.render(xmlStream, color); }); diff --git a/lib/xlsx/xform/sheet/cf/conditional-formatting-xform.js b/lib/xlsx/xform/sheet/cf/conditional-formatting-xform.js index ae41ec86d..e48a26145 100644 --- a/lib/xlsx/xform/sheet/cf/conditional-formatting-xform.js +++ b/lib/xlsx/xform/sheet/cf/conditional-formatting-xform.js @@ -23,7 +23,7 @@ class ConditionalFormattingXform extends CompositeXform { xmlStream.openNode(this.tag, {sqref: model.ref}); - model.rules.forEach(rule => { + model.rules.forEach((rule) => { if (CfRuleXform.isPrimitive(rule)) { rule.ref = model.ref; this.map.cfRule.render(xmlStream, rule); diff --git a/lib/xlsx/xform/sheet/cf/conditional-formattings-xform.js b/lib/xlsx/xform/sheet/cf/conditional-formattings-xform.js index 9786f9bf0..7051dc95c 100644 --- a/lib/xlsx/xform/sheet/cf/conditional-formattings-xform.js +++ b/lib/xlsx/xform/sheet/cf/conditional-formattings-xform.js @@ -1,89 +1,89 @@ -const BaseXform = require('../../base-xform'); - -const ConditionalFormattingXform = require('./conditional-formatting-xform'); - -class ConditionalFormattingsXform extends BaseXform { - constructor() { - super(); - - this.cfXform = new ConditionalFormattingXform(); - } - - get tag() { - return 'conditionalFormatting'; - } - - reset() { - this.model = []; - } - - prepare(model, options) { - // ensure each rule has a priority value - let nextPriority = model.reduce((p, cf) => Math.max(p, ...cf.rules.map(rule => rule.priority || 0)), 1); - model.forEach(cf => { - cf.rules.forEach(rule => { - if (!rule.priority) { - rule.priority = nextPriority++; - } - - if (rule.style) { - rule.dxfId = options.styles.addDxfStyle(rule.style); - } - }); - }); - } - - render(xmlStream, model) { - model.forEach(cf => { - this.cfXform.render(xmlStream, cf); - }); - } - - parseOpen(node) { - if (this.parser) { - this.parser.parseOpen(node); - return true; - } - - switch (node.name) { - case 'conditionalFormatting': - this.parser = this.cfXform; - this.parser.parseOpen(node); - return true; - - default: - return false; - } - } - - parseText(text) { - if (this.parser) { - this.parser.parseText(text); - } - } - - parseClose(name) { - if (this.parser) { - if (!this.parser.parseClose(name)) { - this.model.push(this.parser.model); - this.parser = undefined; - return false; - } - return true; - } - return false; - } - - reconcile(model, options) { - model.forEach(cf => { - cf.rules.forEach(rule => { - if (rule.dxfId !== undefined) { - rule.style = options.styles.getDxfStyle(rule.dxfId); - delete rule.dxfId; - } - }); - }); - } -} - -module.exports = ConditionalFormattingsXform; +const BaseXform = require('../../base-xform'); + +const ConditionalFormattingXform = require('./conditional-formatting-xform'); + +class ConditionalFormattingsXform extends BaseXform { + constructor() { + super(); + + this.cfXform = new ConditionalFormattingXform(); + } + + get tag() { + return 'conditionalFormatting'; + } + + reset() { + this.model = []; + } + + prepare(model, options) { + // ensure each rule has a priority value + let nextPriority = model.reduce((p, cf) => Math.max(p, ...cf.rules.map((rule) => rule.priority || 0)), 1); + model.forEach((cf) => { + cf.rules.forEach((rule) => { + if (!rule.priority) { + rule.priority = nextPriority++; + } + + if (rule.style) { + rule.dxfId = options.styles.addDxfStyle(rule.style); + } + }); + }); + } + + render(xmlStream, model) { + model.forEach((cf) => { + this.cfXform.render(xmlStream, cf); + }); + } + + parseOpen(node) { + if (this.parser) { + this.parser.parseOpen(node); + return true; + } + + switch (node.name) { + case 'conditionalFormatting': + this.parser = this.cfXform; + this.parser.parseOpen(node); + return true; + + default: + return false; + } + } + + parseText(text) { + if (this.parser) { + this.parser.parseText(text); + } + } + + parseClose(name) { + if (this.parser) { + if (!this.parser.parseClose(name)) { + this.model.push(this.parser.model); + this.parser = undefined; + return false; + } + return true; + } + return false; + } + + reconcile(model, options) { + model.forEach((cf) => { + cf.rules.forEach((rule) => { + if (rule.dxfId !== undefined) { + rule.style = options.styles.getDxfStyle(rule.dxfId); + delete rule.dxfId; + } + }); + }); + } +} + +module.exports = ConditionalFormattingsXform; diff --git a/lib/xlsx/xform/sheet/cf/databar-xform.js b/lib/xlsx/xform/sheet/cf/databar-xform.js index 3cc13b611..7f24c431a 100644 --- a/lib/xlsx/xform/sheet/cf/databar-xform.js +++ b/lib/xlsx/xform/sheet/cf/databar-xform.js @@ -20,7 +20,7 @@ class DatabarXform extends CompositeXform { render(xmlStream, model) { xmlStream.openNode(this.tag); - model.cfvo.forEach(cfvo => { + model.cfvo.forEach((cfvo) => { this.cfvoXform.render(xmlStream, cfvo); }); this.colorXform.render(xmlStream, model.color); diff --git a/lib/xlsx/xform/sheet/cf/icon-set-xform.js b/lib/xlsx/xform/sheet/cf/icon-set-xform.js index cd7d4abfc..d529bc605 100644 --- a/lib/xlsx/xform/sheet/cf/icon-set-xform.js +++ b/lib/xlsx/xform/sheet/cf/icon-set-xform.js @@ -23,7 +23,7 @@ class IconSetXform extends CompositeXform { showValue: BaseXform.toBoolAttribute(model.showValue, true), }); - model.cfvo.forEach(cfvo => { + model.cfvo.forEach((cfvo) => { this.cfvoXform.render(xmlStream, cfvo); }); diff --git a/lib/xlsx/xform/sheet/data-validations-xform.js b/lib/xlsx/xform/sheet/data-validations-xform.js index df69f7dc1..1f2c82b68 100644 --- a/lib/xlsx/xform/sheet/data-validations-xform.js +++ b/lib/xlsx/xform/sheet/data-validations-xform.js @@ -49,7 +49,7 @@ function optimiseDataValidations(model) { return true; }; return dvList - .map(dv => { + .map((dv) => { if (!dv.marked) { const addr = colCache.decodeAddress(dv.address); @@ -104,7 +104,7 @@ class DataValidationsXform extends BaseXform { if (optimizedModel.length) { xmlStream.openNode('dataValidations', {count: optimizedModel.length}); - optimizedModel.forEach(value => { + optimizedModel.forEach((value) => { xmlStream.openNode('dataValidation'); if (value.type !== 'any') { @@ -216,10 +216,10 @@ class DataValidationsXform extends BaseXform { } // The four known cases: 1. E4:L9 N4:U9 2.E4 L9 3. N4:U9 4. E4 const list = this._address.split(/\s+/g) || []; - list.forEach(addr => { + list.forEach((addr) => { if (addr.includes(':')) { const range = new Range(addr); - range.forEachAddress(address => { + range.forEachAddress((address) => { this.model[address] = this._dataValidation; }); } else { diff --git a/lib/xlsx/xform/sheet/merges.js b/lib/xlsx/xform/sheet/merges.js index c885375b1..0868e8ff2 100644 --- a/lib/xlsx/xform/sheet/merges.js +++ b/lib/xlsx/xform/sheet/merges.js @@ -21,12 +21,12 @@ class Merges { } get mergeCells() { - return _.map(this.merges, merge => merge.range); + return _.map(this.merges, (merge) => merge.range); } reconcile(mergeCells, rows) { // reconcile merge list with merge cells - _.each(mergeCells, merge => { + _.each(mergeCells, (merge) => { const dimensions = colCache.decode(merge); for (let i = dimensions.top; i <= dimensions.bottom; i++) { const row = rows[i - 1]; diff --git a/lib/xlsx/xform/sheet/outline-properties-xform.js b/lib/xlsx/xform/sheet/outline-properties-xform.js index b494c2490..bcd9d91cd 100644 --- a/lib/xlsx/xform/sheet/outline-properties-xform.js +++ b/lib/xlsx/xform/sheet/outline-properties-xform.js @@ -1,6 +1,6 @@ const BaseXform = require('../base-xform'); -const isDefined = attr => typeof attr !== 'undefined'; +const isDefined = (attr) => typeof attr !== 'undefined'; class OutlinePropertiesXform extends BaseXform { get tag() { diff --git a/lib/xlsx/xform/sheet/page-margins-xform.js b/lib/xlsx/xform/sheet/page-margins-xform.js index 4b221e181..a13a083e8 100644 --- a/lib/xlsx/xform/sheet/page-margins-xform.js +++ b/lib/xlsx/xform/sheet/page-margins-xform.js @@ -16,7 +16,7 @@ class PageMarginsXform extends BaseXform { header: model.header, footer: model.footer, }; - if (_.some(attributes, value => value !== undefined)) { + if (_.some(attributes, (value) => value !== undefined)) { xmlStream.leafNode(this.tag, attributes); } } diff --git a/lib/xlsx/xform/sheet/page-setup-xform.js b/lib/xlsx/xform/sheet/page-setup-xform.js index 034fe69b7..5e6ba0544 100644 --- a/lib/xlsx/xform/sheet/page-setup-xform.js +++ b/lib/xlsx/xform/sheet/page-setup-xform.js @@ -60,7 +60,7 @@ class PageSetupXform extends BaseXform { usePrinterDefaults: booleanToXml(model.usePrinterDefaults), copies: model.copies, }; - if (_.some(attributes, value => value !== undefined)) { + if (_.some(attributes, (value) => value !== undefined)) { xmlStream.leafNode(this.tag, attributes); } } diff --git a/lib/xlsx/xform/sheet/print-options-xform.js b/lib/xlsx/xform/sheet/print-options-xform.js index d9a7d087a..22113a99a 100644 --- a/lib/xlsx/xform/sheet/print-options-xform.js +++ b/lib/xlsx/xform/sheet/print-options-xform.js @@ -18,7 +18,7 @@ class PrintOptionsXform extends BaseXform { horizontalCentered: booleanToXml(model.horizontalCentered), verticalCentered: booleanToXml(model.verticalCentered), }; - if (_.some(attributes, value => value !== undefined)) { + if (_.some(attributes, (value) => value !== undefined)) { xmlStream.leafNode(this.tag, attributes); } } diff --git a/lib/xlsx/xform/sheet/row-breaks-xform.js b/lib/xlsx/xform/sheet/row-breaks-xform.js index cc01008a8..e8c907765 100644 --- a/lib/xlsx/xform/sheet/row-breaks-xform.js +++ b/lib/xlsx/xform/sheet/row-breaks-xform.js @@ -25,7 +25,7 @@ class RowBreaksXform extends ListXform { } const {childXform} = this; - model.forEach(childModel => { + model.forEach((childModel) => { childXform.render(xmlStream, childModel); }); diff --git a/lib/xlsx/xform/sheet/row-xform.js b/lib/xlsx/xform/sheet/row-xform.js index c278839f1..5a142af38 100644 --- a/lib/xlsx/xform/sheet/row-xform.js +++ b/lib/xlsx/xform/sheet/row-xform.js @@ -22,7 +22,7 @@ class RowXform extends BaseXform { model.styleId = styleId; } const cellXform = this.map.c; - model.cells.forEach(cellModel => { + model.cells.forEach((cellModel) => { cellXform.prepare(cellModel, options); }); } @@ -53,7 +53,7 @@ class RowXform extends BaseXform { } const cellXform = this.map.c; - model.cells.forEach(cellModel => { + model.cells.forEach((cellModel) => { cellXform.render(xmlStream, cellModel, options); }); @@ -67,7 +67,7 @@ class RowXform extends BaseXform { } if (node.name === 'row') { this.numRowsSeen += 1; - const spans = node.attributes.spans ? node.attributes.spans.split(':').map(span => parseInt(span, 10)) : [undefined, undefined]; + const spans = node.attributes.spans ? node.attributes.spans.split(':').map((span) => parseInt(span, 10)) : [undefined, undefined]; const model = (this.model = { number: parseInt(node.attributes.r, 10), min: spans[0], @@ -130,7 +130,7 @@ class RowXform extends BaseXform { } const cellXform = this.map.c; - model.cells.forEach(cellModel => { + model.cells.forEach((cellModel) => { cellXform.reconcile(cellModel, options); }); } diff --git a/lib/xlsx/xform/sheet/sheet-format-properties-xform.js b/lib/xlsx/xform/sheet/sheet-format-properties-xform.js index 7ffae26df..12b3ae584 100644 --- a/lib/xlsx/xform/sheet/sheet-format-properties-xform.js +++ b/lib/xlsx/xform/sheet/sheet-format-properties-xform.js @@ -23,7 +23,7 @@ class SheetFormatPropertiesXform extends BaseXform { attributes.customHeight = '1'; } - if (_.some(attributes, value => value !== undefined)) { + if (_.some(attributes, (value) => value !== undefined)) { xmlStream.leafNode('sheetFormatPr', attributes); } } diff --git a/lib/xlsx/xform/sheet/sheet-protection-xform.js b/lib/xlsx/xform/sheet/sheet-protection-xform.js index 17722502a..5ce842ba6 100644 --- a/lib/xlsx/xform/sheet/sheet-protection-xform.js +++ b/lib/xlsx/xform/sheet/sheet-protection-xform.js @@ -40,7 +40,7 @@ class SheetProtectionXform extends BaseXform { attributes.objects = booleanToXml(model.objects === false, '1'); attributes.scenarios = booleanToXml(model.scenarios === false, '1'); } - if (_.some(attributes, value => value !== undefined)) { + if (_.some(attributes, (value) => value !== undefined)) { xmlStream.leafNode(this.tag, attributes); } } diff --git a/lib/xlsx/xform/sheet/worksheet-xform.js b/lib/xlsx/xform/sheet/worksheet-xform.js index bf68ab725..2990c838f 100644 --- a/lib/xlsx/xform/sheet/worksheet-xform.js +++ b/lib/xlsx/xform/sheet/worksheet-xform.js @@ -32,7 +32,7 @@ const ConditionalFormattingsXform = require('./cf/conditional-formattings-xform' const ExtListXform = require('./ext-lst-xform'); const mergeRule = (rule, extRule) => { - Object.keys(extRule).forEach(key => { + Object.keys(extRule).forEach((key) => { const value = rule[key]; const extValue = extRule[key]; if (value === undefined && extValue !== undefined) { @@ -55,9 +55,9 @@ const mergeConditionalFormattings = (model, extModel) => { // index model rules by x14Id const cfMap = {}; const ruleMap = {}; - model.forEach(cf => { + model.forEach((cf) => { cfMap[cf.ref] = cf; - cf.rules.forEach(rule => { + cf.rules.forEach((rule) => { const {x14Id} = rule; if (x14Id) { ruleMap[x14Id] = rule; @@ -65,8 +65,8 @@ const mergeConditionalFormattings = (model, extModel) => { }); }); - extModel.forEach(extCf => { - extCf.rules.forEach(extRule => { + extModel.forEach((extCf) => { + extCf.rules.forEach((extRule) => { const rule = ruleMap[extRule.x14Id]; if (rule) { // merge with matching rule @@ -144,7 +144,7 @@ class WorkSheetXform extends BaseXform { return `rId${r.length + 1}`; } - model.hyperlinks.forEach(hyperlink => { + model.hyperlinks.forEach((hyperlink) => { const rId = nextRid(rels); hyperlink.rId = rId; rels.push({ @@ -170,7 +170,7 @@ class WorkSheetXform extends BaseXform { }; rels.push(vmlDrawing); - model.comments.forEach(item => { + model.comments.forEach((item) => { item.refAddress = colCache.decodeAddress(item.ref); }); @@ -182,7 +182,7 @@ class WorkSheetXform extends BaseXform { const drawingRelsHash = []; let bookImage; - model.media.forEach(medium => { + model.media.forEach((medium) => { if (medium.type === 'background') { const rId = nextRid(rels); bookImage = options.media[medium.imageId]; @@ -249,7 +249,7 @@ class WorkSheetXform extends BaseXform { }); // prepare tables - model.tables.forEach(table => { + model.tables.forEach((table) => { // relationships const rId = nextRid(rels); table.rId = rId; @@ -260,7 +260,7 @@ class WorkSheetXform extends BaseXform { }); // dynamic styles - table.columns.forEach(column => { + table.columns.forEach((column) => { const {style} = column; if (style) { column.dxfId = options.styles.addDxfStyle(style); @@ -334,7 +334,7 @@ class WorkSheetXform extends BaseXform { if (model.rels) { // add a node for each comment - model.rels.forEach(rel => { + model.rels.forEach((rel) => { if (rel.Type === RelType.VmlDrawing) { xmlStream.leafNode('legacyDrawing', {'r:id': rel.Id}); } @@ -351,7 +351,7 @@ class WorkSheetXform extends BaseXform { } if (node.name === 'worksheet') { - _.each(this.map, xform => { + _.each(this.map, (xform) => { xform.reset(); }); return true; @@ -460,7 +460,7 @@ class WorkSheetXform extends BaseXform { // compact the rows and cells model.rows = (model.rows && model.rows.filter(Boolean)) || []; - model.rows.forEach(row => { + model.rows.forEach((row) => { row.cells = (row.cells && row.cells.filter(Boolean)) || []; }); @@ -475,7 +475,7 @@ class WorkSheetXform extends BaseXform { if (match) { const drawingName = match[1]; const drawing = options.drawings[drawingName]; - drawing.anchors.forEach(anchor => { + drawing.anchors.forEach((anchor) => { if (anchor.medium) { const image = { type: 'image', @@ -501,7 +501,7 @@ class WorkSheetXform extends BaseXform { } } - model.tables = (model.tables || []).map(tablePart => { + model.tables = (model.tables || []).map((tablePart) => { const rel = rels[tablePart.rId]; return options.tables[rel.Target]; }); diff --git a/lib/xlsx/xform/static-xform.js b/lib/xlsx/xform/static-xform.js index 1bb1ef6fa..5c52ac1a4 100644 --- a/lib/xlsx/xform/static-xform.js +++ b/lib/xlsx/xform/static-xform.js @@ -13,7 +13,7 @@ const XmlStream = require('../../utils/xml-stream'); function build(xmlStream, model) { xmlStream.openNode(model.tag, model.$); if (model.c) { - model.c.forEach(child => { + model.c.forEach((child) => { build(xmlStream, child); }); } diff --git a/lib/xlsx/xform/strings/phonetic-text-xform.js b/lib/xlsx/xform/strings/phonetic-text-xform.js index fdd20588e..d8b254573 100644 --- a/lib/xlsx/xform/strings/phonetic-text-xform.js +++ b/lib/xlsx/xform/strings/phonetic-text-xform.js @@ -28,7 +28,7 @@ class PhoneticTextXform extends BaseXform { }); if (model && model.hasOwnProperty('richText') && model.richText) { const {r} = this.map; - model.richText.forEach(text => { + model.richText.forEach((text) => { r.render(xmlStream, text); }); } else if (model) { diff --git a/lib/xlsx/xform/strings/shared-string-xform.js b/lib/xlsx/xform/strings/shared-string-xform.js index e23cfde7f..2ba7c5b3c 100644 --- a/lib/xlsx/xform/strings/shared-string-xform.js +++ b/lib/xlsx/xform/strings/shared-string-xform.js @@ -32,7 +32,7 @@ class SharedStringXform extends BaseXform { xmlStream.openNode(this.tag); if (model && model.hasOwnProperty('richText') && model.richText) { if (model.richText.length) { - model.richText.forEach(text => { + model.richText.forEach((text) => { this.map.r.render(xmlStream, text); }); } else { diff --git a/lib/xlsx/xform/strings/shared-strings-xform.js b/lib/xlsx/xform/strings/shared-strings-xform.js index 0777b68d0..79ccea7a6 100644 --- a/lib/xlsx/xform/strings/shared-strings-xform.js +++ b/lib/xlsx/xform/strings/shared-strings-xform.js @@ -77,7 +77,7 @@ class SharedStringsXform extends BaseXform { }); const sx = this.sharedStringXform; - model.values.forEach(sharedString => { + model.values.forEach((sharedString) => { sx.render(xmlStream, sharedString); }); xmlStream.closeNode(); diff --git a/lib/xlsx/xform/style/fill-xform.js b/lib/xlsx/xform/style/fill-xform.js index 007d03115..c25238754 100644 --- a/lib/xlsx/xform/style/fill-xform.js +++ b/lib/xlsx/xform/style/fill-xform.js @@ -191,7 +191,7 @@ class GradientFillXform extends BaseXform { } const stopXform = this.map.stop; - model.stops.forEach(stopModel => { + model.stops.forEach((stopModel) => { stopXform.render(xmlStream, stopModel); }); diff --git a/lib/xlsx/xform/style/styles-xform.js b/lib/xlsx/xform/style/styles-xform.js index 6380c12f7..78b39be25 100644 --- a/lib/xlsx/xform/style/styles-xform.js +++ b/lib/xlsx/xform/style/styles-xform.js @@ -98,7 +98,7 @@ class StylesXform extends BaseXform { // model has been built by style manager role (contains xml) if (model.numFmts && model.numFmts.length) { xmlStream.openNode('numFmts', {count: model.numFmts.length}); - model.numFmts.forEach(numFmtXml => { + model.numFmts.forEach((numFmtXml) => { xmlStream.writeXml(numFmtXml); }); xmlStream.closeNode(); @@ -109,19 +109,19 @@ class StylesXform extends BaseXform { this._addFont({size: 11, color: {theme: 1}, name: 'Calibri', family: 2, scheme: 'minor'}); } xmlStream.openNode('fonts', {count: model.fonts.length, 'x14ac:knownFonts': 1}); - model.fonts.forEach(fontXml => { + model.fonts.forEach((fontXml) => { xmlStream.writeXml(fontXml); }); xmlStream.closeNode(); xmlStream.openNode('fills', {count: model.fills.length}); - model.fills.forEach(fillXml => { + model.fills.forEach((fillXml) => { xmlStream.writeXml(fillXml); }); xmlStream.closeNode(); xmlStream.openNode('borders', {count: model.borders.length}); - model.borders.forEach(borderXml => { + model.borders.forEach((borderXml) => { xmlStream.writeXml(borderXml); }); xmlStream.closeNode(); @@ -129,7 +129,7 @@ class StylesXform extends BaseXform { this.map.cellStyleXfs.render(xmlStream, [{numFmtId: 0, fontId: 0, fillId: 0, borderId: 0, xfId: 0}]); xmlStream.openNode('cellXfs', {count: model.styles.length}); - model.styles.forEach(styleXml => { + model.styles.forEach((styleXml) => { xmlStream.writeXml(styleXml); }); xmlStream.closeNode(); @@ -206,7 +206,7 @@ class StylesXform extends BaseXform { }; if (this.model.numFmts) { const numFmtIndex = this.index.numFmt; - this.model.numFmts.forEach(numFmt => { + this.model.numFmts.forEach((numFmt) => { numFmtIndex[numFmt.id] = numFmt.formatCode; }); } diff --git a/lib/xlsx/xform/table/auto-filter-xform.js b/lib/xlsx/xform/table/auto-filter-xform.js index 0c0230b83..837612915 100644 --- a/lib/xlsx/xform/table/auto-filter-xform.js +++ b/lib/xlsx/xform/table/auto-filter-xform.js @@ -24,7 +24,7 @@ class AutoFilterXform extends BaseXform { render(xmlStream, model) { xmlStream.openNode(this.tag, {ref: model.autoFilterRef}); - model.columns.forEach(column => { + model.columns.forEach((column) => { this.map.filterColumn.render(xmlStream, column); }); diff --git a/lib/xlsx/xform/table/table-xform.js b/lib/xlsx/xform/table/table-xform.js index 002fbda92..0c2f4d4e3 100644 --- a/lib/xlsx/xform/table/table-xform.js +++ b/lib/xlsx/xform/table/table-xform.js @@ -111,7 +111,7 @@ class TableXform extends BaseXform { reconcile(model, options) { // fetch the dfxs from styles - model.columns.forEach(column => { + model.columns.forEach((column) => { if (column.dxfId !== undefined) { column.style = options.styles.getDxfStyle(column.dxfId); } diff --git a/lib/xlsx/xlsx.js b/lib/xlsx/xlsx.js index c9c9d411d..9138dba33 100644 --- a/lib/xlsx/xlsx.js +++ b/lib/xlsx/xlsx.js @@ -88,7 +88,7 @@ class XLSX { media: model.media, mediaIndex: model.mediaIndex, }; - Object.keys(model.drawings).forEach(name => { + Object.keys(model.drawings).forEach((name) => { const drawing = model.drawings[name]; const drawingRel = model.drawingRels[name]; if (drawingRel) { @@ -96,7 +96,7 @@ class XLSX { o[rel.Id] = rel; return o; }, {}); - (drawing.anchors || []).forEach(anchor => { + (drawing.anchors || []).forEach((anchor) => { const hyperlinks = anchor.picture && anchor.picture.hyperlinks; if (hyperlinks && drawingOptions.rels[hyperlinks.rId]) { hyperlinks.hyperlink = drawingOptions.rels[hyperlinks.rId].Target; @@ -111,7 +111,7 @@ class XLSX { const tableOptions = { styles: model.styles, }; - Object.values(model.tables).forEach(table => { + Object.values(model.tables).forEach((table) => { tableXform.reconcile(table, tableOptions); }); @@ -126,7 +126,7 @@ class XLSX { tables: model.tables, vmlDrawings: model.vmlDrawings, }; - model.worksheets.forEach(worksheet => { + model.worksheets.forEach((worksheet) => { worksheet.relationships = model.worksheetRels[worksheet.sheetNo]; worksheetXform.reconcile(worksheet, sheetOptions); }); @@ -191,7 +191,7 @@ class XLSX { model.media.push(medium); resolve(); }); - entry.on('error', error => { + entry.on('error', (error) => { reject(error); }); entry.pipe(streamBuf); @@ -401,7 +401,7 @@ class XLSX { async addMedia(zip, model) { await Promise.all( - model.media.map(async medium => { + model.media.map(async (medium) => { if (medium.type === 'image') { const filename = `xl/media/${medium.name}.${medium.extension}`; if (medium.filename) { @@ -426,7 +426,7 @@ class XLSX { const drawingXform = new DrawingXform(); const relsXform = new RelationshipsXform(); - model.worksheets.forEach(worksheet => { + model.worksheets.forEach((worksheet) => { const {drawing} = worksheet; if (drawing) { drawingXform.prepare(drawing, {}); @@ -442,9 +442,9 @@ class XLSX { addTables(zip, model) { const tableXform = new TableXform(); - model.worksheets.forEach(worksheet => { + model.worksheets.forEach((worksheet) => { const {tables} = worksheet; - tables.forEach(table => { + tables.forEach((table) => { tableXform.prepare(table, {}); const tableXml = tableXform.toXml(table); zip.append(tableXml, {name: `xl/tables/${table.target}`}); @@ -471,7 +471,7 @@ class XLSX { async addThemes(zip, model) { const themes = model.themes || {theme1: theme1Xml}; - Object.keys(themes).forEach(name => { + Object.keys(themes).forEach((name) => { const xml = themes[name]; const path = `xl/theme/${name}.xml`; zip.append(xml, {name: path}); @@ -497,7 +497,7 @@ class XLSX { if (model.sharedStrings.count) { relationships.push({Id: `rId${count++}`, Type: XLSX.RelType.SharedStrings, Target: 'sharedStrings.xml'}); } - model.worksheets.forEach(worksheet => { + model.worksheets.forEach((worksheet) => { worksheet.rId = `rId${count++}`; relationships.push({Id: worksheet.rId, Type: XLSX.RelType.Worksheet, Target: `worksheets/sheet${worksheet.id}.xml`}); }); @@ -532,7 +532,7 @@ class XLSX { const vmlNotesXform = new VmlNotesXform(); // write sheets - model.worksheets.forEach(worksheet => { + model.worksheets.forEach((worksheet) => { let xmlStream = new XmlStream(); worksheetXform.render(xmlStream, worksheet); zip.append(xmlStream.xml, {name: `xl/worksheets/sheet${worksheet.id}.xml`}); @@ -598,9 +598,9 @@ class XLSX { worksheetOptions.commentRefs = model.commentRefs = []; let tableCount = 0; model.tables = []; - model.worksheets.forEach(worksheet => { + model.worksheets.forEach((worksheet) => { // assign unique filenames to tables - worksheet.tables.forEach(table => { + worksheet.tables.forEach((table) => { tableCount++; table.target = `table${tableCount}.xml`; table.id = tableCount; @@ -643,7 +643,7 @@ class XLSX { stream.on('finish', () => { resolve(); }); - stream.on('error', error => { + stream.on('error', (error) => { reject(error); }); diff --git a/package.json b/package.json index ae555aeb2..01f45102a 100644 --- a/package.json +++ b/package.json @@ -96,23 +96,23 @@ "pageSetup" ], "dependencies": { - "archiver": "^4.0.2", + "archiver": "^5.0.0", "dayjs": "^1.8.34", "fast-csv": "^4.3.1", - "jszip": "^3.4.0", + "jszip": "^3.5.0", "readable-stream": "^3.6.0", "saxes": "^5.0.1", "tmp": "^0.2.0", "unzipper": "^0.10.11", - "uuid": "^7.0.3" + "uuid": "^8.3.0" }, "devDependencies": { "@babel/cli": "^7.10.5", "@babel/core": "^7.11.4", "@babel/preset-env": "^7.11.0", "@types/chai": "^4.2.12", - "@types/mocha": "^7.0.2", - "@types/node": "^13.13.15", + "@types/mocha": "^8.0.3", + "@types/node": "^14.11.2", "babelify": "^10.0.0", "browserify": "^16.5.2", "chai": "^4.2.0", @@ -121,8 +121,8 @@ "core-js": "^3.6.5", "dirty-chai": "^2.0.1", "eslint": "^6.5.1", - "eslint-config-airbnb-base": "^14.1.0", - "eslint-config-prettier": "^6.11.0", + "eslint-config-airbnb-base": "^14.2.0", + "eslint-config-prettier": "^6.12.0", "eslint-friendly-formatter": "^4.0.1", "eslint-plugin-import": "^2.22.0", "eslint-plugin-node": "^11.1.0", @@ -132,16 +132,16 @@ "grunt-babel": "^8.0.0", "grunt-browserify": "^5.3.0", "grunt-contrib-copy": "^1.0.0", - "grunt-contrib-jasmine": "^2.1.0", + "grunt-contrib-jasmine": "^2.2.0", "grunt-contrib-watch": "^1.1.0", "grunt-terser": "^1.0.0", - "husky": "^4.2.5", + "husky": "^4.3.0", "lint-staged": "^10.2.13", - "mocha": "^7.1.1", - "prettier-eslint": "^9.0.0", + "mocha": "^7.2.0", + "prettier-eslint": "^11.0.0", "prettier-eslint-cli": "^5.0.0", "regenerator-runtime": "^0.13.7", - "ts-node": "^8.9.0", + "ts-node": "^8.10.2", "typescript": "^3.9.7" } } diff --git a/spec/browser/exceljs.spec.js b/spec/browser/exceljs.spec.js index ce7c21e0a..ec53d130c 100644 --- a/spec/browser/exceljs.spec.js +++ b/spec/browser/exceljs.spec.js @@ -13,7 +13,7 @@ function unexpectedError(done) { } describe('ExcelJS', () => { - it('should read and write xlsx via binary buffer', done => { + it('should read and write xlsx via binary buffer', (done) => { const wb = new ExcelJS.Workbook(); const ws = wb.addWorksheet('blort'); @@ -22,7 +22,7 @@ describe('ExcelJS', () => { wb.xlsx .writeBuffer() - .then(buffer => { + .then((buffer) => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.load(buffer).then(() => { const ws2 = wb2.getWorksheet('blort'); @@ -33,12 +33,12 @@ describe('ExcelJS', () => { done(); }); }) - .catch(error => { + .catch((error) => { throw error; }) .catch(unexpectedError(done)); }); - it('should read and write xlsx via base64 buffer', done => { + it('should read and write xlsx via base64 buffer', (done) => { const options = { base64: true, }; @@ -50,7 +50,7 @@ describe('ExcelJS', () => { wb.xlsx .writeBuffer(options) - .then(buffer => { + .then((buffer) => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.load(buffer.toString('base64'), options).then(() => { const ws2 = wb2.getWorksheet('blort'); @@ -61,12 +61,12 @@ describe('ExcelJS', () => { done(); }); }) - .catch(error => { + .catch((error) => { throw error; }) .catch(unexpectedError(done)); }); - it('should write csv via buffer', done => { + it('should write csv via buffer', (done) => { const wb = new ExcelJS.Workbook(); const ws = wb.addWorksheet('blort'); @@ -77,13 +77,13 @@ describe('ExcelJS', () => { wb.csv .writeBuffer() - .then(buffer => { + .then((buffer) => { expect(buffer.toString()).toEqual( '"Hello, World!",What time is it?\n7,12pm' ); done(); }) - .catch(error => { + .catch((error) => { throw error; }) .catch(unexpectedError(done)); diff --git a/spec/integration/issues/issue-1328-xlsx-worksheet-reader-date.spec.js b/spec/integration/issues/issue-1328-xlsx-worksheet-reader-date.spec.js index 2337fc790..4dcd50b3d 100644 --- a/spec/integration/issues/issue-1328-xlsx-worksheet-reader-date.spec.js +++ b/spec/integration/issues/issue-1328-xlsx-worksheet-reader-date.spec.js @@ -1,20 +1,33 @@ const ExcelJS = verquire('exceljs'); const fs = require('fs'); - describe('github issues: Date field with cache style', () => { const rows = []; - beforeEach(() => - new Promise((resolve, reject) => { - const workbookReader = new ExcelJS.stream.xlsx.WorkbookReader(fs.createReadStream('./spec/integration/data/dateIssue.xlsx'), { worksheets: 'emit', styles: 'cache', sharedStrings: 'cache', hyperlinks: 'ignore', entries: 'ignore' }); - workbookReader.read(); - workbookReader.on('worksheet', worksheet => worksheet.on('row', row => rows.push(row.values[1]))); - workbookReader.on('end', resolve); - workbookReader.on('error', reject); - - }) + beforeEach( + () => + new Promise((resolve, reject) => { + const workbookReader = new ExcelJS.stream.xlsx.WorkbookReader( + fs.createReadStream('./spec/integration/data/dateIssue.xlsx'), + { + worksheets: 'emit', + styles: 'cache', + sharedStrings: 'cache', + hyperlinks: 'ignore', + entries: 'ignore', + } + ); + workbookReader.read(); + workbookReader.on('worksheet', (worksheet) => + worksheet.on('row', (row) => rows.push(row.values[1])) + ); + workbookReader.on('end', resolve); + workbookReader.on('error', reject); + }) ); it('issue 1328 - should emit row with Date Object', () => { - expect(rows).that.deep.equals(['Date', new Date('2020-11-20T00:00:00.000Z')]); + expect(rows).that.deep.equals([ + 'Date', + new Date('2020-11-20T00:00:00.000Z'), + ]); }); }); diff --git a/spec/integration/issues/issue-219-1904-dates.spec.js b/spec/integration/issues/issue-219-1904-dates.spec.js index f9861063c..5a339a1d4 100644 --- a/spec/integration/issues/issue-219-1904-dates.spec.js +++ b/spec/integration/issues/issue-219-1904-dates.spec.js @@ -27,7 +27,7 @@ describe('github issues', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { expect(wb2.properties.date1904).to.equal(true); const ws2 = wb2.getWorksheet('Sheet1'); diff --git a/spec/integration/issues/issue-234-vertical-tab-char.spec.js b/spec/integration/issues/issue-234-vertical-tab-char.spec.js index c1e2cbd46..f4bb90d42 100644 --- a/spec/integration/issues/issue-234-vertical-tab-char.spec.js +++ b/spec/integration/issues/issue-234-vertical-tab-char.spec.js @@ -20,7 +20,7 @@ describe('github issues', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('Sheet1'); expect(ws2.getCell('A1').value).to.equal('Hello, World!'); expect(ws2.getCell('A2').value).to.equal('Hello, World!'); diff --git a/spec/integration/issues/issue-257-sheet-order.spec.js b/spec/integration/issues/issue-257-sheet-order.spec.js index cb3e4556e..44c2ee1b6 100644 --- a/spec/integration/issues/issue-257-sheet-order.spec.js +++ b/spec/integration/issues/issue-257-sheet-order.spec.js @@ -6,7 +6,7 @@ describe('github issues', () => { return wb.xlsx .readFile('./spec/integration/data/test-issue-257.xlsx') .then(() => { - expect(wb.worksheets.map(ws => ws.name)).to.deep.equal([ + expect(wb.worksheets.map((ws) => ws.name)).to.deep.equal([ 'First', 'Second', ]); diff --git a/spec/integration/issues/issue-275-hyperlink-query-param.spec.js b/spec/integration/issues/issue-275-hyperlink-query-param.spec.js index 662414ae4..0d52695d6 100644 --- a/spec/integration/issues/issue-275-hyperlink-query-param.spec.js +++ b/spec/integration/issues/issue-275-hyperlink-query-param.spec.js @@ -27,7 +27,7 @@ describe('github issues', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('Sheet1'); expect(ws2.getCell('A1').value).to.deep.equal(hyperlink); }); diff --git a/spec/integration/issues/issue-623-borders-for-merged-cell.spec.js b/spec/integration/issues/issue-623-borders-for-merged-cell.spec.js index 073c87266..efce01008 100644 --- a/spec/integration/issues/issue-623-borders-for-merged-cell.spec.js +++ b/spec/integration/issues/issue-623-borders-for-merged-cell.spec.js @@ -20,7 +20,7 @@ describe('github issues', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { // written file should have same borders const worksheet = wb2.getWorksheet(1); checkBorder(worksheet.getCell('B2'), ['left', 'top']); @@ -32,7 +32,7 @@ describe('github issues', () => { }); function checkBorder(cell, borders) { - borders.forEach(b => { + borders.forEach((b) => { expect(cell.style.border).to.have.property(b); }); } diff --git a/spec/integration/issues/issue-703-speciel-cell-file.spec.js b/spec/integration/issues/issue-703-speciel-cell-file.spec.js index cb7ead21c..95267d339 100644 --- a/spec/integration/issues/issue-703-speciel-cell-file.spec.js +++ b/spec/integration/issues/issue-703-speciel-cell-file.spec.js @@ -32,7 +32,7 @@ describe('github issues', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('Sheet1'); for (let i = 0; i < specialValues.length; i++) { const value = specialValues[i]; diff --git a/spec/integration/issues/issue-771-data-validation-without-type.spec.js b/spec/integration/issues/issue-771-data-validation-without-type.spec.js index a46505c16..9e48b3700 100644 --- a/spec/integration/issues/issue-771-data-validation-without-type.spec.js +++ b/spec/integration/issues/issue-771-data-validation-without-type.spec.js @@ -3,8 +3,6 @@ const ExcelJS = verquire('exceljs'); describe('github issues', () => { it('issue 771 - Issue with dataValidation without type and with formula1 or formula2', () => { const wb = new ExcelJS.Workbook(); - return wb.xlsx - .readFile('./spec/integration/data/test-issue-771.xlsx'); + return wb.xlsx.readFile('./spec/integration/data/test-issue-771.xlsx'); }); }); - diff --git a/spec/integration/issues/issue-991-csv-read-dates.spec.js b/spec/integration/issues/issue-991-csv-read-dates.spec.js index e2746c7b5..4b6236568 100644 --- a/spec/integration/issues/issue-991-csv-read-dates.spec.js +++ b/spec/integration/issues/issue-991-csv-read-dates.spec.js @@ -5,7 +5,7 @@ describe('github issues', () => { const wb = new ExcelJS.Workbook(); return wb.csv .readFile('./spec/integration/data/test-issue-991.csv') - .then(worksheet => { + .then((worksheet) => { expect(worksheet.getCell('A1').value.toString()).to.equal( new Date('2019-11-04T00:00:00').toString() ); diff --git a/spec/integration/pr/pr-896/test-pr-896.spec.js b/spec/integration/pr/pr-896/test-pr-896.spec.js index ee92bf20f..89e778917 100644 --- a/spec/integration/pr/pr-896/test-pr-896.spec.js +++ b/spec/integration/pr/pr-896/test-pr-896.spec.js @@ -53,7 +53,7 @@ describe('pr related issues', () => { const wb2 = new Excel.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('sheet1'); expect(ws2).to.not.be.undefined(); expect(ws2.getCell('A1').value).to.deep.equal(TEST_VALUE); diff --git a/spec/integration/pr/test-pr-1431.spec.js b/spec/integration/pr/test-pr-1431.spec.js index 631a49839..15fa9bb43 100644 --- a/spec/integration/pr/test-pr-1431.spec.js +++ b/spec/integration/pr/test-pr-1431.spec.js @@ -24,16 +24,19 @@ describe('github issues', () => { await workbook.commit(); return new Promise((resolve, reject) => { - const workbookReader = new ExcelJS.stream.xlsx.WorkbookReader('./test.xlsx', { - entries: 'emit', - hyperlinks: 'cache', - sharedStrings: 'cache', - styles: 'cache', - worksheets: 'emit', - }); - - workbookReader.on('worksheet', worksheet => - worksheet.on('row', row => { + const workbookReader = new ExcelJS.stream.xlsx.WorkbookReader( + './test.xlsx', + { + entries: 'emit', + hyperlinks: 'cache', + sharedStrings: 'cache', + styles: 'cache', + worksheets: 'emit', + } + ); + + workbookReader.on('worksheet', (worksheet) => + worksheet.on('row', (row) => { expect(row.values[1]).to.eql(rowData[0]); expect(row.values[2]).to.equal(rowData[1]); diff --git a/spec/integration/pr/test-pr-896.spec.js b/spec/integration/pr/test-pr-896.spec.js index 7870c15c0..4d00ff1a1 100644 --- a/spec/integration/pr/test-pr-896.spec.js +++ b/spec/integration/pr/test-pr-896.spec.js @@ -19,7 +19,7 @@ describe('pr related issues', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('foo'); expect(ws2.getCell('A1').value).to.equal(' leading'); expect(ws2.getCell('A1').note).to.equal(' leading'); @@ -43,7 +43,7 @@ describe('pr related issues', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('foo'); expect(ws2.getCell('A1').value).to.equal('Hello,\nWorld!'); expect(ws2.getCell('A1').note).to.equal('Later,\nAlligator!'); diff --git a/spec/integration/workbook-xlsx-reader.spec.js b/spec/integration/workbook-xlsx-reader.spec.js index f6ad0a773..525731029 100644 --- a/spec/integration/workbook-xlsx-reader.spec.js +++ b/spec/integration/workbook-xlsx-reader.spec.js @@ -31,7 +31,7 @@ describe('WorkbookReader', () => { () => { throw new Error('Promise unexpectedly fulfilled'); }, - err => { + (err) => { expect(err.message).to.equal('Max row count (10) exceeded'); } ); @@ -46,7 +46,7 @@ describe('WorkbookReader', () => { () => { throw new Error('Promise unexpectedly fulfilled'); }, - err => { + (err) => { expect(err.message).to.equal('Max row count (100) exceeded'); } ); @@ -73,7 +73,7 @@ describe('WorkbookReader', () => { () => { throw new Error('Promise unexpectedly fulfilled'); }, - err => { + (err) => { expect(err.message).to.equal('Max column count (15) exceeded'); } ); @@ -88,7 +88,7 @@ describe('WorkbookReader', () => { () => { throw new Error('Promise unexpectedly fulfilled'); }, - err => { + (err) => { expect(err.message).to.equal('Max column count (10) exceeded'); } ); @@ -117,7 +117,7 @@ describe('WorkbookReader', () => { () => { throw new Error('Promise unexpectedly fulfilled'); }, - err => { + (err) => { expect(err.message).to.equal('Max row count (10) exceeded'); } ); @@ -274,7 +274,7 @@ describe('WorkbookReader', () => { () => { throw new Error('Promise unexpectedly fulfilled'); }, - err => { + (err) => { expect(err.message).to.equal( '3:1: text data outside of root node.' ); @@ -310,14 +310,14 @@ describe('WorkbookReader', () => { describe('with image`s tl anchor', () => { it('Should integer part of col equals nativeCol', function() { - this.worksheet.getImages().forEach(image => { + this.worksheet.getImages().forEach((image) => { expect(Math.floor(image.range.tl.col)).to.equal( image.range.tl.nativeCol ); }); }); it('Should integer part of row equals nativeRow', function() { - this.worksheet.getImages().forEach(image => { + this.worksheet.getImages().forEach((image) => { expect(Math.floor(image.range.tl.row)).to.equal( image.range.tl.nativeRow ); @@ -326,7 +326,7 @@ describe('WorkbookReader', () => { it('Should anchor width equals to column width when custom', function() { const ws = this.worksheet; - ws.getImages().forEach(image => { + ws.getImages().forEach((image) => { const col = ws.getColumn(image.range.tl.nativeCol + 1); if (col.isCustomWidth) { @@ -341,7 +341,7 @@ describe('WorkbookReader', () => { it('Should anchor height equals to row height', function() { const ws = this.worksheet; - ws.getImages().forEach(image => { + ws.getImages().forEach((image) => { const row = ws.getRow(image.range.tl.nativeRow + 1); if (row.height) { @@ -357,14 +357,14 @@ describe('WorkbookReader', () => { describe('with image`s br anchor', () => { it('Should integer part of col equals nativeCol', function() { - this.worksheet.getImages().forEach(image => { + this.worksheet.getImages().forEach((image) => { expect(Math.floor(image.range.br.col)).to.equal( image.range.br.nativeCol ); }); }); it('Should integer part of row equals nativeRow', function() { - this.worksheet.getImages().forEach(image => { + this.worksheet.getImages().forEach((image) => { expect(Math.floor(image.range.br.row)).to.equal( image.range.br.nativeRow ); @@ -373,7 +373,7 @@ describe('WorkbookReader', () => { it('Should anchor width equals to column width when custom', function() { const ws = this.worksheet; - ws.getImages().forEach(image => { + ws.getImages().forEach((image) => { const col = ws.getColumn(image.range.br.nativeCol + 1); if (col.isCustomWidth) { @@ -388,7 +388,7 @@ describe('WorkbookReader', () => { it('Should anchor height equals to row height', function() { const ws = this.worksheet; - ws.getImages().forEach(image => { + ws.getImages().forEach((image) => { const row = ws.getRow(image.range.br.nativeRow + 1); if (row.height) { diff --git a/spec/integration/workbook-xlsx-writer/workbook-xlsx-writer.spec.js b/spec/integration/workbook-xlsx-writer/workbook-xlsx-writer.spec.js index 6feb93aca..f35025375 100644 --- a/spec/integration/workbook-xlsx-writer/workbook-xlsx-writer.spec.js +++ b/spec/integration/workbook-xlsx-writer/workbook-xlsx-writer.spec.js @@ -36,7 +36,7 @@ describe('WorkbookWriter', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { testUtils.checkTestBook(wb2, 'xlsx'); }); }); @@ -64,7 +64,7 @@ describe('WorkbookWriter', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('Hello'); expect(ws2.getCell('A1').value).to.deep.equal({ formula: 'ROW()+COLUMN()', @@ -110,7 +110,7 @@ describe('WorkbookWriter', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('Hello'); expect(ws2.autoFilter).to.equal('A1:B1'); }); @@ -132,7 +132,7 @@ describe('WorkbookWriter', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { testUtils.checkTestBook(wb2, 'xlsx', undefined, { checkStyles: false, }); @@ -173,10 +173,10 @@ describe('WorkbookWriter', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('blort'); ['A1', 'B1', 'C1', 'A2', 'B2', 'C2', 'A3', 'B3', 'C3'].forEach( - address => { + (address) => { expect(ws2.getCell(address).value).to.equal(address); } ); @@ -248,7 +248,7 @@ describe('WorkbookWriter', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('Hello'); expect(ws2.getCell('A1').value).to.deep.equal({ richText: [ @@ -285,7 +285,7 @@ describe('WorkbookWriter', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { for (i = 1; i <= numSheets; i++) { const ws2 = wb2.getWorksheet(`sheet${i}`); expect(ws2).to.be.ok(); @@ -336,7 +336,7 @@ describe('WorkbookWriter', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('blort'); expect(ws2.getCell('A1').name).to.equal('five'); @@ -366,7 +366,7 @@ describe('WorkbookWriter', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('blort'); expect(ws2.getCell('A1').value).to.equal(xmlCharacters); }); @@ -386,7 +386,7 @@ describe('WorkbookWriter', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { testUtils.checkTestBook(wb2, 'xlsx', ['dataValidations']); }); }); @@ -411,7 +411,7 @@ describe('WorkbookWriter', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { testUtils.checkTestBook(wb2, 'xlsx', ['dataValidations']); }); }); @@ -584,7 +584,7 @@ describe('WorkbookWriter', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { testUtils.checkTestBook(wb2, 'xlsx', ['conditionalFormatting']); }); }); diff --git a/spec/integration/workbook/images.spec.js b/spec/integration/workbook/images.spec.js index 423293f7d..ac26256c4 100644 --- a/spec/integration/workbook/images.spec.js +++ b/spec/integration/workbook/images.spec.js @@ -37,7 +37,7 @@ describe('Workbook', () => { return fsReadFileAsync(IMAGE_FILENAME); }) - .then(imageData => { + .then((imageData) => { const backgroundId2 = ws2.getBackgroundImageId(); const image = wb2.getImage(backgroundId2); @@ -81,7 +81,7 @@ describe('Workbook', () => { return fsReadFileAsync(IMAGE_FILENAME); }) - .then(imageData => { + .then((imageData) => { const images = ws2.getImages(); expect(images.length).to.equal(1); @@ -125,7 +125,7 @@ describe('Workbook', () => { return fsReadFileAsync(IMAGE_FILENAME); }) - .then(imageData => { + .then((imageData) => { const images = ws2.getImages(); expect(images.length).to.equal(1); @@ -166,7 +166,7 @@ describe('Workbook', () => { return fsReadFileAsync(IMAGE_FILENAME); }) - .then(imageData => { + .then((imageData) => { const images = ws2.getImages(); expect(images.length).to.equal(1); @@ -213,7 +213,7 @@ describe('Workbook', () => { return fsReadFileAsync(IMAGE_FILENAME); }) - .then(imageData => { + .then((imageData) => { const images = ws2.getImages(); expect(images.length).to.equal(1); @@ -271,7 +271,7 @@ describe('Workbook', () => { return fsReadFileAsync(IMAGE_FILENAME); }) - .then(imageData => { + .then((imageData) => { const images = ws2.getImages(); expect(images.length).to.equal(2); diff --git a/spec/integration/workbook/styles.spec.js b/spec/integration/workbook/styles.spec.js index 5d205fe15..1762dce08 100644 --- a/spec/integration/workbook/styles.spec.js +++ b/spec/integration/workbook/styles.spec.js @@ -47,10 +47,10 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('blort'); ['A1', 'B1', 'C1', 'A2', 'B2', 'C2', 'A3', 'B3', 'C3'].forEach( - address => { + (address) => { expect(ws2.getCell(address).value).to.equal(address); } ); @@ -125,7 +125,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('blort'); expect(ws2.getCell('B4').fill).to.deep.equal( diff --git a/spec/integration/workbook/workbook.spec.js b/spec/integration/workbook/workbook.spec.js index 850147d0b..fb56b0694 100644 --- a/spec/integration/workbook/workbook.spec.js +++ b/spec/integration/workbook/workbook.spec.js @@ -19,7 +19,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { testUtils.checkTestBook(wb2, 'xlsx'); }); }); @@ -40,7 +40,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { testUtils.checkTestBook(wb2, 'xlsx'); }); }); @@ -58,7 +58,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { testUtils.checkTestBook(wb2, 'xlsx'); }); }); @@ -79,7 +79,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { testUtils.checkTestBook(wb2, 'xlsx'); }); }); @@ -97,7 +97,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { testUtils.checkTestBook(wb2, 'xlsx'); }); }); @@ -120,7 +120,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { expect(wb2.getWorksheet('Hello, World!')).to.be.ok(); expect(wb2.getWorksheet('This & That')).to.be.ok(); }); @@ -140,7 +140,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { expect(wb2.creator).to.equal(wb.creator); expect(wb2.lastModifiedBy).to.equal(wb.lastModifiedBy); expect(wb2.created).to.equalDate(wb.created); @@ -167,7 +167,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('printHeader'); expect(ws2.pageSetup.printTitlesRow).to.equal('1:2'); expect(ws2.pageSetup.printTitlesColumn).to.be.undefined(); @@ -197,7 +197,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('printColumn'); expect(ws2.pageSetup.printTitlesRow).to.be.undefined(); expect(ws2.pageSetup.printTitlesColumn).to.equal('A:B'); @@ -242,7 +242,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('printHeaderAndColumn'); expect(ws2.pageSetup.printTitlesRow).to.equal('1:2'); expect(ws2.pageSetup.printTitlesColumn).to.equal('A:B'); @@ -262,7 +262,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('Hello'); expect(ws2.getCell('A1').value).to.deep.equal({ formula: 'ROW()+COLUMN()', @@ -303,7 +303,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('Hello'); expect(ws2.autoFilter).to.equal('A1:B1'); }); @@ -321,7 +321,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { expect(wb2.company).to.equal(wb.company); expect(wb2.manager).to.equal(wb.manager); }); @@ -342,7 +342,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { expect(wb2.title).to.equal(wb.title); expect(wb2.subject).to.equal(wb.subject); expect(wb2.keywords).to.equal(wb.keywords); @@ -364,7 +364,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { expect(wb2.language).to.equal(wb.language); expect(wb2.revision).to.equal(wb.revision); expect(wb2.contentStatus).to.equal(wb.contentStatus); @@ -383,7 +383,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('Hello'); expect(ws2.getCell('A1').value).to.equal('Foo'); @@ -403,7 +403,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { testUtils.checkTestBook(wb2, 'xlsx', ['dataValidations']); }); }); @@ -439,7 +439,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { for (i = 1; i <= numSheets; i++) { const ws2 = wb2.getWorksheet(`sheet${i}`); expect(ws2).to.be.ok(); @@ -459,7 +459,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.csv.readFile(TEST_CSV_FILE_NAME).then(() => wb2); }) - .then(wb2 => { + .then((wb2) => { testUtils.checkTestBook(wb2, 'csv'); }); }); @@ -495,7 +495,7 @@ describe('Workbook', () => { .readFile(TEST_CSV_FILE_NAME, readOptions) .then(() => wb2); }) - .then(wb2 => { + .then((wb2) => { testUtils.checkTestBook(wb2, 'csv', false, writeOptions); }); }); @@ -552,7 +552,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2a = wb2.getWorksheet('blort'); const ws2b = wb2.getWorksheet('foo'); @@ -635,7 +635,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('duplicateTest'); expect(ws2.getCell('A2').value).to.equal('OneInfo'); @@ -662,7 +662,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('duplicateTest'); expect(ws2.getCell('A1').value).to.equal('OneInfo'); @@ -687,7 +687,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('duplicateTest'); expect(ws2.getCell('A1').value).to.equal('OneInfo'); @@ -712,7 +712,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('duplicateTest'); expect(ws2.getCell('A1').value).to.equal('OneInfo'); @@ -739,7 +739,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('blort'); expect(ws2.getCell('B2').value).to.equal('B2'); @@ -776,7 +776,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('blort'); expect(ws2.getCell('B2').font).to.deep.equal( @@ -874,7 +874,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { testUtils.checkTestBook(wb2, 'xlsx', sheets, options); }); }); @@ -947,7 +947,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('frozen'); expect(ws2).to.be.ok(); expect(ws2.getCell('A1').value).to.equal('Let it Snow!'); @@ -1024,7 +1024,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { const ws2 = wb2.getWorksheet('split'); expect(ws2).to.be.ok(); expect(ws2.getCell('A1').value).to.equal('Do the splits!'); @@ -1092,7 +1092,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then(wb2 => { + .then((wb2) => { expect(wb2.views).to.deep.equal(wb.views); const ws1b = wb2.getWorksheet('one'); diff --git a/spec/integration/worksheet-xlsx-writer.spec.js b/spec/integration/worksheet-xlsx-writer.spec.js index 38d743389..24a556a9c 100644 --- a/spec/integration/worksheet-xlsx-writer.spec.js +++ b/spec/integration/worksheet-xlsx-writer.spec.js @@ -297,7 +297,7 @@ describe('WorksheetWriter', () => { row3[3] = 'Sam'; row3[5] = dateValue1; rows.push(row3); - rows.forEach(row => { + rows.forEach((row) => { if (row) { ws.addRow(row); } diff --git a/spec/integration/worksheet.spec.js b/spec/integration/worksheet.spec.js index 4a3756283..ff07a2134 100644 --- a/spec/integration/worksheet.spec.js +++ b/spec/integration/worksheet.spec.js @@ -326,7 +326,7 @@ describe('Worksheet', () => { row3[3] = 'Sam'; row3[5] = dateValue1; rows.push(row3); - rows.forEach(row => { + rows.forEach((row) => { if (row) { ws.addRow(row); } @@ -500,7 +500,7 @@ describe('Worksheet', () => { row3[3] = 'Other Doe'; row3[5] = dateValue3; rows.push(row3); - rows.forEach(row => { + rows.forEach((row) => { if (row) { // insert on row 1 every time and thus finally reversed order ws.insertRow(1, row); @@ -1056,7 +1056,7 @@ describe('Worksheet', () => { it('Should not break when importing a .numbers file', () => new ExcelJS.Workbook().xlsx .readFile(path.resolve(__dirname, 'data', 'numbers.numbers')) - .then(workbook => { + .then((workbook) => { expect(workbook).to.have.property('worksheets'); expect(workbook.worksheets).to.have.length(0); })); @@ -1065,7 +1065,7 @@ describe('Worksheet', () => { it('Should not break when importing an Excel file that contains a chartsheet', () => new ExcelJS.Workbook().xlsx .readFile(path.resolve(__dirname, 'data', 'chart-sheet.xlsx')) - .then(workbook => { + .then((workbook) => { expect(workbook).to.have.property('worksheets'); expect(workbook.worksheets).to.have.length(1); })); @@ -1078,7 +1078,7 @@ describe('Worksheet', () => { ]; for (const file of fileList) { - it(`Should set hidden attribute correctly (${file})`, done => { + it(`Should set hidden attribute correctly (${file})`, (done) => { const wb = new ExcelJS.Workbook(); wb.xlsx .readFile( @@ -1103,7 +1103,7 @@ describe('Worksheet', () => { done(); }) - .catch(error => { + .catch((error) => { done(error); }); }); diff --git a/spec/unit/doc/defined-names.spec.js b/spec/unit/doc/defined-names.spec.js index 08111f614..582c3c963 100644 --- a/spec/unit/doc/defined-names.spec.js +++ b/spec/unit/doc/defined-names.spec.js @@ -77,8 +77,8 @@ describe('DefinedNames', () => { dn.add('horizontal!C1', 'horizontal'); dn.add('horizontal!D1', 'horizontal'); - ['A', 'B', 'C', 'D'].forEach(col => { - [1, 2, 3, 4].forEach(row => { + ['A', 'B', 'C', 'D'].forEach((col) => { + [1, 2, 3, 4].forEach((row) => { dn.add(`square!${col}${row}`, 'square'); }); }); diff --git a/spec/unit/doc/workbook.spec.js b/spec/unit/doc/workbook.spec.js index ff6a1d7d3..ffde48eab 100644 --- a/spec/unit/doc/workbook.spec.js +++ b/spec/unit/doc/workbook.spec.js @@ -1,4 +1,4 @@ -const simpleWorkbookModel = require('./../data/simpleWorkbook.json'); +const simpleWorkbookModel = require('../data/simpleWorkbook.json'); const testUtils = require('../../utils/index'); const Excel = verquire('exceljs'); diff --git a/spec/unit/doc/worksheet-table.spec.js b/spec/unit/doc/worksheet-table.spec.js index f87495279..9f69c6c3e 100644 --- a/spec/unit/doc/worksheet-table.spec.js +++ b/spec/unit/doc/worksheet-table.spec.js @@ -157,7 +157,7 @@ describe('Worksheet', () => { table.removeColumns(1); table.commit(); - const newValues = values.map(rVals => spliceArray(rVals, 1, 1)); + const newValues = values.map((rVals) => spliceArray(rVals, 1, 1)); checkTable('A1', ws, newValues); }); diff --git a/spec/unit/doc/worksheet.values.spec.js b/spec/unit/doc/worksheet.values.spec.js index da6784db9..3731dd48a 100644 --- a/spec/unit/doc/worksheet.values.spec.js +++ b/spec/unit/doc/worksheet.values.spec.js @@ -309,7 +309,7 @@ describe('Worksheet', () => { row3[3] = 'Sam'; row3[5] = dateValue1; rows.push(row3); - rows.forEach(row => { + rows.forEach((row) => { if (row) { ws.addRow(row); } @@ -572,7 +572,7 @@ describe('Worksheet', () => { {id: '123', name: 'Jack', dob: new Date(), age: 0}, {id: '124', name: 'Jill', dob: new Date(), age: 0}, ]; - values.forEach(value => { + values.forEach((value) => { ws.addRow(value); }); diff --git a/spec/unit/utils/stream-buf.spec.js b/spec/unit/utils/stream-buf.spec.js index d51489013..d7cfe36bc 100644 --- a/spec/unit/utils/stream-buf.spec.js +++ b/spec/unit/utils/stream-buf.spec.js @@ -27,7 +27,7 @@ describe('StreamBuf', () => { expect(chunk.toString('UTF8')).to.equal('Hello, World!'); }); - it('signals end', done => { + it('signals end', (done) => { const stream = new StreamBuf(); stream.on('finish', () => { done(); diff --git a/spec/unit/utils/utils.spec.js b/spec/unit/utils/utils.spec.js index 53b7a6326..8b6b14aa4 100644 --- a/spec/unit/utils/utils.spec.js +++ b/spec/unit/utils/utils.spec.js @@ -25,13 +25,13 @@ describe('utils', () => { }); }); describe('isDateFmt', () => { - ['yyyy-mm-dd'].forEach(fmt => { + ['yyyy-mm-dd'].forEach((fmt) => { it(`'${fmt}' a date`, () => { expect(utils.isDateFmt(fmt)).to.be.true(); }); }); - ['', '[Green]#,##0 ;[Red](#,##0)'].forEach(fmt => { + ['', '[Green]#,##0 ;[Red](#,##0)'].forEach((fmt) => { it(`'${fmt}' is not a date`, () => { expect(utils.isDateFmt(fmt)).to.be.false(); }); diff --git a/spec/unit/xlsx/xform/book/defined-name-xform.spec.js b/spec/unit/xlsx/xform/book/defined-name-xform.spec.js index 07ce3296a..27a6b10ca 100644 --- a/spec/unit/xlsx/xform/book/defined-name-xform.spec.js +++ b/spec/unit/xlsx/xform/book/defined-name-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const DefinedNameXform = verquire('xlsx/xform/book/defined-name-xform'); diff --git a/spec/unit/xlsx/xform/book/workbook-calc-properties-xform.spec.js b/spec/unit/xlsx/xform/book/workbook-calc-properties-xform.spec.js index 67e772ca2..3ee15fe38 100644 --- a/spec/unit/xlsx/xform/book/workbook-calc-properties-xform.spec.js +++ b/spec/unit/xlsx/xform/book/workbook-calc-properties-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const WorkbookCalcPropertiesXform = verquire( 'xlsx/xform/book/workbook-calc-properties-xform' diff --git a/spec/unit/xlsx/xform/book/workbook-properties-xform.spec.js b/spec/unit/xlsx/xform/book/workbook-properties-xform.spec.js index 3726ffbda..9a908134f 100644 --- a/spec/unit/xlsx/xform/book/workbook-properties-xform.spec.js +++ b/spec/unit/xlsx/xform/book/workbook-properties-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const WorkbookPropertiesXform = verquire( 'xlsx/xform/book/workbook-properties-xform' diff --git a/spec/unit/xlsx/xform/book/workbook-view-xform.spec.js b/spec/unit/xlsx/xform/book/workbook-view-xform.spec.js index 268de357a..5cd4094da 100644 --- a/spec/unit/xlsx/xform/book/workbook-view-xform.spec.js +++ b/spec/unit/xlsx/xform/book/workbook-view-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const WorkbookViewXform = verquire('xlsx/xform/book/workbook-view-xform'); diff --git a/spec/unit/xlsx/xform/compy-xform.js b/spec/unit/xlsx/xform/compy-xform.js index afbd849ee..447904316 100644 --- a/spec/unit/xlsx/xform/compy-xform.js +++ b/spec/unit/xlsx/xform/compy-xform.js @@ -1,77 +1,77 @@ -const BaseXform = verquire('xlsx/xform/base-xform'); - -class CompyXform extends BaseXform { - constructor(options) { - super(); - - this.tag = options.tag; - this.attrs = options.attrs; - this.children = options.children; - this.map = this.children.reduce((map, child) => { - const name = child.name || child.tag; - const tag = child.tag || child.name; - map[tag] = child; - child.name = name; - child.tag = tag; - return map; - }, {}); - } - - prepare(model, options) { - this.children.forEach(child => { - child.xform.prepare(model[child.tag], options); - }); - } - - render(xmlStream, model) { - xmlStream.openNode(this.tag, this.attrs); - this.children.forEach(child => { - child.xform.render(xmlStream, model[child.name]); - }); - xmlStream.closeNode(); - } - - parseOpen(node) { - if (this.parser) { - this.parser.xform.parseOpen(node); - return true; - } - switch (node.name) { - case this.tag: - this.model = {}; - return true; - default: - this.parser = this.map[node.name]; - if (this.parser) { - this.parser.xform.parseOpen(node); - return true; - } - } - return false; - } - - parseText(text) { - if (this.parser) { - this.parser.xform.parseText(text); - } - } - - parseClose(name) { - if (this.parser) { - if (!this.parser.xform.parseClose(name)) { - this.model[this.parser.name] = this.parser.xform.model; - this.parser = undefined; - } - return true; - } - return false; - } - - reconcile(model, options) { - this.children.forEach(child => { - child.xform.prepare(model[child.tag], options); - }); - } -} - -module.exports = CompyXform; +const BaseXform = verquire('xlsx/xform/base-xform'); + +class CompyXform extends BaseXform { + constructor(options) { + super(); + + this.tag = options.tag; + this.attrs = options.attrs; + this.children = options.children; + this.map = this.children.reduce((map, child) => { + const name = child.name || child.tag; + const tag = child.tag || child.name; + map[tag] = child; + child.name = name; + child.tag = tag; + return map; + }, {}); + } + + prepare(model, options) { + this.children.forEach((child) => { + child.xform.prepare(model[child.tag], options); + }); + } + + render(xmlStream, model) { + xmlStream.openNode(this.tag, this.attrs); + this.children.forEach((child) => { + child.xform.render(xmlStream, model[child.name]); + }); + xmlStream.closeNode(); + } + + parseOpen(node) { + if (this.parser) { + this.parser.xform.parseOpen(node); + return true; + } + switch (node.name) { + case this.tag: + this.model = {}; + return true; + default: + this.parser = this.map[node.name]; + if (this.parser) { + this.parser.xform.parseOpen(node); + return true; + } + } + return false; + } + + parseText(text) { + if (this.parser) { + this.parser.xform.parseText(text); + } + } + + parseClose(name) { + if (this.parser) { + if (!this.parser.xform.parseClose(name)) { + this.model[this.parser.name] = this.parser.xform.model; + this.parser = undefined; + } + return true; + } + return false; + } + + reconcile(model, options) { + this.children.forEach((child) => { + child.xform.prepare(model[child.tag], options); + }); + } +} + +module.exports = CompyXform; diff --git a/spec/unit/xlsx/xform/core/content-types-xform.spec.js b/spec/unit/xlsx/xform/core/content-types-xform.spec.js index 82bda44b5..29e4ea0e5 100644 --- a/spec/unit/xlsx/xform/core/content-types-xform.spec.js +++ b/spec/unit/xlsx/xform/core/content-types-xform.spec.js @@ -1,6 +1,6 @@ const fs = require('fs'); -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const ContentTypesXform = verquire('xlsx/xform/core/content-types-xform'); diff --git a/spec/unit/xlsx/xform/core/core-xform.spec.js b/spec/unit/xlsx/xform/core/core-xform.spec.js index 1f2730d40..607457aae 100644 --- a/spec/unit/xlsx/xform/core/core-xform.spec.js +++ b/spec/unit/xlsx/xform/core/core-xform.spec.js @@ -1,6 +1,6 @@ const fs = require('fs'); -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const CoreXform = verquire('xlsx/xform/core/core-xform'); diff --git a/spec/unit/xlsx/xform/core/relationships-xform.spec.js b/spec/unit/xlsx/xform/core/relationships-xform.spec.js index f624474fc..a967a6223 100644 --- a/spec/unit/xlsx/xform/core/relationships-xform.spec.js +++ b/spec/unit/xlsx/xform/core/relationships-xform.spec.js @@ -1,6 +1,6 @@ const fs = require('fs'); -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const RelationshipsXform = verquire('xlsx/xform/core/relationships-xform'); diff --git a/spec/unit/xlsx/xform/drawing/blip-fill-xform.spec.js b/spec/unit/xlsx/xform/drawing/blip-fill-xform.spec.js index ca955f516..40def1e70 100644 --- a/spec/unit/xlsx/xform/drawing/blip-fill-xform.spec.js +++ b/spec/unit/xlsx/xform/drawing/blip-fill-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const BlipFillXform = verquire('xlsx/xform/drawing/blip-fill-xform'); diff --git a/spec/unit/xlsx/xform/drawing/blip-xform.spec.js b/spec/unit/xlsx/xform/drawing/blip-xform.spec.js index 3ce8419c0..788089ca5 100644 --- a/spec/unit/xlsx/xform/drawing/blip-xform.spec.js +++ b/spec/unit/xlsx/xform/drawing/blip-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const BlipXform = verquire('xlsx/xform/drawing/blip-xform'); diff --git a/spec/unit/xlsx/xform/drawing/cell-position-xform.spec.js b/spec/unit/xlsx/xform/drawing/cell-position-xform.spec.js index d592d7429..b278d5b0c 100644 --- a/spec/unit/xlsx/xform/drawing/cell-position-xform.spec.js +++ b/spec/unit/xlsx/xform/drawing/cell-position-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const CellPositionXform = verquire('xlsx/xform/drawing/cell-position-xform'); diff --git a/spec/unit/xlsx/xform/drawing/drawing-xform.spec.js b/spec/unit/xlsx/xform/drawing/drawing-xform.spec.js index adcc73f96..c5ee02ee1 100644 --- a/spec/unit/xlsx/xform/drawing/drawing-xform.spec.js +++ b/spec/unit/xlsx/xform/drawing/drawing-xform.spec.js @@ -1,6 +1,6 @@ const fs = require('fs'); -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const DrawingXform = verquire('xlsx/xform/drawing/drawing-xform'); diff --git a/spec/unit/xlsx/xform/sheet/auto-filter-xform.spec.js b/spec/unit/xlsx/xform/sheet/auto-filter-xform.spec.js index c07cdbc7b..4fe1bd43a 100644 --- a/spec/unit/xlsx/xform/sheet/auto-filter-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/auto-filter-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const AutoFilterXform = verquire('xlsx/xform/sheet/auto-filter-xform'); diff --git a/spec/unit/xlsx/xform/sheet/cell-xform.spec.js b/spec/unit/xlsx/xform/sheet/cell-xform.spec.js index f527e947f..e5dad466c 100644 --- a/spec/unit/xlsx/xform/sheet/cell-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/cell-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const CellXform = verquire('xlsx/xform/sheet/cell-xform'); const SharedStringsXform = verquire('xlsx/xform/strings/shared-strings-xform'); diff --git a/spec/unit/xlsx/xform/sheet/col-xform.spec.js b/spec/unit/xlsx/xform/sheet/col-xform.spec.js index d81d8a0c7..403de2311 100644 --- a/spec/unit/xlsx/xform/sheet/col-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/col-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const ColXform = verquire('xlsx/xform/sheet/col-xform'); diff --git a/spec/unit/xlsx/xform/sheet/data-validations-xform.spec.js b/spec/unit/xlsx/xform/sheet/data-validations-xform.spec.js index b9b2a4b33..1887b3de3 100644 --- a/spec/unit/xlsx/xform/sheet/data-validations-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/data-validations-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const DataValidationsXform = verquire( 'xlsx/xform/sheet/data-validations-xform' diff --git a/spec/unit/xlsx/xform/sheet/dimension-xform.spec.js b/spec/unit/xlsx/xform/sheet/dimension-xform.spec.js index 30f019a47..f0dd04c89 100644 --- a/spec/unit/xlsx/xform/sheet/dimension-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/dimension-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const DimensionXform = verquire('xlsx/xform/sheet/dimension-xform'); diff --git a/spec/unit/xlsx/xform/sheet/header-footer-xform.spec.js b/spec/unit/xlsx/xform/sheet/header-footer-xform.spec.js index 042ac114c..0f643cb6d 100644 --- a/spec/unit/xlsx/xform/sheet/header-footer-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/header-footer-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const HeaderFooterXform = verquire('xlsx/xform/sheet/header-footer-xform'); diff --git a/spec/unit/xlsx/xform/sheet/hyperlink-xform.spec.js b/spec/unit/xlsx/xform/sheet/hyperlink-xform.spec.js index ab1deed3b..4292dfe9d 100644 --- a/spec/unit/xlsx/xform/sheet/hyperlink-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/hyperlink-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const HyperlinkXform = verquire('xlsx/xform/sheet/hyperlink-xform'); diff --git a/spec/unit/xlsx/xform/sheet/merge-cell-xform.spec.js b/spec/unit/xlsx/xform/sheet/merge-cell-xform.spec.js index c7ecc183e..e1b62d92e 100644 --- a/spec/unit/xlsx/xform/sheet/merge-cell-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/merge-cell-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const MergeCellXform = verquire('xlsx/xform/sheet/merge-cell-xform'); diff --git a/spec/unit/xlsx/xform/sheet/outline-properties-xform.spec.js b/spec/unit/xlsx/xform/sheet/outline-properties-xform.spec.js index a2e826f4b..34c250e7b 100644 --- a/spec/unit/xlsx/xform/sheet/outline-properties-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/outline-properties-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const OutlinePropertiesXform = verquire( 'xlsx/xform/sheet/outline-properties-xform' diff --git a/spec/unit/xlsx/xform/sheet/page-breaks-xform.spec.js b/spec/unit/xlsx/xform/sheet/page-breaks-xform.spec.js index 00f16fb7d..e85e98c8d 100644 --- a/spec/unit/xlsx/xform/sheet/page-breaks-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/page-breaks-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const PageBreaksXform = verquire('xlsx/xform/sheet/page-breaks-xform'); diff --git a/spec/unit/xlsx/xform/sheet/page-margins-xform.spec.js b/spec/unit/xlsx/xform/sheet/page-margins-xform.spec.js index 867947c3d..4f560011f 100644 --- a/spec/unit/xlsx/xform/sheet/page-margins-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/page-margins-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const PageMarginsXform = verquire('xlsx/xform/sheet/page-margins-xform'); diff --git a/spec/unit/xlsx/xform/sheet/page-setup-properties-xform.spec.js b/spec/unit/xlsx/xform/sheet/page-setup-properties-xform.spec.js index 91ea3151c..ae6de07df 100644 --- a/spec/unit/xlsx/xform/sheet/page-setup-properties-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/page-setup-properties-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const PageSetupPropertiesXform = verquire( 'xlsx/xform/sheet/page-setup-properties-xform' diff --git a/spec/unit/xlsx/xform/sheet/page-setup-xform.spec.js b/spec/unit/xlsx/xform/sheet/page-setup-xform.spec.js index 32ce20520..d4e8a6a7f 100644 --- a/spec/unit/xlsx/xform/sheet/page-setup-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/page-setup-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const PageSetupXform = verquire('xlsx/xform/sheet/page-setup-xform'); diff --git a/spec/unit/xlsx/xform/sheet/print-options-xform.spec.js b/spec/unit/xlsx/xform/sheet/print-options-xform.spec.js index 238cf75d2..8f1adf7c8 100644 --- a/spec/unit/xlsx/xform/sheet/print-options-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/print-options-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const PrintOptionsXform = verquire('xlsx/xform/sheet/print-options-xform'); diff --git a/spec/unit/xlsx/xform/sheet/row-xform.spec.js b/spec/unit/xlsx/xform/sheet/row-xform.spec.js index a96f2a7fd..9b2d9cc8a 100644 --- a/spec/unit/xlsx/xform/sheet/row-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/row-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const RowXform = verquire('xlsx/xform/sheet/row-xform'); const SharedStringsXform = verquire('xlsx/xform/strings/shared-strings-xform'); diff --git a/spec/unit/xlsx/xform/sheet/sheet-format-properties-xform.spec.js b/spec/unit/xlsx/xform/sheet/sheet-format-properties-xform.spec.js index 7cbbefd92..8e120bde6 100644 --- a/spec/unit/xlsx/xform/sheet/sheet-format-properties-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/sheet-format-properties-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const SheetFormatPropertiesXform = verquire( 'xlsx/xform/sheet/sheet-format-properties-xform' diff --git a/spec/unit/xlsx/xform/sheet/sheet-properties-xform.spec.js b/spec/unit/xlsx/xform/sheet/sheet-properties-xform.spec.js index 426491b85..dda10bbfe 100644 --- a/spec/unit/xlsx/xform/sheet/sheet-properties-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/sheet-properties-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const SheetPropertiesXform = verquire( 'xlsx/xform/sheet/sheet-properties-xform' diff --git a/spec/unit/xlsx/xform/sheet/sheet-view-xform.spec.js b/spec/unit/xlsx/xform/sheet/sheet-view-xform.spec.js index 27e5a8fae..188002f4e 100644 --- a/spec/unit/xlsx/xform/sheet/sheet-view-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/sheet-view-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const SheetViewXform = verquire('xlsx/xform/sheet/sheet-view-xform'); const ListXform = verquire('xlsx/xform/list-xform'); diff --git a/spec/unit/xlsx/xform/simple/boolean-xform.spec.js b/spec/unit/xlsx/xform/simple/boolean-xform.spec.js index ced242fb3..e9d9d7a82 100644 --- a/spec/unit/xlsx/xform/simple/boolean-xform.spec.js +++ b/spec/unit/xlsx/xform/simple/boolean-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const BooleanXform = verquire('xlsx/xform/simple/boolean-xform'); diff --git a/spec/unit/xlsx/xform/simple/date-xform.spec.js b/spec/unit/xlsx/xform/simple/date-xform.spec.js index 986934702..a5c737010 100644 --- a/spec/unit/xlsx/xform/simple/date-xform.spec.js +++ b/spec/unit/xlsx/xform/simple/date-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const DateXform = verquire('xlsx/xform/simple/date-xform'); diff --git a/spec/unit/xlsx/xform/simple/float-xform.spec.js b/spec/unit/xlsx/xform/simple/float-xform.spec.js index 4cca1a3d8..e8a5c19c0 100644 --- a/spec/unit/xlsx/xform/simple/float-xform.spec.js +++ b/spec/unit/xlsx/xform/simple/float-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const FloatXform = verquire('xlsx/xform/simple/float-xform'); diff --git a/spec/unit/xlsx/xform/simple/integer-xform.spec.js b/spec/unit/xlsx/xform/simple/integer-xform.spec.js index 83d4db447..d5e920b76 100644 --- a/spec/unit/xlsx/xform/simple/integer-xform.spec.js +++ b/spec/unit/xlsx/xform/simple/integer-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const IntegerXform = verquire('xlsx/xform/simple/integer-xform'); diff --git a/spec/unit/xlsx/xform/simple/string-xform.spec.js b/spec/unit/xlsx/xform/simple/string-xform.spec.js index 2d83c64f7..a276fffdf 100644 --- a/spec/unit/xlsx/xform/simple/string-xform.spec.js +++ b/spec/unit/xlsx/xform/simple/string-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const StringXform = verquire('xlsx/xform/simple/string-xform'); diff --git a/spec/unit/xlsx/xform/strings/phonetic-text-xform.spec.js b/spec/unit/xlsx/xform/strings/phonetic-text-xform.spec.js index a30b68e35..1077d35ac 100644 --- a/spec/unit/xlsx/xform/strings/phonetic-text-xform.spec.js +++ b/spec/unit/xlsx/xform/strings/phonetic-text-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const PhoneticTextXform = verquire('xlsx/xform/strings/phonetic-text-xform'); diff --git a/spec/unit/xlsx/xform/style/alignment-xform.spec.js b/spec/unit/xlsx/xform/style/alignment-xform.spec.js index 80e68738b..12f8d04dd 100644 --- a/spec/unit/xlsx/xform/style/alignment-xform.spec.js +++ b/spec/unit/xlsx/xform/style/alignment-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const AlignmentXform = verquire('xlsx/xform/style/alignment-xform'); diff --git a/spec/unit/xlsx/xform/style/border-xform.spec.js b/spec/unit/xlsx/xform/style/border-xform.spec.js index eb2c4da05..40f8b5162 100644 --- a/spec/unit/xlsx/xform/style/border-xform.spec.js +++ b/spec/unit/xlsx/xform/style/border-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const BorderXform = verquire('xlsx/xform/style/border-xform'); diff --git a/spec/unit/xlsx/xform/style/color-xform.spec.js b/spec/unit/xlsx/xform/style/color-xform.spec.js index 4dbde6289..445781d50 100644 --- a/spec/unit/xlsx/xform/style/color-xform.spec.js +++ b/spec/unit/xlsx/xform/style/color-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const ColorXform = verquire('xlsx/xform/style/color-xform'); diff --git a/spec/unit/xlsx/xform/style/fill-xform.spec.js b/spec/unit/xlsx/xform/style/fill-xform.spec.js index bcf7a2773..ddc92bb10 100644 --- a/spec/unit/xlsx/xform/style/fill-xform.spec.js +++ b/spec/unit/xlsx/xform/style/fill-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const FillXform = verquire('xlsx/xform/style/fill-xform'); diff --git a/spec/unit/xlsx/xform/style/font-xform.spec.js b/spec/unit/xlsx/xform/style/font-xform.spec.js index bb8dfa04f..dc6be0d6c 100644 --- a/spec/unit/xlsx/xform/style/font-xform.spec.js +++ b/spec/unit/xlsx/xform/style/font-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const FontXform = verquire('xlsx/xform/style/font-xform'); diff --git a/spec/unit/xlsx/xform/style/numfmt-xform.spec.js b/spec/unit/xlsx/xform/style/numfmt-xform.spec.js index 0964ffa36..cd2856918 100644 --- a/spec/unit/xlsx/xform/style/numfmt-xform.spec.js +++ b/spec/unit/xlsx/xform/style/numfmt-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const NumFmtXform = verquire('xlsx/xform/style/numfmt-xform'); diff --git a/spec/unit/xlsx/xform/style/styles-xform.spec.js b/spec/unit/xlsx/xform/style/styles-xform.spec.js index 5c5925a27..d8e97cc45 100644 --- a/spec/unit/xlsx/xform/style/styles-xform.spec.js +++ b/spec/unit/xlsx/xform/style/styles-xform.spec.js @@ -1,6 +1,6 @@ const fs = require('fs'); -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const StylesXform = verquire('xlsx/xform/style/styles-xform'); const XmlStream = verquire('utils/xml-stream'); diff --git a/spec/unit/xlsx/xform/style/underline-xform.spec.js b/spec/unit/xlsx/xform/style/underline-xform.spec.js index 944fc571b..30e8afa15 100644 --- a/spec/unit/xlsx/xform/style/underline-xform.spec.js +++ b/spec/unit/xlsx/xform/style/underline-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const UnderlineXform = verquire('xlsx/xform/style/underline-xform'); diff --git a/spec/unit/xlsx/xform/table/auto-filter-xform.spec.js b/spec/unit/xlsx/xform/table/auto-filter-xform.spec.js index 502fd86d6..77de89999 100644 --- a/spec/unit/xlsx/xform/table/auto-filter-xform.spec.js +++ b/spec/unit/xlsx/xform/table/auto-filter-xform.spec.js @@ -1,42 +1,42 @@ -const testXformHelper = require('./../test-xform-helper'); - -const AutoFilterXform = verquire('xlsx/xform/table/auto-filter-xform'); - -const expectations = [ - { - title: 'showing filter', - create() { - return new AutoFilterXform(); - }, - initialModel: { - autoFilterRef: 'A1:B10', - columns: [ - {filterButton: false}, - {filterButton: true}, - {filterButton: true}, - ], - }, - preparedModel: { - autoFilterRef: 'A1:B10', - columns: [ - {colId: '0', filterButton: false}, - {colId: '1', filterButton: true}, - {colId: '2', filterButton: true}, - ], - }, - xml: - '' + - '' + - '' + - '' + - '', - get parsedModel() { - return this.initialModel; - }, - tests: ['prepare', 'render', 'renderIn', 'parse'], - }, -]; - -describe('AutoFilterXform', () => { - testXformHelper(expectations); -}); +const testXformHelper = require('../test-xform-helper'); + +const AutoFilterXform = verquire('xlsx/xform/table/auto-filter-xform'); + +const expectations = [ + { + title: 'showing filter', + create() { + return new AutoFilterXform(); + }, + initialModel: { + autoFilterRef: 'A1:B10', + columns: [ + {filterButton: false}, + {filterButton: true}, + {filterButton: true}, + ], + }, + preparedModel: { + autoFilterRef: 'A1:B10', + columns: [ + {colId: '0', filterButton: false}, + {colId: '1', filterButton: true}, + {colId: '2', filterButton: true}, + ], + }, + xml: + '' + + '' + + '' + + '' + + '', + get parsedModel() { + return this.initialModel; + }, + tests: ['prepare', 'render', 'renderIn', 'parse'], + }, +]; + +describe('AutoFilterXform', () => { + testXformHelper(expectations); +}); diff --git a/spec/unit/xlsx/xform/table/filter-column-xform.spec.js b/spec/unit/xlsx/xform/table/filter-column-xform.spec.js index 669cf084f..2d9900c17 100644 --- a/spec/unit/xlsx/xform/table/filter-column-xform.spec.js +++ b/spec/unit/xlsx/xform/table/filter-column-xform.spec.js @@ -1,38 +1,38 @@ -const testXformHelper = require('./../test-xform-helper'); - -const FilterColumnXform = verquire('xlsx/xform/table/filter-column-xform'); - -const expectations = [ - { - title: 'showing filter', - create() { - return new FilterColumnXform(); - }, - initialModel: {filterButton: true}, - preparedModel: {colId: '0', filterButton: true}, - xml: '', - get parsedModel() { - return this.initialModel; - }, - tests: ['prepare', 'render', 'renderIn', 'parse'], - options: {index: 0}, - }, - { - title: 'hidden filter', - create() { - return new FilterColumnXform(); - }, - initialModel: {filterButton: false}, - preparedModel: {colId: '1', filterButton: false}, - xml: '', - get parsedModel() { - return this.initialModel; - }, - tests: ['prepare', 'render', 'renderIn', 'parse'], - options: {index: 1}, - }, -]; - -describe('FilterColumnXform', () => { - testXformHelper(expectations); -}); +const testXformHelper = require('../test-xform-helper'); + +const FilterColumnXform = verquire('xlsx/xform/table/filter-column-xform'); + +const expectations = [ + { + title: 'showing filter', + create() { + return new FilterColumnXform(); + }, + initialModel: {filterButton: true}, + preparedModel: {colId: '0', filterButton: true}, + xml: '', + get parsedModel() { + return this.initialModel; + }, + tests: ['prepare', 'render', 'renderIn', 'parse'], + options: {index: 0}, + }, + { + title: 'hidden filter', + create() { + return new FilterColumnXform(); + }, + initialModel: {filterButton: false}, + preparedModel: {colId: '1', filterButton: false}, + xml: '', + get parsedModel() { + return this.initialModel; + }, + tests: ['prepare', 'render', 'renderIn', 'parse'], + options: {index: 1}, + }, +]; + +describe('FilterColumnXform', () => { + testXformHelper(expectations); +}); diff --git a/spec/unit/xlsx/xform/table/table-column-xform.spec.js b/spec/unit/xlsx/xform/table/table-column-xform.spec.js index b648299cc..109486e96 100644 --- a/spec/unit/xlsx/xform/table/table-column-xform.spec.js +++ b/spec/unit/xlsx/xform/table/table-column-xform.spec.js @@ -1,30 +1,30 @@ -const testXformHelper = require('./../test-xform-helper'); - -const TableColumnXform = verquire('xlsx/xform/table/table-column-xform'); - -const expectations = [ - { - title: 'label', - create() { - return new TableColumnXform(); - }, - preparedModel: {id: 1, name: 'Foo', totalsRowLabel: 'Bar'}, - xml: '', - parsedModel: {name: 'Foo', totalsRowLabel: 'Bar'}, - tests: ['render', 'renderIn', 'parse'], - }, - { - title: 'function', - create() { - return new TableColumnXform(); - }, - preparedModel: {id: 1, name: 'Foo', totalsRowFunction: 'Baz'}, - xml: '', - parsedModel: {name: 'Foo', totalsRowFunction: 'Baz'}, - tests: ['render', 'renderIn', 'parse'], - }, -]; - -describe('TableColumnXform', () => { - testXformHelper(expectations); -}); +const testXformHelper = require('../test-xform-helper'); + +const TableColumnXform = verquire('xlsx/xform/table/table-column-xform'); + +const expectations = [ + { + title: 'label', + create() { + return new TableColumnXform(); + }, + preparedModel: {id: 1, name: 'Foo', totalsRowLabel: 'Bar'}, + xml: '', + parsedModel: {name: 'Foo', totalsRowLabel: 'Bar'}, + tests: ['render', 'renderIn', 'parse'], + }, + { + title: 'function', + create() { + return new TableColumnXform(); + }, + preparedModel: {id: 1, name: 'Foo', totalsRowFunction: 'Baz'}, + xml: '', + parsedModel: {name: 'Foo', totalsRowFunction: 'Baz'}, + tests: ['render', 'renderIn', 'parse'], + }, +]; + +describe('TableColumnXform', () => { + testXformHelper(expectations); +}); diff --git a/spec/unit/xlsx/xform/table/table-style-info-xform.spec.js b/spec/unit/xlsx/xform/table/table-style-info-xform.spec.js index b0cc2aa74..5ce442bae 100644 --- a/spec/unit/xlsx/xform/table/table-style-info-xform.spec.js +++ b/spec/unit/xlsx/xform/table/table-style-info-xform.spec.js @@ -1,48 +1,48 @@ -const testXformHelper = require('./../test-xform-helper'); - -const TableStyleInfoXform = verquire('xlsx/xform/table/table-style-info-xform'); - -const expectations = [ - { - title: 'row', - create() { - return new TableStyleInfoXform(); - }, - preparedModel: { - theme: 'TableStyle', - showFirstColumn: false, - showLastColumn: false, - showRowStripes: true, - showColumnStripes: false, - }, - xml: - '', - get parsedModel() { - return this.preparedModel; - }, - tests: ['render', 'renderIn', 'parse'], - }, - { - title: 'col', - create() { - return new TableStyleInfoXform(); - }, - preparedModel: { - theme: null, - showFirstColumn: true, - showLastColumn: true, - showRowStripes: false, - showColumnStripes: true, - }, - xml: - '', - get parsedModel() { - return this.preparedModel; - }, - tests: ['render', 'renderIn', 'parse'], - }, -]; - -describe('TableStyleInfoXform', () => { - testXformHelper(expectations); -}); +const testXformHelper = require('../test-xform-helper'); + +const TableStyleInfoXform = verquire('xlsx/xform/table/table-style-info-xform'); + +const expectations = [ + { + title: 'row', + create() { + return new TableStyleInfoXform(); + }, + preparedModel: { + theme: 'TableStyle', + showFirstColumn: false, + showLastColumn: false, + showRowStripes: true, + showColumnStripes: false, + }, + xml: + '', + get parsedModel() { + return this.preparedModel; + }, + tests: ['render', 'renderIn', 'parse'], + }, + { + title: 'col', + create() { + return new TableStyleInfoXform(); + }, + preparedModel: { + theme: null, + showFirstColumn: true, + showLastColumn: true, + showRowStripes: false, + showColumnStripes: true, + }, + xml: + '', + get parsedModel() { + return this.preparedModel; + }, + tests: ['render', 'renderIn', 'parse'], + }, +]; + +describe('TableStyleInfoXform', () => { + testXformHelper(expectations); +}); diff --git a/spec/unit/xlsx/xform/table/table-xform.spec.js b/spec/unit/xlsx/xform/table/table-xform.spec.js index 71c6ef48e..098a9bb94 100644 --- a/spec/unit/xlsx/xform/table/table-xform.spec.js +++ b/spec/unit/xlsx/xform/table/table-xform.spec.js @@ -1,23 +1,23 @@ -const fs = require('fs'); - -const testXformHelper = require('./../test-xform-helper'); - -const TableXform = verquire('xlsx/xform/table/table-xform'); - -const expectations = [ - { - title: 'showing filter', - create() { - return new TableXform(); - }, - initialModel: null, - preparedModel: require('./data/table.1.1'), - xml: fs.readFileSync(`${__dirname}/data/table.1.2.xml`).toString(), - parsedModel: require('./data/table.1.3'), - tests: ['render', 'renderIn', 'parse'], - }, -]; - -describe('TableXform', () => { - testXformHelper(expectations); -}); +const fs = require('fs'); + +const testXformHelper = require('../test-xform-helper'); + +const TableXform = verquire('xlsx/xform/table/table-xform'); + +const expectations = [ + { + title: 'showing filter', + create() { + return new TableXform(); + }, + initialModel: null, + preparedModel: require('./data/table.1.1'), + xml: fs.readFileSync(`${__dirname}/data/table.1.2.xml`).toString(), + parsedModel: require('./data/table.1.3'), + tests: ['render', 'renderIn', 'parse'], + }, +]; + +describe('TableXform', () => { + testXformHelper(expectations); +}); diff --git a/spec/unit/xlsx/xform/test-xform-helper.js b/spec/unit/xlsx/xform/test-xform-helper.js index 8cadea8a4..05312e491 100644 --- a/spec/unit/xlsx/xform/test-xform-helper.js +++ b/spec/unit/xlsx/xform/test-xform-helper.js @@ -23,7 +23,7 @@ function getExpectation(expectation, name) { const its = { prepare(expectation) { it('Prepare Model', () => - new Promise(resolve => { + new Promise((resolve) => { const model = getExpectation(expectation, 'initialModel'); const result = getExpectation(expectation, 'preparedModel'); @@ -36,7 +36,7 @@ const its = { render(expectation) { it('Render to XML', () => - new Promise(resolve => { + new Promise((resolve) => { const model = getExpectation(expectation, 'preparedModel'); const result = getExpectation(expectation, 'xml'); @@ -54,7 +54,7 @@ const its = { 'prepare-render': function(expectation) { // when implementation details get in the way of testing the prepared result it('Prepare and Render to XML', () => - new Promise(resolve => { + new Promise((resolve) => { const model = getExpectation(expectation, 'initialModel'); const result = getExpectation(expectation, 'xml'); @@ -71,7 +71,7 @@ const its = { renderIn(expectation) { it('Render in Composite to XML ', () => - new Promise(resolve => { + new Promise((resolve) => { const model = { pre: true, child: getExpectation(expectation, 'preparedModel'), @@ -136,7 +136,7 @@ const its = { stream.end(); xform .parse(parseSax(stream)) - .then(model => { + .then((model) => { // console.log('parsed Model', JSON.stringify(model)); // console.log('expected Model', JSON.stringify(result)); @@ -165,7 +165,7 @@ const its = { stream.end(); xform .parse(parseSax(stream)) - .then(model => { + .then((model) => { // eliminate the undefined const clone = cloneDeep(model, false); @@ -180,7 +180,7 @@ const its = { reconcile(expectation) { it('Reconcile Model', () => - new Promise(resolve => { + new Promise((resolve) => { const model = getExpectation(expectation, 'parsedModel'); const result = getExpectation(expectation, 'reconciledModel'); @@ -197,10 +197,10 @@ const its = { }; function testXform(expectations) { - each(expectations, expectation => { + each(expectations, (expectation) => { const tests = getExpectation(expectation, 'tests'); describe(expectation.title, () => { - each(tests, test => { + each(tests, (test) => { its[test](expectation); }); }); diff --git a/spec/utils/index.js b/spec/utils/index.js index 9cf3cb13b..5fa9177ea 100644 --- a/spec/utils/index.js +++ b/spec/utils/index.js @@ -67,7 +67,7 @@ module.exports = { {x: 1, y: 2, width: 10000, height: 20000, firstSheet: 0, activeTab: 0}, ]; - sheets.forEach(sheet => { + sheets.forEach((sheet) => { const testSheet = _.get(testSheets, sheet); testSheet.addSheet(workbook, options); }); @@ -95,7 +95,7 @@ module.exports = { ]); } - sheets.forEach(sheet => { + sheets.forEach((sheet) => { const testSheet = _.get(testSheets, sheet); testSheet.checkSheet(workbook, options); }); diff --git a/spec/utils/test-conditional-formatting-sheet.js b/spec/utils/test-conditional-formatting-sheet.js index 2dea87319..62e655957 100644 --- a/spec/utils/test-conditional-formatting-sheet.js +++ b/spec/utils/test-conditional-formatting-sheet.js @@ -8,7 +8,7 @@ const self = { addSheet(wb) { const ws = wb.addWorksheet('conditional-formatting'); const {types} = self.conditionalFormattings; - types.forEach(type => { + types.forEach((type) => { const conditionalFormatting = self.getConditionalFormatting(type); if (conditionalFormatting) { ws.addConditionalFormatting(conditionalFormatting); @@ -20,7 +20,7 @@ const self = { const ws = wb.getWorksheet('conditional-formatting'); expect(ws).to.not.be.undefined(); expect(ws.conditionalFormattings).to.not.be.undefined(); - (ws.conditionalFormattings && ws.conditionalFormattings).forEach(item => { + (ws.conditionalFormattings && ws.conditionalFormattings).forEach((item) => { const type = item.rules && item.rules[0].type; const conditionalFormatting = self.getConditionalFormatting(type); expect(item).to.have.property('ref'); diff --git a/spec/utils/test-data-validation-sheet.js b/spec/utils/test-data-validation-sheet.js index 4481ae9ea..88847d22c 100644 --- a/spec/utils/test-data-validation-sheet.js +++ b/spec/utils/test-data-validation-sheet.js @@ -85,7 +85,7 @@ const self = { }; // two rows of the same validation to test dataValidation optimisation - ['A22', 'A23'].forEach(address => { + ['A22', 'A23'].forEach((address) => { ws.getCell(address).value = tools.concatenateFormula('Five Numbers'); }); [ @@ -99,7 +99,7 @@ const self = { 'D23', 'E23', 'F23', - ].forEach(address => { + ].forEach((address) => { ws.getCell(address).dataValidation = JSON.parse( JSON.stringify(self.dataValidations.shared) ); @@ -159,7 +159,7 @@ const self = { 'D23', 'E23', 'F23', - ].forEach(address => { + ].forEach((address) => { expect(ws.getCell(address).dataValidation).to.deep.equal( self.dataValidations.shared ); diff --git a/spec/utils/test-spliced-sheet.js b/spec/utils/test-spliced-sheet.js index f08ee7c72..02fd4b2c5 100644 --- a/spec/utils/test-spliced-sheet.js +++ b/spec/utils/test-spliced-sheet.js @@ -335,8 +335,8 @@ module.exports = { wsSquare.addRow(['3,1', '3,2', '3,3', '3,4']); wsSquare.addRow(['4,1', '4,2', '4,3', '4,4']); - ['A', 'B', 'C', 'D'].forEach(col => { - [1, 2, 3, 4].forEach(row => { + ['A', 'B', 'C', 'D'].forEach((col) => { + [1, 2, 3, 4].forEach((row) => { wsSquare.getCell(col + row).name = 'square'; }); }); @@ -349,8 +349,8 @@ module.exports = { wsSingles.getCell('D1').value = '1,4'; wsSingles.getCell('D4').value = '4,4'; - ['A', 'D'].forEach(col => { - [1, 4].forEach(row => { + ['A', 'D'].forEach((col) => { + [1, 4].forEach((row) => { wsSingles.getCell(col + row).name = `single-${col}${row}`; }); }); @@ -377,8 +377,8 @@ module.exports = { '4,4', ]); - ['A', 'B', 'C', 'D'].forEach(col => { - [1, 2, 3].forEach(row => { + ['A', 'B', 'C', 'D'].forEach((col) => { + [1, 2, 3].forEach((row) => { if (row === 3) { expect(wsSquare.getCell(col + row).name).to.be.undefined(); } else { @@ -407,8 +407,8 @@ module.exports = { wsSquare.addRow(['3,1', '3,2', '3,3', '3,4']); wsSquare.addRow(['4,1', '4,2', '4,3', '4,4']); - ['A', 'B', 'C', 'D'].forEach(col => { - [1, 2, 3, 4].forEach(row => { + ['A', 'B', 'C', 'D'].forEach((col) => { + [1, 2, 3, 4].forEach((row) => { wsSquare.getCell(col + row).name = 'square'; }); }); @@ -421,8 +421,8 @@ module.exports = { wsSingles.getCell('D1').value = '1,4'; wsSingles.getCell('D4').value = '4,4'; - ['A', 'D'].forEach(col => { - [1, 4].forEach(row => { + ['A', 'D'].forEach((col) => { + [1, 4].forEach((row) => { wsSingles.getCell(col + row).name = `single-${col}${row}`; }); }); @@ -470,8 +470,8 @@ module.exports = { '4,4', ]); - ['A', 'B', 'C', 'D'].forEach(col => { - [1, 2, 3, 4, 5].forEach(row => { + ['A', 'B', 'C', 'D'].forEach((col) => { + [1, 2, 3, 4, 5].forEach((row) => { if (row === 3) { expect(wsSquare.getCell(col + row).name).to.be.undefined(); } else { @@ -506,8 +506,8 @@ module.exports = { wsSquare.addRow(['3,1', '3,2', '3,3', '3,4']); wsSquare.addRow(['4,1', '4,2', '4,3', '4,4']); - ['A', 'B', 'C', 'D'].forEach(col => { - [1, 2, 3, 4].forEach(row => { + ['A', 'B', 'C', 'D'].forEach((col) => { + [1, 2, 3, 4].forEach((row) => { wsSquare.getCell(col + row).name = 'square'; }); }); @@ -520,8 +520,8 @@ module.exports = { wsSingles.getCell('D1').value = '1,4'; wsSingles.getCell('D4').value = '4,4'; - ['A', 'D'].forEach(col => { - [1, 4].forEach(row => { + ['A', 'D'].forEach((col) => { + [1, 4].forEach((row) => { wsSingles.getCell(col + row).name = `single-${col}${row}`; }); }); @@ -562,8 +562,8 @@ module.exports = { '4,4', ]); - ['A', 'B', 'C', 'D'].forEach(col => { - [1, 2, 3, 4].forEach(row => { + ['A', 'B', 'C', 'D'].forEach((col) => { + [1, 2, 3, 4].forEach((row) => { if (row === 2) { expect(wsSquare.getCell(col + row).name).to.be.undefined(); } else { @@ -1028,8 +1028,8 @@ module.exports = { wsSquare.addRow(['3,1', '3,2', '3,3', '3,4']); wsSquare.addRow(['4,1', '4,2', '4,3', '4,4']); - ['A', 'B', 'C', 'D'].forEach(col => { - [1, 2, 3, 4].forEach(row => { + ['A', 'B', 'C', 'D'].forEach((col) => { + [1, 2, 3, 4].forEach((row) => { wsSquare.getCell(col + row).name = 'square'; }); }); @@ -1042,8 +1042,8 @@ module.exports = { wsSingles.getCell('D1').value = '1,4'; wsSingles.getCell('D4').value = '4,4'; - ['A', 'D'].forEach(col => { - [1, 4].forEach(row => { + ['A', 'D'].forEach((col) => { + [1, 4].forEach((row) => { wsSingles.getCell(col + row).name = `single-${col}${row}`; }); }); @@ -1060,8 +1060,8 @@ module.exports = { expect(wsSquare.getRow(3).values).to.deep.equal([, '3,1', '3,4']); expect(wsSquare.getRow(4).values).to.deep.equal([, '4,1', '4,4']); - ['A', 'B', 'C', 'D'].forEach(col => { - [1, 2, 3].forEach(row => { + ['A', 'B', 'C', 'D'].forEach((col) => { + [1, 2, 3].forEach((row) => { if (['C', 'D'].includes(col)) { expect(wsSquare.getCell(col + row).name).to.be.undefined(); } else { @@ -1090,8 +1090,8 @@ module.exports = { wsSquare.addRow(['3,1', '3,2', '3,3', '3,4']); wsSquare.addRow(['4,1', '4,2', '4,3', '4,4']); - ['A', 'B', 'C', 'D'].forEach(col => { - [1, 2, 3, 4].forEach(row => { + ['A', 'B', 'C', 'D'].forEach((col) => { + [1, 2, 3, 4].forEach((row) => { wsSquare.getCell(col + row).name = 'square'; }); }); @@ -1104,8 +1104,8 @@ module.exports = { wsSingles.getCell('D1').value = '1,4'; wsSingles.getCell('D4').value = '4,4'; - ['A', 'D'].forEach(col => { - [1, 4].forEach(row => { + ['A', 'D'].forEach((col) => { + [1, 4].forEach((row) => { wsSingles.getCell(col + row).name = `single-${col}${row}`; }); }); @@ -1150,8 +1150,8 @@ module.exports = { '4,4', ]); - ['A', 'B', 'C', 'D', 'E'].forEach(col => { - [1, 2, 3, 4].forEach(row => { + ['A', 'B', 'C', 'D', 'E'].forEach((col) => { + [1, 2, 3, 4].forEach((row) => { if (col === 'C') { expect(wsSquare.getCell(col + row).name).to.be.undefined(); } else { @@ -1194,8 +1194,8 @@ module.exports = { wsSquare.addRow(['3,1', '3,2', '3,3', '3,4']); wsSquare.addRow(['4,1', '4,2', '4,3', '4,4']); - ['A', 'B', 'C', 'D'].forEach(col => { - [1, 2, 3, 4].forEach(row => { + ['A', 'B', 'C', 'D'].forEach((col) => { + [1, 2, 3, 4].forEach((row) => { wsSquare.getCell(col + row).name = 'square'; }); }); @@ -1208,8 +1208,8 @@ module.exports = { wsSingles.getCell('D1').value = '1,4'; wsSingles.getCell('D4').value = '4,4'; - ['A', 'D'].forEach(col => { - [1, 4].forEach(row => { + ['A', 'D'].forEach((col) => { + [1, 4].forEach((row) => { wsSingles.getCell(col + row).name = `single-${col}${row}`; }); }); @@ -1250,8 +1250,8 @@ module.exports = { '4,4', ]); - ['A', 'B', 'C', 'D'].forEach(col => { - [1, 2, 3, 4].forEach(row => { + ['A', 'B', 'C', 'D'].forEach((col) => { + [1, 2, 3, 4].forEach((row) => { if (col === 'B') { expect(wsSquare.getCell(col + row).name).to.be.undefined(); } else { diff --git a/spec/utils/test-values-sheet.js b/spec/utils/test-values-sheet.js index 2bbc45be3..34ef805fa 100644 --- a/spec/utils/test-values-sheet.js +++ b/spec/utils/test-values-sheet.js @@ -358,7 +358,7 @@ const self = { formula: 'A9', result: 1, }); - ['B11', 'C11', 'D11', 'E11'].forEach(address => { + ['B11', 'C11', 'D11', 'E11'].forEach((address) => { expect(ws.getCell(address).value).to.equal(1); }); } diff --git a/spec/utils/test-workbook-reader.js b/spec/utils/test-workbook-reader.js index 4994701e6..111c0accf 100644 --- a/spec/utils/test-workbook-reader.js +++ b/spec/utils/test-workbook-reader.js @@ -31,10 +31,10 @@ module.exports = { return new Promise((resolve, reject) => { let rowCount = 0; - wb.on('worksheet', ws => { + wb.on('worksheet', (ws) => { // Sheet name stored in workbook. Not guaranteed here // expect(ws.name).to.equal('blort'); - ws.on('row', row => { + ws.on('row', (row) => { rowCount++; try { switch (row.number) { diff --git a/spec/utils/tools.js b/spec/utils/tools.js index 5ac472fd3..afd67881c 100644 --- a/spec/utils/tools.js +++ b/spec/utils/tools.js @@ -23,7 +23,7 @@ const tools = { }, concatenateFormula(...args) { - const values = args.map(value => `"${value}"`); + const values = args.map((value) => `"${value}"`); return { formula: `CONCATENATE(${values.join(',')})`, }; diff --git a/test/test-a1.js b/test/test-a1.js index edb4ca7c4..e910ace27 100644 --- a/test/test-a1.js +++ b/test/test-a1.js @@ -16,6 +16,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); diff --git a/test/test-cf.js b/test/test-cf.js index a1e016161..2c1ae37f9 100644 --- a/test/test-cf.js +++ b/test/test-cf.js @@ -654,6 +654,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); diff --git a/test/test-chart.js b/test/test-chart.js index 43201e6ea..ef81025ab 100644 --- a/test/test-chart.js +++ b/test/test-chart.js @@ -49,6 +49,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); diff --git a/test/test-colour-cell.js b/test/test-colour-cell.js index ce308ebde..a2f9f5242 100644 --- a/test/test-colour-cell.js +++ b/test/test-colour-cell.js @@ -56,6 +56,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); diff --git a/test/test-comment-new.js b/test/test-comment-new.js index 840439468..8e979c41e 100644 --- a/test/test-comment-new.js +++ b/test/test-comment-new.js @@ -102,6 +102,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); diff --git a/test/test-comment-stream-writer.js b/test/test-comment-stream-writer.js index 0693a9323..30145b0ea 100644 --- a/test/test-comment-stream-writer.js +++ b/test/test-comment-stream-writer.js @@ -101,6 +101,6 @@ wb.commit() console.log('Done.'); console.log('Time taken:', micros); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); diff --git a/test/test-comments.js b/test/test-comments.js index 481bd5991..5ceb64c3a 100644 --- a/test/test-comments.js +++ b/test/test-comments.js @@ -4,7 +4,7 @@ const wb = new Excel.Workbook(); wb.xlsx .readFile(require.resolve('./data/comments.xlsx')) .then(() => { - wb.worksheets.forEach(sheet => { + wb.worksheets.forEach((sheet) => { console.info(sheet.getCell('A1').model); sheet.getCell('B2').value = 'Zeb'; sheet.getCell('B2').comment = { diff --git a/test/test-copy.js b/test/test-copy.js index c78399348..6b1706756 100644 --- a/test/test-copy.js +++ b/test/test-copy.js @@ -19,6 +19,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch(error => { + .catch((error) => { console.error('Error', error.stack); }); diff --git a/test/test-default-height.js b/test/test-default-height.js index 8c02cd89a..b968811d0 100644 --- a/test/test-default-height.js +++ b/test/test-default-height.js @@ -24,6 +24,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch(error => { + .catch((error) => { console.error(error.stack); }); diff --git a/test/test-formula.js b/test/test-formula.js index a0abf43c1..bf8a6741a 100644 --- a/test/test-formula.js +++ b/test/test-formula.js @@ -30,7 +30,7 @@ ws.getCell('F4').value = {sharedFormula: 'F1', result: 4}; // function fill ws.getCell('H1').value = 1; -ws.fillFormula('H2:H20', 'H1+1', row => row); +ws.fillFormula('H2:H20', 'H1+1', (row) => row); // array formula @@ -51,6 +51,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); diff --git a/test/test-header-footer.js b/test/test-header-footer.js index d616f9afa..0cfb1caf1 100644 --- a/test/test-header-footer.js +++ b/test/test-header-footer.js @@ -19,6 +19,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); diff --git a/test/test-hyperlink.js b/test/test-hyperlink.js index 704bcf18a..059c919b5 100644 --- a/test/test-hyperlink.js +++ b/test/test-hyperlink.js @@ -21,6 +21,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); diff --git a/test/test-image-one-cell-anchor.js b/test/test-image-one-cell-anchor.js index 6c21a2aad..c4d65896e 100644 --- a/test/test-image-one-cell-anchor.js +++ b/test/test-image-one-cell-anchor.js @@ -37,6 +37,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch(error => { + .catch((error) => { console.error(error.stack); }); diff --git a/test/test-image-oneCell.js b/test/test-image-oneCell.js index c7ccc9243..551befae3 100644 --- a/test/test-image-oneCell.js +++ b/test/test-image-oneCell.js @@ -28,6 +28,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch(error => { + .catch((error) => { console.error(error.stack); }); diff --git a/test/test-image-out.js b/test/test-image-out.js index 4333ee76a..814e966fa 100644 --- a/test/test-image-out.js +++ b/test/test-image-out.js @@ -37,6 +37,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch(error => { + .catch((error) => { console.error(error.stack); }); diff --git a/test/test-image-stream-writer.js b/test/test-image-stream-writer.js index 5d0d3c093..01e53e2a2 100644 --- a/test/test-image-stream-writer.js +++ b/test/test-image-stream-writer.js @@ -23,6 +23,6 @@ wb.commit() console.log('Done.'); console.log('Time taken:', micros); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); diff --git a/test/test-jszip.js b/test/test-jszip.js index 5d5b70ece..47fef58c9 100644 --- a/test/test-jszip.js +++ b/test/test-jszip.js @@ -10,11 +10,11 @@ const jsZip = new JSZip(); fsp .readFileAsync(filename) - .then(data => { + .then((data) => { console.log('data', data); return jsZip.loadAsync(data); }) - .then(zip => { + .then((zip) => { zip.forEach((path, entry) => { if (!entry.dir) { // console.log(path, entry) diff --git a/test/test-merge-align.js b/test/test-merge-align.js index 743867ca4..fd3432461 100644 --- a/test/test-merge-align.js +++ b/test/test-merge-align.js @@ -24,6 +24,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); diff --git a/test/test-newline.js b/test/test-newline.js index 0e022f01f..f124ecd40 100644 --- a/test/test-newline.js +++ b/test/test-newline.js @@ -23,6 +23,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); diff --git a/test/test-protection-spinCount.js b/test/test-protection-spinCount.js index 39f84278a..de378d117 100644 --- a/test/test-protection-spinCount.js +++ b/test/test-protection-spinCount.js @@ -51,6 +51,6 @@ async function save() { } } -save().catch(error => { +save().catch((error) => { console.log(error.message); }); diff --git a/test/test-protection.js b/test/test-protection.js index 51ebd5d26..f1500883e 100644 --- a/test/test-protection.js +++ b/test/test-protection.js @@ -27,6 +27,6 @@ async function save() { console.log('Time taken:', stopwatch.microseconds); } -save().catch(error => { +save().catch((error) => { console.log(error.message); }); diff --git a/test/test-table.js b/test/test-table.js index f0401552d..07bb6abd3 100644 --- a/test/test-table.js +++ b/test/test-table.js @@ -66,6 +66,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); diff --git a/test/testArray.js b/test/testArray.js index 148974957..16891e826 100644 --- a/test/testArray.js +++ b/test/testArray.js @@ -8,6 +8,6 @@ a[1] = 'one'; a[5] = 'five'; a[0] = 'zero'; -_.each(a, i => { +_.each(a, (i) => { console.log(i); }); diff --git a/test/testBigBookIn.js b/test/testBigBookIn.js index 35dd68f94..aba029ae1 100644 --- a/test/testBigBookIn.js +++ b/test/testBigBookIn.js @@ -89,15 +89,15 @@ if (useStream) { console.log('reached end of stream'); }); wb.on('finished', report); - wb.on('worksheet', worksheet => { + wb.on('worksheet', (worksheet) => { worksheet.on('row', checkRow); }); - wb.on('hyperlinks', hyperlinks => { + wb.on('hyperlinks', (hyperlinks) => { hyperlinks.on('hyperlink', () => { hyperlinkCount++; }); }); - wb.on('entry', entry => { + wb.on('entry', (entry) => { console.log(JSON.stringify(entry)); }); switch (options.plan) { diff --git a/test/testBigBookOut.js b/test/testBigBookOut.js index ed9a4b29c..4a395f54c 100644 --- a/test/testBigBookOut.js +++ b/test/testBigBookOut.js @@ -134,7 +134,7 @@ function allDone() { console.log(`Sums: ${colCount}`); console.log(`Time: ${stopwatch}`); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); } diff --git a/test/testBookFont.js b/test/testBookFont.js index 79e9e9332..4df3499c7 100644 --- a/test/testBookFont.js +++ b/test/testBookFont.js @@ -6,14 +6,14 @@ const workbook = new Workbook(); workbook.xlsx .readFile(filename) .then(() => { - workbook.eachSheet(worksheet => { + workbook.eachSheet((worksheet) => { console.log( `Sheet ${worksheet.id} - ${worksheet.name}, Dims=${JSON.stringify( worksheet.dimensions )}` ); - worksheet.eachRow(row => { - row.eachCell(cell => { + worksheet.eachRow((row) => { + row.eachCell((cell) => { if (cell.font.strike) { console.log(`Strikethrough: ${cell.value}`); } @@ -21,6 +21,6 @@ workbook.xlsx }); }); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); diff --git a/test/testBookOut.js b/test/testBookOut.js index 74b3f0241..4c557596c 100644 --- a/test/testBookOut.js +++ b/test/testBookOut.js @@ -358,6 +358,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); diff --git a/test/testBookOutS.js b/test/testBookOutS.js index 2f323ab3e..49e862459 100644 --- a/test/testBookOutS.js +++ b/test/testBookOutS.js @@ -289,6 +289,6 @@ wb.commit() .then(() => { console.log('Done.'); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); diff --git a/test/testBookRead.js b/test/testBookRead.js index 492091474..dd23afefe 100644 --- a/test/testBookRead.js +++ b/test/testBookRead.js @@ -6,7 +6,7 @@ const workbook = new Workbook(); workbook.xlsx .readFile(filename) .then(() => { - workbook.eachSheet(worksheet => { + workbook.eachSheet((worksheet) => { console.log( `Sheet ${worksheet.id} - ${worksheet.name}, Dims=${JSON.stringify( worksheet.dimensions @@ -14,6 +14,6 @@ workbook.xlsx ); }); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); diff --git a/test/testCsvOut.js b/test/testCsvOut.js index 2be90dc98..eb24f43a6 100644 --- a/test/testCsvOut.js +++ b/test/testCsvOut.js @@ -59,6 +59,6 @@ wb.csv .then(() => { console.log('Done.'); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); diff --git a/test/testImageIn.js b/test/testImageIn.js index da15ccdf0..367078ebb 100644 --- a/test/testImageIn.js +++ b/test/testImageIn.js @@ -19,6 +19,6 @@ wb.xlsx const {image} = ws.background; console.log('Media', image.name, image.type, image.buffer.length); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); diff --git a/test/testMergedBorder.js b/test/testMergedBorder.js index 634cca36f..9998d4a8b 100644 --- a/test/testMergedBorder.js +++ b/test/testMergedBorder.js @@ -42,6 +42,6 @@ wb.xlsx .then(() => { console.log('Done.'); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); diff --git a/test/testMultiplePrintAreaOut.js b/test/testMultiplePrintAreaOut.js index b6728f051..0fa720cfc 100644 --- a/test/testMultiplePrintAreaOut.js +++ b/test/testMultiplePrintAreaOut.js @@ -35,6 +35,6 @@ wb.xlsx .then(() => { console.log('Done.'); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); diff --git a/test/testPerformance.js b/test/testPerformance.js index eac5b2436..9b41cc2e6 100644 --- a/test/testPerformance.js +++ b/test/testPerformance.js @@ -156,7 +156,7 @@ function runTests(options) { // run each test with a 10 second pause between (to let GC do its stuff) promise = promise.then(() => runTest(options) - .then(result => { + .then((result) => { results.push(result); }) .delay(sleepTime) @@ -180,13 +180,13 @@ function runTests(options) { let mainPromise = Promise.resolve(); // var mainPromise = execute(125, 'stream', 'plain', 'own'); -_.each(counts, count => { +_.each(counts, (count) => { mainPromise = mainPromise.then(() => { resultSheet.addRow().getCell('count').value = count; }); - _.each(workbooks, workbook => { - _.each(styles, style => { - _.each(strings, str => { + _.each(workbooks, (workbook) => { + _.each(styles, (style) => { + _.each(strings, (str) => { mainPromise = mainPromise.then( runTests({ count, @@ -208,7 +208,7 @@ mainPromise = mainPromise .then(() => { console.log('All Done'); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); diff --git a/test/testPrintAreaOut.js b/test/testPrintAreaOut.js index c5f0c8788..eea8fea58 100644 --- a/test/testPrintAreaOut.js +++ b/test/testPrintAreaOut.js @@ -35,6 +35,6 @@ wb.xlsx .then(() => { console.log('Done.'); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); diff --git a/test/testPrintColRowOut.js b/test/testPrintColRowOut.js index ebfdb3878..8edf20016 100644 --- a/test/testPrintColRowOut.js +++ b/test/testPrintColRowOut.js @@ -41,6 +41,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch(error => { + .catch((error) => { console.log(error.message); }); diff --git a/test/testProcess.js b/test/testProcess.js index 1c311fc34..8037af3da 100644 --- a/test/testProcess.js +++ b/test/testProcess.js @@ -22,7 +22,7 @@ wb.xlsx .then(() => { console.log('Loaded', inputFile); - wb.eachSheet(sheet => { + wb.eachSheet((sheet) => { console.log(sheet.name); }); @@ -39,7 +39,7 @@ wb.xlsx .then(() => { assert(passed, 'Something went wrong', 'All tests passed!'); }) - .catch(error => { + .catch((error) => { console.error(error.message); console.error(error.stack); }); diff --git a/test/testSax2.js b/test/testSax2.js index 20ebe4d95..d841aaec2 100644 --- a/test/testSax2.js +++ b/test/testSax2.js @@ -45,7 +45,7 @@ e.on('finished', () => { let row = null; let cell = null; -parser.on('opentag', node => { +parser.on('opentag', (node) => { // console.log('opentag ' + node.name); switch (node.name) { case 'row': { @@ -64,13 +64,13 @@ parser.on('opentag', node => { default: } }); -parser.on('text', text => { +parser.on('text', (text) => { // console.log('text ' + text); if (cell) { cell.value += text; } }); -parser.on('closetag', name => { +parser.on('closetag', (name) => { // console.log('closetag ' + name); switch (name) { case 'row': diff --git a/test/testSharedStrings.js b/test/testSharedStrings.js index 69cc1ca6c..2c9216deb 100644 --- a/test/testSharedStrings.js +++ b/test/testSharedStrings.js @@ -17,4 +17,4 @@ wb.xlsx .then(() => { console.log('done'); }) - .catch(e => console.log(e)); + .catch((e) => console.log(e)); diff --git a/test/testStringBuf.js b/test/testStringBuf.js index 1adc440a8..c93bdd720 100644 --- a/test/testStringBuf.js +++ b/test/testStringBuf.js @@ -87,6 +87,6 @@ const results = {}; Promise.resolve(results) .then(testWrite) .then(testGrow) - .then(r => { + .then((r) => { console.log(JSON.stringify(r, null, ' ')); }); diff --git a/test/testStringtable.js b/test/testStringtable.js index 96a93fae9..4ac07989c 100644 --- a/test/testStringtable.js +++ b/test/testStringtable.js @@ -7,7 +7,7 @@ const filename = process.argv[2]; const st = new SharedStrings(null); const lst = ['Hello', 'Hello', 'World', 'Hello\nWorld!', 'Hello, "World!"']; -_.each(lst, item => { +_.each(lst, (item) => { st.add(item); }); diff --git a/test/testTemplate.js b/test/testTemplate.js index 2fdd7421d..875f4258a 100644 --- a/test/testTemplate.js +++ b/test/testTemplate.js @@ -3,7 +3,7 @@ const Excel = require('../excel'); const workbook = new Excel.Workbook(); workbook.xlsx .readFile('./out/template.xlsx') - .then(stream => { + .then((stream) => { const options = { useSharedStrings: true, useStyles: true, @@ -15,7 +15,7 @@ workbook.xlsx console.log('Done.'); }); }) - .catch(error => { + .catch((error) => { console.error(error.message); console.error(error.stack); }); diff --git a/test/testXlsxIn.js b/test/testXlsxIn.js index 589263929..1dc45250e 100644 --- a/test/testXlsxIn.js +++ b/test/testXlsxIn.js @@ -21,6 +21,6 @@ wb.xlsx console.log(id, sheet.name); }); }) - .catch(error => { + .catch((error) => { console.error('something went wrong', error.stack); }); diff --git a/test/utils/column-sum.js b/test/utils/column-sum.js index 6419c992f..b58c5b029 100644 --- a/test/utils/column-sum.js +++ b/test/utils/column-sum.js @@ -4,14 +4,14 @@ const ColumnSum = (module.exports = function(columns) { this.columns = columns; this.sums = []; this.count = 0; - _.each(this.columns, column => { + _.each(this.columns, (column) => { this.sums[column] = 0; }); }); ColumnSum.prototype = { add(row) { - _.each(this.columns, column => { + _.each(this.columns, (column) => { this.sums[column] += row.getCell(column).value; }); this.count++; @@ -22,7 +22,7 @@ ColumnSum.prototype = { }, toAverages() { return this.sum - .map(value => (value ? value / this.count : value)) + .map((value) => (value ? value / this.count : value)) .join(', '); }, }; diff --git a/test/utils/utils.js b/test/utils/utils.js index 7a30f2633..c7586c244 100644 --- a/test/utils/utils.js +++ b/test/utils/utils.js @@ -38,7 +38,7 @@ const main = { deferred.reject(err); } else { const promises = []; - _.each(files, file => { + _.each(files, (file) => { promises.push(remove(`${path}/${file}`)); }); @@ -46,7 +46,7 @@ const main = { .then(() => { deferred.resolve(); }) - .catch(error => { + .catch((error) => { deferred.reject(error); }); } From 51cfe072109082af2a344a3524c2e5870132024c Mon Sep 17 00:00:00 2001 From: Andreas Lubbe Date: Mon, 28 Sep 2020 20:17:04 +0200 Subject: [PATCH 2/4] Use arrow-parens only as-needed --- .eslintrc | 1 + .prettier | 3 +- benchmark.js | 4 +- lib/csv/csv.js | 4 +- lib/csv/line-buffer.js | 2 +- lib/csv/stream-converter.js | 2 +- lib/doc/cell.js | 6 +- lib/doc/column.js | 2 +- lib/doc/defined-names.js | 20 +++--- lib/doc/row.js | 12 ++-- lib/doc/table.js | 8 +-- lib/doc/workbook.js | 14 ++-- lib/doc/worksheet.js | 40 +++++------ lib/exceljs.bare.js | 2 +- lib/exceljs.browser.js | 2 +- lib/stream/xlsx/sheet-comments-writer.js | 4 +- lib/stream/xlsx/workbook-writer.js | 26 +++---- lib/stream/xlsx/worksheet-writer.js | 10 +-- lib/utils/cell-matrix.js | 4 +- lib/utils/iterate-stream.js | 8 +-- lib/utils/parse-sax.js | 8 +-- lib/utils/stream-base64.js | 2 +- lib/utils/stream-buf.js | 12 ++-- lib/utils/under-dash.js | 8 +-- lib/utils/utils.js | 14 ++-- lib/xlsx/xform/base-xform.js | 2 +- lib/xlsx/xform/book/defined-name-xform.js | 2 +- lib/xlsx/xform/book/workbook-xform.js | 8 +-- lib/xlsx/xform/comment/comment-xform.js | 2 +- lib/xlsx/xform/comment/comments-xform.js | 2 +- lib/xlsx/xform/comment/vml-notes-xform.js | 2 +- lib/xlsx/xform/comment/vml-textbox-xform.js | 4 +- .../xform/core/app-titles-of-parts-xform.js | 2 +- lib/xlsx/xform/core/content-types-xform.js | 8 +-- lib/xlsx/xform/core/relationships-xform.js | 2 +- lib/xlsx/xform/drawing/drawing-xform.js | 4 +- lib/xlsx/xform/list-xform.js | 2 +- lib/xlsx/xform/sheet/cell-xform.js | 2 +- .../conditional-formatting-ext-xform.js | 4 +- .../conditional-formattings-ext-xform.js | 6 +- .../xform/sheet/cf-ext/databar-ext-xform.js | 2 +- .../xform/sheet/cf-ext/icon-set-ext-xform.js | 2 +- lib/xlsx/xform/sheet/cf/cf-rule-xform.js | 8 +-- lib/xlsx/xform/sheet/cf/color-scale-xform.js | 4 +- .../sheet/cf/conditional-formatting-xform.js | 2 +- .../sheet/cf/conditional-formattings-xform.js | 12 ++-- lib/xlsx/xform/sheet/cf/databar-xform.js | 2 +- lib/xlsx/xform/sheet/cf/icon-set-xform.js | 2 +- .../xform/sheet/data-validations-xform.js | 8 +-- lib/xlsx/xform/sheet/merges.js | 4 +- .../xform/sheet/outline-properties-xform.js | 2 +- lib/xlsx/xform/sheet/page-margins-xform.js | 2 +- lib/xlsx/xform/sheet/page-setup-xform.js | 2 +- lib/xlsx/xform/sheet/print-options-xform.js | 2 +- lib/xlsx/xform/sheet/row-breaks-xform.js | 2 +- lib/xlsx/xform/sheet/row-xform.js | 8 +-- .../sheet/sheet-format-properties-xform.js | 2 +- .../xform/sheet/sheet-protection-xform.js | 2 +- lib/xlsx/xform/sheet/worksheet-xform.js | 30 ++++---- lib/xlsx/xform/static-xform.js | 2 +- lib/xlsx/xform/strings/phonetic-text-xform.js | 2 +- lib/xlsx/xform/strings/shared-string-xform.js | 2 +- .../xform/strings/shared-strings-xform.js | 2 +- lib/xlsx/xform/style/fill-xform.js | 2 +- lib/xlsx/xform/style/styles-xform.js | 12 ++-- lib/xlsx/xform/table/auto-filter-xform.js | 2 +- lib/xlsx/xform/table/table-xform.js | 2 +- lib/xlsx/xlsx.js | 30 ++++---- spec/browser/exceljs.spec.js | 18 ++--- ...ue-1328-xlsx-worksheet-reader-date.spec.js | 4 +- .../issues/issue-219-1904-dates.spec.js | 2 +- .../issue-234-vertical-tab-char.spec.js | 2 +- .../issues/issue-257-sheet-order.spec.js | 2 +- .../issue-275-hyperlink-query-param.spec.js | 2 +- .../issue-623-borders-for-merged-cell.spec.js | 4 +- .../issue-703-speciel-cell-file.spec.js | 2 +- .../issues/issue-991-csv-read-dates.spec.js | 2 +- .../integration/pr/pr-896/test-pr-896.spec.js | 2 +- spec/integration/pr/test-pr-1431.spec.js | 4 +- spec/integration/pr/test-pr-896.spec.js | 4 +- spec/integration/workbook-xlsx-reader.spec.js | 28 ++++---- .../workbook-xlsx-writer.spec.js | 26 +++---- spec/integration/workbook/images.spec.js | 12 ++-- spec/integration/workbook/styles.spec.js | 6 +- spec/integration/workbook/workbook.spec.js | 62 ++++++++-------- .../integration/worksheet-xlsx-writer.spec.js | 2 +- spec/integration/worksheet.spec.js | 12 ++-- spec/unit/doc/defined-names.spec.js | 4 +- spec/unit/doc/worksheet-table.spec.js | 2 +- spec/unit/doc/worksheet.values.spec.js | 4 +- spec/unit/utils/stream-buf.spec.js | 2 +- spec/unit/utils/utils.spec.js | 4 +- spec/unit/xlsx/xform/compy-xform.js | 6 +- spec/unit/xlsx/xform/test-xform-helper.js | 18 ++--- spec/utils/index.js | 4 +- .../test-conditional-formatting-sheet.js | 4 +- spec/utils/test-data-validation-sheet.js | 6 +- spec/utils/test-spliced-sheet.js | 72 +++++++++---------- spec/utils/test-values-sheet.js | 2 +- spec/utils/test-workbook-reader.js | 4 +- spec/utils/tools.js | 2 +- test/test-a1.js | 2 +- test/test-cf.js | 2 +- test/test-chart.js | 2 +- test/test-colour-cell.js | 2 +- test/test-comment-new.js | 2 +- test/test-comment-stream-writer.js | 2 +- test/test-comments.js | 2 +- test/test-copy.js | 2 +- test/test-default-height.js | 2 +- test/test-formula.js | 4 +- test/test-header-footer.js | 2 +- test/test-hyperlink.js | 2 +- test/test-image-one-cell-anchor.js | 2 +- test/test-image-oneCell.js | 2 +- test/test-image-out.js | 2 +- test/test-image-stream-writer.js | 2 +- test/test-jszip.js | 4 +- test/test-merge-align.js | 2 +- test/test-newline.js | 2 +- test/test-protection-spinCount.js | 2 +- test/test-protection.js | 2 +- test/test-table.js | 2 +- test/testArray.js | 2 +- test/testBigBookIn.js | 6 +- test/testBigBookOut.js | 2 +- test/testBookFont.js | 8 +-- test/testBookOut.js | 2 +- test/testBookOutS.js | 2 +- test/testBookRead.js | 4 +- test/testCsvOut.js | 2 +- test/testImageIn.js | 2 +- test/testMergedBorder.js | 2 +- test/testMultiplePrintAreaOut.js | 2 +- test/testPerformance.js | 12 ++-- test/testPrintAreaOut.js | 2 +- test/testPrintColRowOut.js | 2 +- test/testProcess.js | 4 +- test/testSax2.js | 6 +- test/testSharedStrings.js | 2 +- test/testStringBuf.js | 2 +- test/testStringtable.js | 2 +- test/testTemplate.js | 4 +- test/testXlsxIn.js | 2 +- test/utils/column-sum.js | 6 +- test/utils/utils.js | 4 +- 146 files changed, 443 insertions(+), 441 deletions(-) diff --git a/.eslintrc b/.eslintrc index b59db4aa1..9342c97f5 100644 --- a/.eslintrc +++ b/.eslintrc @@ -13,6 +13,7 @@ "node": true }, "rules": { + "arrow-parens": ["error", "as-needed"], "class-methods-use-this": ["off"], "comma-dangle": ["error", {"arrays": "always-multiline", "objects": "always-multiline", "imports": "always-multiline", "exports": "always-multiline", "functions": "never"}], "default-case": ["off"], diff --git a/.prettier b/.prettier index 2f891b81a..dc9121c80 100644 --- a/.prettier +++ b/.prettier @@ -2,5 +2,6 @@ "bracketSpacing": false, "printWidth": 160, "trailingComma": "all", - "bracketSpacing": false + "bracketSpacing": true, + "arrowParens": "avoid" } diff --git a/benchmark.js b/benchmark.js index ce854a0ba..ca698f02d 100644 --- a/benchmark.js +++ b/benchmark.js @@ -13,10 +13,10 @@ const runs = 3; let worksheetCount = 0; let rowCount = 0; - workbookReader.on('worksheet', (worksheet) => { + workbookReader.on('worksheet', worksheet => { worksheetCount += 1; console.log(`Reading worksheet ${worksheetCount}`); - worksheet.on('row', (row) => { + worksheet.on('row', row => { rowCount += 1; if (rowCount % 50000 === 0) console.log(`Reading row ${rowCount}`); }); diff --git a/lib/csv/csv.js b/lib/csv/csv.js index 8bb95c840..fb6c70024 100644 --- a/lib/csv/csv.js +++ b/lib/csv/csv.js @@ -79,7 +79,7 @@ class CSV { const csvStream = fastCsv .parse(options.parserOptions) - .on('data', (data) => { + .on('data', data => { worksheet.addRow(data.map(map)); }) .on('end', () => { @@ -120,7 +120,7 @@ class CSV { const {dateFormat, dateUTC} = options; const map = options.map || - ((value) => { + (value => { if (value) { if (value.text || value.hyperlink) { return value.hyperlink || value.text || ''; diff --git a/lib/csv/line-buffer.js b/lib/csv/line-buffer.js index a97ea4254..8ea489c96 100644 --- a/lib/csv/line-buffer.js +++ b/lib/csv/line-buffer.js @@ -63,7 +63,7 @@ class LineBuffer extends EventEmitter { _flush() { if (!this.corked) { - this.queue.forEach((line) => { + this.queue.forEach(line => { this.emit('line', line); }); this.queue = []; diff --git a/lib/csv/stream-converter.js b/lib/csv/stream-converter.js index 49638c4ab..639aa5b7d 100644 --- a/lib/csv/stream-converter.js +++ b/lib/csv/stream-converter.js @@ -105,7 +105,7 @@ class StreamConverter { on(type, callback) { switch (type) { case 'data': - this.inner.on('data', (chunk) => { + this.inner.on('data', chunk => { callback(this.convertOutwards(chunk)); }); return this; diff --git a/lib/doc/cell.js b/lib/doc/cell.js index cf7fb3750..3ae2457a8 100644 --- a/lib/doc/cell.js +++ b/lib/doc/cell.js @@ -292,7 +292,7 @@ class Cell { set names(value) { const {definedNames} = this.workbook; definedNames.removeAllNames(this.fullAddress); - value.forEach((name) => { + value.forEach(name => { definedNames.addEx(this.fullAddress, name); }); } @@ -509,7 +509,7 @@ class RichTextValue { } toString() { - return this.model.value.richText.map((t) => t.text).join(''); + return this.model.value.richText.map(t => t.text).join(''); } get type() { @@ -748,7 +748,7 @@ class FormulaValue { _copyModel(model) { const copy = {}; - const cp = (name) => { + const cp = name => { const value = model[name]; if (value) { copy[name] = value; diff --git a/lib/doc/column.js b/lib/doc/column.js index 6283407e2..e5f8ceef0 100644 --- a/lib/doc/column.js +++ b/lib/doc/column.js @@ -198,7 +198,7 @@ class Column { // styles _applyStyle(name, value) { this.style[name] = value; - this.eachCell((cell) => { + this.eachCell(cell => { cell[name] = value; }); return value; diff --git a/lib/doc/defined-names.js b/lib/doc/defined-names.js index 522792f8a..597744207 100644 --- a/lib/doc/defined-names.js +++ b/lib/doc/defined-names.js @@ -54,14 +54,14 @@ class DefinedNames { } removeAllNames(location) { - _.each(this.matrixMap, (matrix) => { + _.each(this.matrixMap, matrix => { matrix.removeCellEx(location); }); } forEach(callback) { _.each(this.matrixMap, (matrix, name) => { - matrix.forEach((cell) => { + matrix.forEach(cell => { callback(name, cell); }); }); @@ -128,13 +128,13 @@ class DefinedNames { } // mark and sweep! - matrix.forEach((cell) => { + matrix.forEach(cell => { cell.mark = true; }); const ranges = matrix - .map((cell) => cell.mark && this._explore(matrix, cell)) + .map(cell => cell.mark && this._explore(matrix, cell)) .filter(Boolean) - .map((range) => range.$shortRange); + .map(range => range.$shortRange); return { name, @@ -157,14 +157,14 @@ class DefinedNames { } spliceRows(sheetName, start, numDelete, numInsert) { - _.each(this.matrixMap, (matrix) => { + _.each(this.matrixMap, matrix => { matrix.spliceRows(sheetName, start, numDelete, numInsert); this.normaliseMatrix(matrix, sheetName); }); } spliceColumns(sheetName, start, numDelete, numInsert) { - _.each(this.matrixMap, (matrix) => { + _.each(this.matrixMap, matrix => { matrix.spliceColumns(sheetName, start, numDelete, numInsert); this.normaliseMatrix(matrix, sheetName); }); @@ -172,15 +172,15 @@ class DefinedNames { get model() { // To get names per cell - just iterate over all names finding cells if they exist - return _.map(this.matrixMap, (matrix, name) => this.getRanges(name, matrix)).filter((definedName) => definedName.ranges.length); + return _.map(this.matrixMap, (matrix, name) => this.getRanges(name, matrix)).filter(definedName => definedName.ranges.length); } set model(value) { // value is [ { name, ranges }, ... ] const matrixMap = (this.matrixMap = {}); - value.forEach((definedName) => { + value.forEach(definedName => { const matrix = (matrixMap[definedName.name] = new CellMatrix()); - definedName.ranges.forEach((rangeStr) => { + definedName.ranges.forEach(rangeStr => { if (rangeRegexp.test(rangeStr.split('!').pop() || '')) { matrix.addCell(rangeStr); } diff --git a/lib/doc/row.js b/lib/doc/row.js index caa1c1895..520cc7fe9 100644 --- a/lib/doc/row.js +++ b/lib/doc/row.js @@ -165,7 +165,7 @@ class Row { // return a sparse array of cell values get values() { const values = []; - this._cells.forEach((cell) => { + this._cells.forEach(cell => { if (cell && cell.type !== Enums.ValueType.Null) { values[cell.col] = cell.value; } @@ -210,7 +210,7 @@ class Row { // returns true if the row includes at least one cell with a value get hasValues() { - return _.some(this._cells, (cell) => cell && cell.type !== Enums.ValueType.Null); + return _.some(this._cells, cell => cell && cell.type !== Enums.ValueType.Null); } get cellCount() { @@ -229,7 +229,7 @@ class Row { get dimensions() { let min = 0; let max = 0; - this._cells.forEach((cell) => { + this._cells.forEach(cell => { if (cell && cell.type !== Enums.ValueType.Null) { if (!min || min > cell.col) { min = cell.col; @@ -251,7 +251,7 @@ class Row { // styles _applyStyle(name, value) { this.style[name] = value; - this._cells.forEach((cell) => { + this._cells.forEach(cell => { if (cell) { cell[name] = value; } @@ -332,7 +332,7 @@ class Row { const cells = []; let min = 0; let max = 0; - this._cells.forEach((cell) => { + this._cells.forEach(cell => { if (cell) { const cellModel = cell.model; if (cellModel) { @@ -368,7 +368,7 @@ class Row { } this._cells = []; let previousAddress; - value.cells.forEach((cellModel) => { + value.cells.forEach(cellModel => { switch (cellModel.type) { case Cell.Types.Merge: // special case - don't add this types diff --git a/lib/doc/table.js b/lib/doc/table.js index a5c565ed8..87a96d29c 100644 --- a/lib/doc/table.js +++ b/lib/doc/table.js @@ -182,7 +182,7 @@ class Table { // the sheet... const assignStyle = (cell, style) => { if (style) { - Object.keys(style).forEach((key) => { + Object.keys(style).forEach(key => { cell[key] = style[key]; }); } @@ -200,7 +200,7 @@ class Table { assignStyle(cell, style); }); } - table.rows.forEach((data) => { + table.rows.forEach(data => { const r = worksheet.getRow(row + count++); data.forEach((value, j) => { const cell = r.getCell(col + j); @@ -245,7 +245,7 @@ class Table { cell.value = column.name; }); } - table.rows.forEach((data) => { + table.rows.forEach(data => { const r = worksheet.getRow(row + count++); data.forEach((value, j) => { const cell = r.getCell(col + j); @@ -379,7 +379,7 @@ class Table { this.cacheState(); this.table.columns.splice(colIndex, count); - this.table.rows.forEach((row) => { + this.table.rows.forEach(row => { row.splice(colIndex, count); }); } diff --git a/lib/doc/workbook.js b/lib/doc/workbook.js index a828b1259..98c42c0ea 100644 --- a/lib/doc/workbook.js +++ b/lib/doc/workbook.js @@ -51,7 +51,7 @@ class Workbook { console.warn(`Worksheet name ${name} exceeds 31 chars. This will be truncated`); } name = (name || `sheet${id}`).substring(0, 31); - if (this._worksheets.find((ws) => ws && ws.name.toLowerCase() === name.toLowerCase())) { + if (this._worksheets.find(ws => ws && ws.name.toLowerCase() === name.toLowerCase())) { throw new Error(`Worksheet name already exists: ${name}`); } @@ -109,7 +109,7 @@ class Workbook { return this._worksheets[id]; } if (typeof id === 'string') { - return this._worksheets.find((worksheet) => worksheet && worksheet.name === id); + return this._worksheets.find(worksheet => worksheet && worksheet.name === id); } return undefined; } @@ -123,7 +123,7 @@ class Workbook { } eachSheet(iteratee) { - this.worksheets.forEach((sheet) => { + this.worksheets.forEach(sheet => { iteratee(sheet, sheet.id); }); } @@ -156,8 +156,8 @@ class Workbook { created: this.created, modified: this.modified, properties: this.properties, - worksheets: this.worksheets.map((worksheet) => worksheet.model), - sheets: this.worksheets.map((ws) => ws.model).filter(Boolean), + worksheets: this.worksheets.map(worksheet => worksheet.model), + sheets: this.worksheets.map(ws => ws.model).filter(Boolean), definedNames: this._definedNames.model, views: this.views, company: this.company, @@ -196,9 +196,9 @@ class Workbook { this.properties = value.properties; this.calcProperties = value.calcProperties; this._worksheets = []; - value.worksheets.forEach((worksheetModel) => { + value.worksheets.forEach(worksheetModel => { const {id, name, state} = worksheetModel; - const orderNo = value.sheets && value.sheets.findIndex((ws) => ws.id === id); + const orderNo = value.sheets && value.sheets.findIndex(ws => ws.id === id); const worksheet = (this._worksheets[id] = new Worksheet({ id, name, diff --git a/lib/doc/worksheet.js b/lib/doc/worksheet.js index f738318d0..b1ca37852 100644 --- a/lib/doc/worksheet.js +++ b/lib/doc/worksheet.js @@ -135,7 +135,7 @@ class Worksheet { // Get the bounding range of the cells in this worksheet get dimensions() { const dimensions = new Range(); - this._rows.forEach((row) => { + this._rows.forEach(row => { if (row) { const rowDims = row.dimensions; if (rowDims) { @@ -166,7 +166,7 @@ class Worksheet { // construct Column objects let count = 1; const columns = (this._columns = []); - value.forEach((defn) => { + value.forEach(defn => { const column = new Column(this, count++, false); columns.push(column); column.defn = defn; @@ -219,7 +219,7 @@ class Worksheet { for (let i = 0; i < nRows; i++) { const rowArguments = [start, count]; // eslint-disable-next-line no-loop-func - inserts.forEach((insert) => { + inserts.forEach(insert => { rowArguments.push(insert[i] || null); }); const row = this.getRow(i + 1); @@ -228,7 +228,7 @@ class Worksheet { } } else { // nothing to insert, so just splice all rows - this._rows.forEach((r) => { + this._rows.forEach(r => { if (r) { r.splice(start, count); } @@ -258,7 +258,7 @@ class Worksheet { get columnCount() { let maxCount = 0; - this.eachRow((row) => { + this.eachRow(row => { maxCount = Math.max(maxCount, row.cellCount); }); return maxCount; @@ -268,7 +268,7 @@ class Worksheet { // performance nightmare - for each row, counts all the columns used const counts = []; let count = 0; - this.eachRow((row) => { + this.eachRow(row => { row.eachCell(({col}) => { if (!counts[col]) { counts[col] = true; @@ -359,7 +359,7 @@ class Worksheet { addRows(value, style = 'n') { const rows = []; - value.forEach((row) => { + value.forEach(row => { rows.push(this.addRow(row, style)); }); return rows; @@ -493,7 +493,7 @@ class Worksheet { iteratee(this.getRow(i), i); } } else { - this._rows.forEach((row) => { + this._rows.forEach(row => { if (row && row.hasValues) { iteratee(row, row.number); } @@ -504,7 +504,7 @@ class Worksheet { // return all rows as sparse array getSheetValues() { const rows = []; - this._rows.forEach((row) => { + this._rows.forEach(row => { if (row) { rows[row.number] = row.values; } @@ -545,7 +545,7 @@ class Worksheet { _mergeCellsInternal(dimensions, ignoreStyle) { // check cells aren't already merged - _.each(this._merges, (merge) => { + _.each(this._merges, merge => { if (merge.intersects(dimensions)) { throw new Error('Cannot merge already merged cells'); } @@ -666,7 +666,7 @@ class Worksheet { } getImages() { - return this._media.filter((m) => m.type === 'image'); + return this._media.filter(m => m.type === 'image'); } addBackgroundImage(imageId) { @@ -678,7 +678,7 @@ class Worksheet { } getBackgroundImageId() { - const image = this._media.find((m) => m.type === 'background'); + const image = this._media.find(m => m.type === 'background'); return image && image.imageId; } @@ -687,7 +687,7 @@ class Worksheet { protect(password, options) { // TODO: make this function truly async // perhaps marshal to worker thread or something - return new Promise((resolve) => { + return new Promise(resolve => { this.sheetProtection = { sheet: true, }; @@ -780,9 +780,9 @@ class Worksheet { rowBreaks: this.rowBreaks, views: this.views, autoFilter: this.autoFilter, - media: this._media.map((medium) => medium.model), + media: this._media.map(medium => medium.model), sheetProtection: this.sheetProtection, - tables: Object.values(this.tables).map((table) => table.model), + tables: Object.values(this.tables).map(table => table.model), conditionalFormattings: this.conditionalFormattings, }; @@ -794,7 +794,7 @@ class Worksheet { // Rows const rows = (model.rows = []); const dimensions = (model.dimensions = new Range()); - this._rows.forEach((row) => { + this._rows.forEach(row => { const rowModel = row && row.model; if (rowModel) { dimensions.expand(rowModel.number, rowModel.min, rowModel.number, rowModel.max); @@ -805,7 +805,7 @@ class Worksheet { // ========================================================== // Merges model.merges = []; - _.each(this._merges, (merge) => { + _.each(this._merges, merge => { model.merges.push(merge.range); }); @@ -814,7 +814,7 @@ class Worksheet { _parseRows(model) { this._rows = []; - model.rows.forEach((rowModel) => { + model.rows.forEach(rowModel => { const row = new Row(this, rowModel.number); this._rows[row.number - 1] = row; row.model = rowModel; @@ -822,7 +822,7 @@ class Worksheet { } _parseMergeCells(model) { - _.each(model.mergeCells, (merge) => { + _.each(model.mergeCells, merge => { // Do not merge styles when importing an Excel file // since each cell may have different styles intentionally. this.mergeCellsWithoutStyle(merge); @@ -841,7 +841,7 @@ class Worksheet { this.headerFooter = value.headerFooter; this.views = value.views; this.autoFilter = value.autoFilter; - this._media = value.media.map((medium) => new Image(this, medium)); + this._media = value.media.map(medium => new Image(this, medium)); this.sheetProtection = value.sheetProtection; this.tables = value.tables.reduce((tables, table) => { const t = new Table(); diff --git a/lib/exceljs.bare.js b/lib/exceljs.bare.js index 922831efc..9f00471f8 100644 --- a/lib/exceljs.bare.js +++ b/lib/exceljs.bare.js @@ -6,7 +6,7 @@ const ExcelJS = { // Object.assign mono-fill const Enums = require('./doc/enums'); -Object.keys(Enums).forEach((key) => { +Object.keys(Enums).forEach(key => { ExcelJS[key] = Enums[key]; }); diff --git a/lib/exceljs.browser.js b/lib/exceljs.browser.js index aecd27422..3a3d631dc 100644 --- a/lib/exceljs.browser.js +++ b/lib/exceljs.browser.js @@ -13,7 +13,7 @@ const ExcelJS = { // Object.assign mono-fill const Enums = require('./doc/enums'); -Object.keys(Enums).forEach((key) => { +Object.keys(Enums).forEach(key => { ExcelJS[key] = Enums[key]; }); diff --git a/lib/stream/xlsx/sheet-comments-writer.js b/lib/stream/xlsx/sheet-comments-writer.js index fb86ea7fd..e241e9add 100644 --- a/lib/stream/xlsx/sheet-comments-writer.js +++ b/lib/stream/xlsx/sheet-comments-writer.js @@ -98,11 +98,11 @@ class SheetCommentsWriter { this.startedData = true; } - comments.forEach((item) => { + comments.forEach(item => { item.refAddress = colCache.decodeAddress(item.ref); }); - comments.forEach((comment) => { + comments.forEach(comment => { this._writeComment(comment, this.count); this.count += 1; }); diff --git a/lib/stream/xlsx/workbook-writer.js b/lib/stream/xlsx/workbook-writer.js index 31eb056e7..6816c58d6 100644 --- a/lib/stream/xlsx/workbook-writer.js +++ b/lib/stream/xlsx/workbook-writer.js @@ -77,7 +77,7 @@ class WorkbookWriter { _commitWorksheets() { const commitWorksheet = function(worksheet) { if (!worksheet.committed) { - return new Promise((resolve) => { + return new Promise(resolve => { worksheet.stream.on('zipped', () => { resolve(); }); @@ -172,27 +172,27 @@ class WorkbookWriter { return this._worksheets[id]; } if (typeof id === 'string') { - return this._worksheets.find((worksheet) => worksheet && worksheet.name === id); + return this._worksheets.find(worksheet => worksheet && worksheet.name === id); } return undefined; } addStyles() { - return new Promise((resolve) => { + return new Promise(resolve => { this.zip.append(this.styles.xml, {name: 'xl/styles.xml'}); resolve(); }); } addThemes() { - return new Promise((resolve) => { + return new Promise(resolve => { this.zip.append(theme1Xml, {name: 'xl/theme/theme1.xml'}); resolve(); }); } addOfficeRels() { - return new Promise((resolve) => { + return new Promise(resolve => { const xform = new RelationshipsXform(); const xml = xform.toXml([ {Id: 'rId1', Type: RelType.OfficeDocument, Target: 'xl/workbook.xml'}, @@ -205,7 +205,7 @@ class WorkbookWriter { } addContentTypes() { - return new Promise((resolve) => { + return new Promise(resolve => { const model = { worksheets: this._worksheets.filter(Boolean), sharedStrings: this.sharedStrings, @@ -221,7 +221,7 @@ class WorkbookWriter { addMedia() { return Promise.all( - this.media.map((medium) => { + this.media.map(medium => { if (medium.type === 'image') { const filename = `xl/media/${medium.name}`; if (medium.filename) { @@ -242,7 +242,7 @@ class WorkbookWriter { } addApp() { - return new Promise((resolve) => { + return new Promise(resolve => { const model = { worksheets: this._worksheets.filter(Boolean), }; @@ -254,7 +254,7 @@ class WorkbookWriter { } addCore() { - return new Promise((resolve) => { + return new Promise(resolve => { const coreXform = new CoreXform(); const xml = coreXform.toXml(this); this.zip.append(xml, {name: 'docProps/core.xml'}); @@ -264,7 +264,7 @@ class WorkbookWriter { addSharedStrings() { if (this.sharedStrings.count) { - return new Promise((resolve) => { + return new Promise(resolve => { const sharedStringsXform = new SharedStringsXform(); const xml = sharedStringsXform.toXml(this.sharedStrings); this.zip.append(xml, {name: '/xl/sharedStrings.xml'}); @@ -283,13 +283,13 @@ class WorkbookWriter { if (this.sharedStrings.count) { relationships.push({Id: `rId${count++}`, Type: RelType.SharedStrings, Target: 'sharedStrings.xml'}); } - this._worksheets.forEach((worksheet) => { + this._worksheets.forEach(worksheet => { if (worksheet) { worksheet.rId = `rId${count++}`; relationships.push({Id: worksheet.rId, Type: RelType.Worksheet, Target: `worksheets/sheet${worksheet.id}.xml`}); } }); - return new Promise((resolve) => { + return new Promise(resolve => { const xform = new RelationshipsXform(); const xml = xform.toXml(relationships); this.zip.append(xml, {name: '/xl/_rels/workbook.xml.rels'}); @@ -307,7 +307,7 @@ class WorkbookWriter { calcProperties: {}, }; - return new Promise((resolve) => { + return new Promise(resolve => { const xform = new WorkbookXform(); xform.prepare(model); zip.append(xform.toXml(model), {name: '/xl/workbook.xml'}); diff --git a/lib/stream/xlsx/worksheet-writer.js b/lib/stream/xlsx/worksheet-writer.js index ea34aa8fb..47a199c62 100644 --- a/lib/stream/xlsx/worksheet-writer.js +++ b/lib/stream/xlsx/worksheet-writer.js @@ -209,7 +209,7 @@ class WorksheetWriter { return; } // commit all rows - this._rows.forEach((cRow) => { + this._rows.forEach(cRow => { if (cRow) { // write the row to the stream this._writeRow(cRow); @@ -282,7 +282,7 @@ class WorksheetWriter { // construct Column objects let count = 1; const columns = (this._columns = []); - value.forEach((defn) => { + value.forEach(defn => { const column = new Column(this, count++, false); columns.push(column); column.defn = defn; @@ -346,7 +346,7 @@ class WorksheetWriter { iteratee(this.getRow(i), i); } } else { - this._rows.forEach((row) => { + this._rows.forEach(row => { if (row.hasValues) { iteratee(row, row.number); } @@ -425,7 +425,7 @@ class WorksheetWriter { const dimensions = new Dimensions(cells); // check cells aren't already merged - this._merges.forEach((merge) => { + this._merges.forEach(merge => { if (merge.intersects(dimensions)) { throw new Error('Cannot merge already merged cells'); } @@ -581,7 +581,7 @@ class WorksheetWriter { if (this._merges.length) { xmlBuffer.reset(); xmlBuffer.addText(``); - this._merges.forEach((merge) => { + this._merges.forEach(merge => { xmlBuffer.addText(``); }); xmlBuffer.addText(''); diff --git a/lib/utils/cell-matrix.js b/lib/utils/cell-matrix.js index 92ec91b40..121b5141d 100644 --- a/lib/utils/cell-matrix.js +++ b/lib/utils/cell-matrix.js @@ -96,7 +96,7 @@ class CellMatrix { map(callback) { const results = []; - this.forEach((cell) => { + this.forEach(cell => { results.push(callback(cell)); }); return results; @@ -153,7 +153,7 @@ class CellMatrix { for (let i = 0; i < numInsert; i++) { inserts.push(null); } - _.each(sheet, (row) => { + _.each(sheet, row => { row.splice(start, numDelete, ...inserts); }); } diff --git a/lib/utils/iterate-stream.js b/lib/utils/iterate-stream.js index aa8d62597..08b974e9a 100644 --- a/lib/utils/iterate-stream.js +++ b/lib/utils/iterate-stream.js @@ -1,9 +1,9 @@ module.exports = async function* iterateStream(stream) { const contents = []; - stream.on('data', (data) => contents.push(data)); + stream.on('data', data => contents.push(data)); let resolveStreamEndedPromise; - const streamEndedPromise = new Promise((resolve) => (resolveStreamEndedPromise = resolve)); + const streamEndedPromise = new Promise(resolve => (resolveStreamEndedPromise = resolve)); let ended = false; stream.on('end', () => { @@ -12,7 +12,7 @@ module.exports = async function* iterateStream(stream) { }); let error = false; - stream.on('error', (err) => { + stream.on('error', err => { error = err; resolveStreamEndedPromise(); }); @@ -34,7 +34,7 @@ module.exports = async function* iterateStream(stream) { function once(eventEmitter, type) { // TODO: Use require('events').once when node v10 is dropped - return new Promise((resolve) => { + return new Promise(resolve => { let fired = false; const handler = () => { if (!fired) { diff --git a/lib/utils/parse-sax.js b/lib/utils/parse-sax.js index 474a8d998..d3a53a497 100644 --- a/lib/utils/parse-sax.js +++ b/lib/utils/parse-sax.js @@ -9,13 +9,13 @@ module.exports = async function* (iterable) { } const saxesParser = new SaxesParser(); let error; - saxesParser.on('error', (err) => { + saxesParser.on('error', err => { error = err; }); let events = []; - saxesParser.on('opentag', (value) => events.push({eventType: 'opentag', value})); - saxesParser.on('text', (value) => events.push({eventType: 'text', value})); - saxesParser.on('closetag', (value) => events.push({eventType: 'closetag', value})); + saxesParser.on('opentag', value => events.push({eventType: 'opentag', value})); + saxesParser.on('text', value => events.push({eventType: 'text', value})); + saxesParser.on('closetag', value => events.push({eventType: 'closetag', value})); for await (const chunk of iterable) { saxesParser.write(chunk.toString()); // saxesParser.write and saxesParser.on() are synchronous, diff --git a/lib/utils/stream-base64.js b/lib/utils/stream-base64.js index 249ea643f..b73002081 100644 --- a/lib/utils/stream-base64.js +++ b/lib/utils/stream-base64.js @@ -54,7 +54,7 @@ class StreamBase64 extends Stream.Duplex { unpipe(destination) { // remove destination from pipe list - this.pipes = this.pipes.filter((pipe) => pipe !== destination); + this.pipes = this.pipes.filter(pipe => pipe !== destination); } unshift(/* chunk */) { diff --git a/lib/utils/stream-buf.js b/lib/utils/stream-buf.js index b31eb75b9..90a46b28a 100644 --- a/lib/utils/stream-buf.js +++ b/lib/utils/stream-buf.js @@ -176,7 +176,7 @@ utils.inherits(StreamBuf, Stream.Duplex, { case 1: return this.buffers[0].toBuffer(); default: - return Buffer.concat(this.buffers.map((rwBuf) => rwBuf.toBuffer())); + return Buffer.concat(this.buffers.map(rwBuf => rwBuf.toBuffer())); } }, @@ -201,7 +201,7 @@ utils.inherits(StreamBuf, Stream.Duplex, { async _pipe(chunk) { const write = function(pipe) { - return new Promise((resolve) => { + return new Promise(resolve => { pipe.write(chunk.toBuffer(), () => { resolve(); }); @@ -281,12 +281,12 @@ utils.inherits(StreamBuf, Stream.Duplex, { this._flush(); }, end(chunk, encoding, callback) { - const writeComplete = (error) => { + const writeComplete = error => { if (error) { callback(error); } else { this._flush(); - this.pipes.forEach((pipe) => { + this.pipes.forEach(pipe => { pipe.end(); }); this.emit('finish'); @@ -322,7 +322,7 @@ utils.inherits(StreamBuf, Stream.Duplex, { return Buffer.concat(buffers); } - buffers = this.buffers.map((buf) => buf.toBuffer()).filter(Boolean); + buffers = this.buffers.map(buf => buf.toBuffer()).filter(Boolean); this.buffers = []; return Buffer.concat(buffers); }, @@ -348,7 +348,7 @@ utils.inherits(StreamBuf, Stream.Duplex, { }, unpipe(destination) { // remove destination from pipe list - this.pipes = this.pipes.filter((pipe) => pipe !== destination); + this.pipes = this.pipes.filter(pipe => pipe !== destination); }, unshift(/* chunk */) { // some numpty has read some data that's not for them and they want to put it back! diff --git a/lib/utils/under-dash.js b/lib/utils/under-dash.js index 89ca2c92a..150e1d2a3 100644 --- a/lib/utils/under-dash.js +++ b/lib/utils/under-dash.js @@ -6,7 +6,7 @@ const _ = { if (Array.isArray(obj)) { obj.forEach(cb); } else { - Object.keys(obj).forEach((key) => { + Object.keys(obj).forEach(key => { cb(obj[key], key); }); } @@ -18,7 +18,7 @@ const _ = { if (Array.isArray(obj)) { return obj.some(cb); } - return Object.keys(obj).some((key) => cb(obj[key], key)); + return Object.keys(obj).some(key => cb(obj[key], key)); } return false; }, @@ -28,7 +28,7 @@ const _ = { if (Array.isArray(obj)) { return obj.every(cb); } - return Object.keys(obj).every((key) => cb(obj[key], key)); + return Object.keys(obj).every(key => cb(obj[key], key)); } return true; }, @@ -38,7 +38,7 @@ const _ = { if (Array.isArray(obj)) { return obj.map(cb); } - return Object.keys(obj).map((key) => cb(obj[key], key)); + return Object.keys(obj).map(key => cb(obj[key], key)); } return []; }, diff --git a/lib/utils/utils.js b/lib/utils/utils.js index 63c7c5a9e..f13669a87 100644 --- a/lib/utils/utils.js +++ b/lib/utils/utils.js @@ -11,7 +11,7 @@ const inherits = function(cls, superCtor, statics, prototype) { } if (statics) { - Object.keys(statics).forEach((i) => { + Object.keys(statics).forEach(i => { Object.defineProperty(cls, i, Object.getOwnPropertyDescriptor(statics, i)); }); } @@ -25,7 +25,7 @@ const inherits = function(cls, superCtor, statics, prototype) { }, }; if (prototype) { - Object.keys(prototype).forEach((i) => { + Object.keys(prototype).forEach(i => { properties[i] = Object.getOwnPropertyDescriptor(prototype, i); }); } @@ -36,7 +36,7 @@ const inherits = function(cls, superCtor, statics, prototype) { const utils = { nop() {}, promiseImmediate(value) { - return new Promise((resolve) => { + return new Promise(resolve => { if (global.setImmediate) { setImmediate(() => { resolve(value); @@ -70,7 +70,7 @@ const utils = { }, xmlEncode(text) { // eslint-disable-next-line no-control-regex - return text.replace(/[<>&'"\x7F\x00-\x08\x0B-\x0C\x0E-\x1F]/g, (c) => { + return text.replace(/[<>&'"\x7F\x00-\x08\x0B-\x0C\x0E-\x1F]/g, c => { switch (c) { case '<': return '<'; @@ -88,7 +88,7 @@ const utils = { }); }, xmlDecode(text) { - return text.replace(/&([a-z]*);/, (c) => { + return text.replace(/&([a-z]*);/, c => { switch (c) { case '<': return '<'; @@ -125,8 +125,8 @@ const utils = { fs: { exists(path) { - return new Promise((resolve) => { - fs.access(path, fs.constants.F_OK, (err) => { + return new Promise(resolve => { + fs.access(path, fs.constants.F_OK, err => { resolve(!err); }); }); diff --git a/lib/xlsx/xform/base-xform.js b/lib/xlsx/xform/base-xform.js index 6e4efa0e3..cb48cfa09 100644 --- a/lib/xlsx/xform/base-xform.js +++ b/lib/xlsx/xform/base-xform.js @@ -41,7 +41,7 @@ class BaseXform { // if we have a map - reset them too if (this.map) { - Object.values(this.map).forEach((xform) => { + Object.values(this.map).forEach(xform => { if (xform instanceof BaseXform) { xform.reset(); } else if (xform.xform) { diff --git a/lib/xlsx/xform/book/defined-name-xform.js b/lib/xlsx/xform/book/defined-name-xform.js index 1beafd284..9ed8fec0d 100644 --- a/lib/xlsx/xform/book/defined-name-xform.js +++ b/lib/xlsx/xform/book/defined-name-xform.js @@ -56,7 +56,7 @@ function extractRanges(parsedText) { const ranges = []; let quotesOpened = false; let last = ''; - parsedText.split(',').forEach((item) => { + parsedText.split(',').forEach(item => { if (!item) { return; } diff --git a/lib/xlsx/xform/book/workbook-xform.js b/lib/xlsx/xform/book/workbook-xform.js index 418b848a5..2047d72c8 100644 --- a/lib/xlsx/xform/book/workbook-xform.js +++ b/lib/xlsx/xform/book/workbook-xform.js @@ -32,9 +32,9 @@ class WorkbookXform extends BaseXform { // collate all the print areas from all of the sheets and add them to the defined names const printAreas = []; let index = 0; // sheets is sparse array - calc index manually - model.sheets.forEach((sheet) => { + model.sheets.forEach(sheet => { if (sheet.pageSetup && sheet.pageSetup.printArea) { - sheet.pageSetup.printArea.split('&&').forEach((printArea) => { + sheet.pageSetup.printArea.split('&&').forEach(printArea => { const printAreaComponents = printArea.split(':'); const definedName = { name: '_xlnm.Print_Area', @@ -152,7 +152,7 @@ class WorkbookXform extends BaseXform { let worksheet; let index = 0; - (model.sheets || []).forEach((sheet) => { + (model.sheets || []).forEach(sheet => { const rel = rels[sheet.rId]; if (!rel) { return; @@ -175,7 +175,7 @@ class WorkbookXform extends BaseXform { // reconcile print areas const definedNames = []; - _.each(model.definedNames, (definedName) => { + _.each(model.definedNames, definedName => { if (definedName.name === '_xlnm.Print_Area') { worksheet = worksheets[definedName.localSheetId]; if (worksheet) { diff --git a/lib/xlsx/xform/comment/comment-xform.js b/lib/xlsx/xform/comment/comment-xform.js index 59b49c77a..16363bfea 100644 --- a/lib/xlsx/xform/comment/comment-xform.js +++ b/lib/xlsx/xform/comment/comment-xform.js @@ -51,7 +51,7 @@ utils.inherits(CommentXform, BaseXform, { }); xmlStream.openNode('text'); if (model && model.note && model.note.texts) { - model.note.texts.forEach((text) => { + model.note.texts.forEach(text => { this.richTextXform.render(xmlStream, text); }); } diff --git a/lib/xlsx/xform/comment/comments-xform.js b/lib/xlsx/xform/comment/comments-xform.js index b3ca65b7f..c301bb00e 100644 --- a/lib/xlsx/xform/comment/comments-xform.js +++ b/lib/xlsx/xform/comment/comments-xform.js @@ -32,7 +32,7 @@ utils.inherits( // comments xmlStream.openNode('commentList'); - model.comments.forEach((comment) => { + model.comments.forEach(comment => { this.map.comment.render(xmlStream, comment); }); xmlStream.closeNode(); diff --git a/lib/xlsx/xform/comment/vml-notes-xform.js b/lib/xlsx/xform/comment/vml-notes-xform.js index e8dceeff1..28fe95474 100644 --- a/lib/xlsx/xform/comment/vml-notes-xform.js +++ b/lib/xlsx/xform/comment/vml-notes-xform.js @@ -83,7 +83,7 @@ class VmlNotesXform extends BaseXform { } reconcile(model, options) { - model.anchors.forEach((anchor) => { + model.anchors.forEach(anchor => { if (anchor.br) { this.map['xdr:twoCellAnchor'].reconcile(anchor, options); } else { diff --git a/lib/xlsx/xform/comment/vml-textbox-xform.js b/lib/xlsx/xform/comment/vml-textbox-xform.js index a664dc86c..95f28d934 100644 --- a/lib/xlsx/xform/comment/vml-textbox-xform.js +++ b/lib/xlsx/xform/comment/vml-textbox-xform.js @@ -10,7 +10,7 @@ class VmlTextboxXform extends BaseXform { } reverseConversionUnit(inset) { - return (inset || '').split(',').map((margin) => { + return (inset || '').split(',').map(margin => { return Number(parseFloat(this.conversionUnit(parseFloat(margin), 0.1, '')).toFixed(2)); }); } @@ -23,7 +23,7 @@ class VmlTextboxXform extends BaseXform { let {inset} = model.note && model.note.margins; if (Array.isArray(inset)) { inset = inset - .map((margin) => { + .map(margin => { return this.conversionUnit(margin, 10, 'mm'); }) .join(','); diff --git a/lib/xlsx/xform/core/app-titles-of-parts-xform.js b/lib/xlsx/xform/core/app-titles-of-parts-xform.js index 06eac551c..e276a6fef 100644 --- a/lib/xlsx/xform/core/app-titles-of-parts-xform.js +++ b/lib/xlsx/xform/core/app-titles-of-parts-xform.js @@ -5,7 +5,7 @@ class AppTitlesOfPartsXform extends BaseXform { xmlStream.openNode('TitlesOfParts'); xmlStream.openNode('vt:vector', {size: model.length, baseType: 'lpstr'}); - model.forEach((sheet) => { + model.forEach(sheet => { xmlStream.leafNode('vt:lpstr', undefined, sheet.name); }); diff --git a/lib/xlsx/xform/core/content-types-xform.js b/lib/xlsx/xform/core/content-types-xform.js index 98b0d1ab9..d3babcf61 100644 --- a/lib/xlsx/xform/core/content-types-xform.js +++ b/lib/xlsx/xform/core/content-types-xform.js @@ -11,7 +11,7 @@ class ContentTypesXform extends BaseXform { xmlStream.openNode('Types', ContentTypesXform.PROPERTY_ATTRIBUTES); const mediaHash = {}; - (model.media || []).forEach((medium) => { + (model.media || []).forEach(medium => { if (medium.type === 'image') { const imageType = medium.extension; if (!mediaHash[imageType]) { @@ -29,7 +29,7 @@ class ContentTypesXform extends BaseXform { ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml', }); - model.worksheets.forEach((worksheet) => { + model.worksheets.forEach(worksheet => { const name = `/xl/worksheets/sheet${worksheet.id}.xml`; xmlStream.leafNode('Override', {PartName: name, ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml'}); }); @@ -46,7 +46,7 @@ class ContentTypesXform extends BaseXform { } if (model.tables) { - model.tables.forEach((table) => { + model.tables.forEach(table => { xmlStream.leafNode('Override', { PartName: `/xl/tables/${table.target}`, ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml', @@ -55,7 +55,7 @@ class ContentTypesXform extends BaseXform { } if (model.drawings) { - model.drawings.forEach((drawing) => { + model.drawings.forEach(drawing => { xmlStream.leafNode('Override', { PartName: `/xl/drawings/${drawing.name}.xml`, ContentType: 'application/vnd.openxmlformats-officedocument.drawing+xml', diff --git a/lib/xlsx/xform/core/relationships-xform.js b/lib/xlsx/xform/core/relationships-xform.js index a2ce46642..ead7227d4 100644 --- a/lib/xlsx/xform/core/relationships-xform.js +++ b/lib/xlsx/xform/core/relationships-xform.js @@ -17,7 +17,7 @@ class RelationshipsXform extends BaseXform { xmlStream.openXml(XmlStream.StdDocAttributes); xmlStream.openNode('Relationships', RelationshipsXform.RELATIONSHIPS_ATTRIBUTES); - model.forEach((relationship) => { + model.forEach(relationship => { this.map.Relationship.render(xmlStream, relationship); }); diff --git a/lib/xlsx/xform/drawing/drawing-xform.js b/lib/xlsx/xform/drawing/drawing-xform.js index 1f782cf71..6bc4c43d8 100644 --- a/lib/xlsx/xform/drawing/drawing-xform.js +++ b/lib/xlsx/xform/drawing/drawing-xform.js @@ -37,7 +37,7 @@ class DrawingXform extends BaseXform { xmlStream.openXml(XmlStream.StdDocAttributes); xmlStream.openNode(this.tag, DrawingXform.DRAWING_ATTRIBUTES); - model.anchors.forEach((item) => { + model.anchors.forEach(item => { const anchor = this.map[item.anchorType]; anchor.render(xmlStream, item); }); @@ -91,7 +91,7 @@ class DrawingXform extends BaseXform { } reconcile(model, options) { - model.anchors.forEach((anchor) => { + model.anchors.forEach(anchor => { if (anchor.br) { this.map['xdr:twoCellAnchor'].reconcile(anchor, options); } else { diff --git a/lib/xlsx/xform/list-xform.js b/lib/xlsx/xform/list-xform.js index dac28904d..aeac91f4e 100644 --- a/lib/xlsx/xform/list-xform.js +++ b/lib/xlsx/xform/list-xform.js @@ -85,7 +85,7 @@ class ListXform extends BaseXform { reconcile(model, options) { if (model) { const {childXform} = this; - model.forEach((childModel) => { + model.forEach(childModel => { childXform.reconcile(childModel, options); }); } diff --git a/lib/xlsx/xform/sheet/cell-xform.js b/lib/xlsx/xform/sheet/cell-xform.js index 7fe3cedfd..2e78bf36c 100644 --- a/lib/xlsx/xform/sheet/cell-xform.js +++ b/lib/xlsx/xform/sheet/cell-xform.js @@ -233,7 +233,7 @@ class CellXform extends BaseXform { } else if (model.value && model.value.richText) { xmlStream.addAttribute('t', 'inlineStr'); xmlStream.openNode('is'); - model.value.richText.forEach((text) => { + model.value.richText.forEach(text => { this.richTextXForm.render(xmlStream, text); }); xmlStream.closeNode('is'); diff --git a/lib/xlsx/xform/sheet/cf-ext/conditional-formatting-ext-xform.js b/lib/xlsx/xform/sheet/cf-ext/conditional-formatting-ext-xform.js index 8043099be..d0e9c3bc0 100644 --- a/lib/xlsx/xform/sheet/cf-ext/conditional-formatting-ext-xform.js +++ b/lib/xlsx/xform/sheet/cf-ext/conditional-formatting-ext-xform.js @@ -18,7 +18,7 @@ class ConditionalFormattingExtXform extends CompositeXform { } prepare(model, options) { - model.rules.forEach((rule) => { + model.rules.forEach(rule => { this.cfRule.prepare(rule, options); }); } @@ -32,7 +32,7 @@ class ConditionalFormattingExtXform extends CompositeXform { 'xmlns:xm': 'http://schemas.microsoft.com/office/excel/2006/main', }); - model.rules.filter(CfRuleExtXform.isExt).forEach((rule) => this.cfRule.render(xmlStream, rule)); + model.rules.filter(CfRuleExtXform.isExt).forEach(rule => this.cfRule.render(xmlStream, rule)); // for some odd reason, Excel needs the node to be after the rules this.sqRef.render(xmlStream, model.ref); diff --git a/lib/xlsx/xform/sheet/cf-ext/conditional-formattings-ext-xform.js b/lib/xlsx/xform/sheet/cf-ext/conditional-formattings-ext-xform.js index aad91fa64..77d32b118 100644 --- a/lib/xlsx/xform/sheet/cf-ext/conditional-formattings-ext-xform.js +++ b/lib/xlsx/xform/sheet/cf-ext/conditional-formattings-ext-xform.js @@ -18,13 +18,13 @@ class ConditionalFormattingsExtXform extends CompositeXform { hasContent(model) { if (model.hasExtContent === undefined) { - model.hasExtContent = model.some((cf) => cf.rules.some(CfRuleExtXform.isExt)); + model.hasExtContent = model.some(cf => cf.rules.some(CfRuleExtXform.isExt)); } return model.hasExtContent; } prepare(model, options) { - model.forEach((cf) => { + model.forEach(cf => { this.cfXform.prepare(cf, options); }); } @@ -32,7 +32,7 @@ class ConditionalFormattingsExtXform extends CompositeXform { render(xmlStream, model) { if (this.hasContent(model)) { xmlStream.openNode(this.tag); - model.forEach((cf) => this.cfXform.render(xmlStream, cf)); + model.forEach(cf => this.cfXform.render(xmlStream, cf)); xmlStream.closeNode(); } } diff --git a/lib/xlsx/xform/sheet/cf-ext/databar-ext-xform.js b/lib/xlsx/xform/sheet/cf-ext/databar-ext-xform.js index 47c537fc9..05feeb3e6 100644 --- a/lib/xlsx/xform/sheet/cf-ext/databar-ext-xform.js +++ b/lib/xlsx/xform/sheet/cf-ext/databar-ext-xform.js @@ -39,7 +39,7 @@ class DatabarExtXform extends CompositeXform { direction: BaseXform.toAttribute(model.direction, 'leftToRight'), }); - model.cfvo.forEach((cfvo) => { + model.cfvo.forEach(cfvo => { this.cfvoXform.render(xmlStream, cfvo); }); diff --git a/lib/xlsx/xform/sheet/cf-ext/icon-set-ext-xform.js b/lib/xlsx/xform/sheet/cf-ext/icon-set-ext-xform.js index 318a323ac..ef0e16d30 100644 --- a/lib/xlsx/xform/sheet/cf-ext/icon-set-ext-xform.js +++ b/lib/xlsx/xform/sheet/cf-ext/icon-set-ext-xform.js @@ -26,7 +26,7 @@ class IconSetExtXform extends CompositeXform { custom: BaseXform.toBoolAttribute(model.icons, false), }); - model.cfvo.forEach((cfvo) => { + model.cfvo.forEach(cfvo => { this.cfvoXform.render(xmlStream, cfvo); }); diff --git a/lib/xlsx/xform/sheet/cf/cf-rule-xform.js b/lib/xlsx/xform/sheet/cf/cf-rule-xform.js index 6cb20235c..22b3e44ec 100644 --- a/lib/xlsx/xform/sheet/cf/cf-rule-xform.js +++ b/lib/xlsx/xform/sheet/cf/cf-rule-xform.js @@ -15,7 +15,7 @@ const extIcons = { '5Boxes': true, }; -const getTextFormula = (model) => { +const getTextFormula = model => { if (model.formulae && model.formulae[0]) { return model.formulae[0]; } @@ -38,7 +38,7 @@ const getTextFormula = (model) => { } }; -const getTimePeriodFormula = (model) => { +const getTimePeriodFormula = model => { if (model.formulae && model.formulae[0]) { return model.formulae[0]; } @@ -71,7 +71,7 @@ const getTimePeriodFormula = (model) => { } }; -const opType = (attributes) => { +const opType = attributes => { const {type, operator} = attributes; switch (type) { case 'containsText': @@ -168,7 +168,7 @@ class CfRuleXform extends CompositeXform { operator: model.operator, }); - model.formulae.forEach((formula) => { + model.formulae.forEach(formula => { this.formulaXform.render(xmlStream, formula); }); diff --git a/lib/xlsx/xform/sheet/cf/color-scale-xform.js b/lib/xlsx/xform/sheet/cf/color-scale-xform.js index c636ce11f..66293068c 100644 --- a/lib/xlsx/xform/sheet/cf/color-scale-xform.js +++ b/lib/xlsx/xform/sheet/cf/color-scale-xform.js @@ -20,10 +20,10 @@ class ColorScaleXform extends CompositeXform { render(xmlStream, model) { xmlStream.openNode(this.tag); - model.cfvo.forEach((cfvo) => { + model.cfvo.forEach(cfvo => { this.cfvoXform.render(xmlStream, cfvo); }); - model.color.forEach((color) => { + model.color.forEach(color => { this.colorXform.render(xmlStream, color); }); diff --git a/lib/xlsx/xform/sheet/cf/conditional-formatting-xform.js b/lib/xlsx/xform/sheet/cf/conditional-formatting-xform.js index e48a26145..ae41ec86d 100644 --- a/lib/xlsx/xform/sheet/cf/conditional-formatting-xform.js +++ b/lib/xlsx/xform/sheet/cf/conditional-formatting-xform.js @@ -23,7 +23,7 @@ class ConditionalFormattingXform extends CompositeXform { xmlStream.openNode(this.tag, {sqref: model.ref}); - model.rules.forEach((rule) => { + model.rules.forEach(rule => { if (CfRuleXform.isPrimitive(rule)) { rule.ref = model.ref; this.map.cfRule.render(xmlStream, rule); diff --git a/lib/xlsx/xform/sheet/cf/conditional-formattings-xform.js b/lib/xlsx/xform/sheet/cf/conditional-formattings-xform.js index 7051dc95c..11756865c 100644 --- a/lib/xlsx/xform/sheet/cf/conditional-formattings-xform.js +++ b/lib/xlsx/xform/sheet/cf/conditional-formattings-xform.js @@ -19,9 +19,9 @@ class ConditionalFormattingsXform extends BaseXform { prepare(model, options) { // ensure each rule has a priority value - let nextPriority = model.reduce((p, cf) => Math.max(p, ...cf.rules.map((rule) => rule.priority || 0)), 1); - model.forEach((cf) => { - cf.rules.forEach((rule) => { + let nextPriority = model.reduce((p, cf) => Math.max(p, ...cf.rules.map(rule => rule.priority || 0)), 1); + model.forEach(cf => { + cf.rules.forEach(rule => { if (!rule.priority) { rule.priority = nextPriority++; } @@ -34,7 +34,7 @@ class ConditionalFormattingsXform extends BaseXform { } render(xmlStream, model) { - model.forEach((cf) => { + model.forEach(cf => { this.cfXform.render(xmlStream, cf); }); } @@ -75,8 +75,8 @@ class ConditionalFormattingsXform extends BaseXform { } reconcile(model, options) { - model.forEach((cf) => { - cf.rules.forEach((rule) => { + model.forEach(cf => { + cf.rules.forEach(rule => { if (rule.dxfId !== undefined) { rule.style = options.styles.getDxfStyle(rule.dxfId); delete rule.dxfId; diff --git a/lib/xlsx/xform/sheet/cf/databar-xform.js b/lib/xlsx/xform/sheet/cf/databar-xform.js index 7f24c431a..3cc13b611 100644 --- a/lib/xlsx/xform/sheet/cf/databar-xform.js +++ b/lib/xlsx/xform/sheet/cf/databar-xform.js @@ -20,7 +20,7 @@ class DatabarXform extends CompositeXform { render(xmlStream, model) { xmlStream.openNode(this.tag); - model.cfvo.forEach((cfvo) => { + model.cfvo.forEach(cfvo => { this.cfvoXform.render(xmlStream, cfvo); }); this.colorXform.render(xmlStream, model.color); diff --git a/lib/xlsx/xform/sheet/cf/icon-set-xform.js b/lib/xlsx/xform/sheet/cf/icon-set-xform.js index d529bc605..cd7d4abfc 100644 --- a/lib/xlsx/xform/sheet/cf/icon-set-xform.js +++ b/lib/xlsx/xform/sheet/cf/icon-set-xform.js @@ -23,7 +23,7 @@ class IconSetXform extends CompositeXform { showValue: BaseXform.toBoolAttribute(model.showValue, true), }); - model.cfvo.forEach((cfvo) => { + model.cfvo.forEach(cfvo => { this.cfvoXform.render(xmlStream, cfvo); }); diff --git a/lib/xlsx/xform/sheet/data-validations-xform.js b/lib/xlsx/xform/sheet/data-validations-xform.js index 1f2c82b68..df69f7dc1 100644 --- a/lib/xlsx/xform/sheet/data-validations-xform.js +++ b/lib/xlsx/xform/sheet/data-validations-xform.js @@ -49,7 +49,7 @@ function optimiseDataValidations(model) { return true; }; return dvList - .map((dv) => { + .map(dv => { if (!dv.marked) { const addr = colCache.decodeAddress(dv.address); @@ -104,7 +104,7 @@ class DataValidationsXform extends BaseXform { if (optimizedModel.length) { xmlStream.openNode('dataValidations', {count: optimizedModel.length}); - optimizedModel.forEach((value) => { + optimizedModel.forEach(value => { xmlStream.openNode('dataValidation'); if (value.type !== 'any') { @@ -216,10 +216,10 @@ class DataValidationsXform extends BaseXform { } // The four known cases: 1. E4:L9 N4:U9 2.E4 L9 3. N4:U9 4. E4 const list = this._address.split(/\s+/g) || []; - list.forEach((addr) => { + list.forEach(addr => { if (addr.includes(':')) { const range = new Range(addr); - range.forEachAddress((address) => { + range.forEachAddress(address => { this.model[address] = this._dataValidation; }); } else { diff --git a/lib/xlsx/xform/sheet/merges.js b/lib/xlsx/xform/sheet/merges.js index 0868e8ff2..c885375b1 100644 --- a/lib/xlsx/xform/sheet/merges.js +++ b/lib/xlsx/xform/sheet/merges.js @@ -21,12 +21,12 @@ class Merges { } get mergeCells() { - return _.map(this.merges, (merge) => merge.range); + return _.map(this.merges, merge => merge.range); } reconcile(mergeCells, rows) { // reconcile merge list with merge cells - _.each(mergeCells, (merge) => { + _.each(mergeCells, merge => { const dimensions = colCache.decode(merge); for (let i = dimensions.top; i <= dimensions.bottom; i++) { const row = rows[i - 1]; diff --git a/lib/xlsx/xform/sheet/outline-properties-xform.js b/lib/xlsx/xform/sheet/outline-properties-xform.js index bcd9d91cd..b494c2490 100644 --- a/lib/xlsx/xform/sheet/outline-properties-xform.js +++ b/lib/xlsx/xform/sheet/outline-properties-xform.js @@ -1,6 +1,6 @@ const BaseXform = require('../base-xform'); -const isDefined = (attr) => typeof attr !== 'undefined'; +const isDefined = attr => typeof attr !== 'undefined'; class OutlinePropertiesXform extends BaseXform { get tag() { diff --git a/lib/xlsx/xform/sheet/page-margins-xform.js b/lib/xlsx/xform/sheet/page-margins-xform.js index a13a083e8..4b221e181 100644 --- a/lib/xlsx/xform/sheet/page-margins-xform.js +++ b/lib/xlsx/xform/sheet/page-margins-xform.js @@ -16,7 +16,7 @@ class PageMarginsXform extends BaseXform { header: model.header, footer: model.footer, }; - if (_.some(attributes, (value) => value !== undefined)) { + if (_.some(attributes, value => value !== undefined)) { xmlStream.leafNode(this.tag, attributes); } } diff --git a/lib/xlsx/xform/sheet/page-setup-xform.js b/lib/xlsx/xform/sheet/page-setup-xform.js index 5e6ba0544..034fe69b7 100644 --- a/lib/xlsx/xform/sheet/page-setup-xform.js +++ b/lib/xlsx/xform/sheet/page-setup-xform.js @@ -60,7 +60,7 @@ class PageSetupXform extends BaseXform { usePrinterDefaults: booleanToXml(model.usePrinterDefaults), copies: model.copies, }; - if (_.some(attributes, (value) => value !== undefined)) { + if (_.some(attributes, value => value !== undefined)) { xmlStream.leafNode(this.tag, attributes); } } diff --git a/lib/xlsx/xform/sheet/print-options-xform.js b/lib/xlsx/xform/sheet/print-options-xform.js index 22113a99a..d9a7d087a 100644 --- a/lib/xlsx/xform/sheet/print-options-xform.js +++ b/lib/xlsx/xform/sheet/print-options-xform.js @@ -18,7 +18,7 @@ class PrintOptionsXform extends BaseXform { horizontalCentered: booleanToXml(model.horizontalCentered), verticalCentered: booleanToXml(model.verticalCentered), }; - if (_.some(attributes, (value) => value !== undefined)) { + if (_.some(attributes, value => value !== undefined)) { xmlStream.leafNode(this.tag, attributes); } } diff --git a/lib/xlsx/xform/sheet/row-breaks-xform.js b/lib/xlsx/xform/sheet/row-breaks-xform.js index e8c907765..cc01008a8 100644 --- a/lib/xlsx/xform/sheet/row-breaks-xform.js +++ b/lib/xlsx/xform/sheet/row-breaks-xform.js @@ -25,7 +25,7 @@ class RowBreaksXform extends ListXform { } const {childXform} = this; - model.forEach((childModel) => { + model.forEach(childModel => { childXform.render(xmlStream, childModel); }); diff --git a/lib/xlsx/xform/sheet/row-xform.js b/lib/xlsx/xform/sheet/row-xform.js index 5a142af38..c278839f1 100644 --- a/lib/xlsx/xform/sheet/row-xform.js +++ b/lib/xlsx/xform/sheet/row-xform.js @@ -22,7 +22,7 @@ class RowXform extends BaseXform { model.styleId = styleId; } const cellXform = this.map.c; - model.cells.forEach((cellModel) => { + model.cells.forEach(cellModel => { cellXform.prepare(cellModel, options); }); } @@ -53,7 +53,7 @@ class RowXform extends BaseXform { } const cellXform = this.map.c; - model.cells.forEach((cellModel) => { + model.cells.forEach(cellModel => { cellXform.render(xmlStream, cellModel, options); }); @@ -67,7 +67,7 @@ class RowXform extends BaseXform { } if (node.name === 'row') { this.numRowsSeen += 1; - const spans = node.attributes.spans ? node.attributes.spans.split(':').map((span) => parseInt(span, 10)) : [undefined, undefined]; + const spans = node.attributes.spans ? node.attributes.spans.split(':').map(span => parseInt(span, 10)) : [undefined, undefined]; const model = (this.model = { number: parseInt(node.attributes.r, 10), min: spans[0], @@ -130,7 +130,7 @@ class RowXform extends BaseXform { } const cellXform = this.map.c; - model.cells.forEach((cellModel) => { + model.cells.forEach(cellModel => { cellXform.reconcile(cellModel, options); }); } diff --git a/lib/xlsx/xform/sheet/sheet-format-properties-xform.js b/lib/xlsx/xform/sheet/sheet-format-properties-xform.js index 12b3ae584..7ffae26df 100644 --- a/lib/xlsx/xform/sheet/sheet-format-properties-xform.js +++ b/lib/xlsx/xform/sheet/sheet-format-properties-xform.js @@ -23,7 +23,7 @@ class SheetFormatPropertiesXform extends BaseXform { attributes.customHeight = '1'; } - if (_.some(attributes, (value) => value !== undefined)) { + if (_.some(attributes, value => value !== undefined)) { xmlStream.leafNode('sheetFormatPr', attributes); } } diff --git a/lib/xlsx/xform/sheet/sheet-protection-xform.js b/lib/xlsx/xform/sheet/sheet-protection-xform.js index 5ce842ba6..17722502a 100644 --- a/lib/xlsx/xform/sheet/sheet-protection-xform.js +++ b/lib/xlsx/xform/sheet/sheet-protection-xform.js @@ -40,7 +40,7 @@ class SheetProtectionXform extends BaseXform { attributes.objects = booleanToXml(model.objects === false, '1'); attributes.scenarios = booleanToXml(model.scenarios === false, '1'); } - if (_.some(attributes, (value) => value !== undefined)) { + if (_.some(attributes, value => value !== undefined)) { xmlStream.leafNode(this.tag, attributes); } } diff --git a/lib/xlsx/xform/sheet/worksheet-xform.js b/lib/xlsx/xform/sheet/worksheet-xform.js index 2990c838f..bf68ab725 100644 --- a/lib/xlsx/xform/sheet/worksheet-xform.js +++ b/lib/xlsx/xform/sheet/worksheet-xform.js @@ -32,7 +32,7 @@ const ConditionalFormattingsXform = require('./cf/conditional-formattings-xform' const ExtListXform = require('./ext-lst-xform'); const mergeRule = (rule, extRule) => { - Object.keys(extRule).forEach((key) => { + Object.keys(extRule).forEach(key => { const value = rule[key]; const extValue = extRule[key]; if (value === undefined && extValue !== undefined) { @@ -55,9 +55,9 @@ const mergeConditionalFormattings = (model, extModel) => { // index model rules by x14Id const cfMap = {}; const ruleMap = {}; - model.forEach((cf) => { + model.forEach(cf => { cfMap[cf.ref] = cf; - cf.rules.forEach((rule) => { + cf.rules.forEach(rule => { const {x14Id} = rule; if (x14Id) { ruleMap[x14Id] = rule; @@ -65,8 +65,8 @@ const mergeConditionalFormattings = (model, extModel) => { }); }); - extModel.forEach((extCf) => { - extCf.rules.forEach((extRule) => { + extModel.forEach(extCf => { + extCf.rules.forEach(extRule => { const rule = ruleMap[extRule.x14Id]; if (rule) { // merge with matching rule @@ -144,7 +144,7 @@ class WorkSheetXform extends BaseXform { return `rId${r.length + 1}`; } - model.hyperlinks.forEach((hyperlink) => { + model.hyperlinks.forEach(hyperlink => { const rId = nextRid(rels); hyperlink.rId = rId; rels.push({ @@ -170,7 +170,7 @@ class WorkSheetXform extends BaseXform { }; rels.push(vmlDrawing); - model.comments.forEach((item) => { + model.comments.forEach(item => { item.refAddress = colCache.decodeAddress(item.ref); }); @@ -182,7 +182,7 @@ class WorkSheetXform extends BaseXform { const drawingRelsHash = []; let bookImage; - model.media.forEach((medium) => { + model.media.forEach(medium => { if (medium.type === 'background') { const rId = nextRid(rels); bookImage = options.media[medium.imageId]; @@ -249,7 +249,7 @@ class WorkSheetXform extends BaseXform { }); // prepare tables - model.tables.forEach((table) => { + model.tables.forEach(table => { // relationships const rId = nextRid(rels); table.rId = rId; @@ -260,7 +260,7 @@ class WorkSheetXform extends BaseXform { }); // dynamic styles - table.columns.forEach((column) => { + table.columns.forEach(column => { const {style} = column; if (style) { column.dxfId = options.styles.addDxfStyle(style); @@ -334,7 +334,7 @@ class WorkSheetXform extends BaseXform { if (model.rels) { // add a node for each comment - model.rels.forEach((rel) => { + model.rels.forEach(rel => { if (rel.Type === RelType.VmlDrawing) { xmlStream.leafNode('legacyDrawing', {'r:id': rel.Id}); } @@ -351,7 +351,7 @@ class WorkSheetXform extends BaseXform { } if (node.name === 'worksheet') { - _.each(this.map, (xform) => { + _.each(this.map, xform => { xform.reset(); }); return true; @@ -460,7 +460,7 @@ class WorkSheetXform extends BaseXform { // compact the rows and cells model.rows = (model.rows && model.rows.filter(Boolean)) || []; - model.rows.forEach((row) => { + model.rows.forEach(row => { row.cells = (row.cells && row.cells.filter(Boolean)) || []; }); @@ -475,7 +475,7 @@ class WorkSheetXform extends BaseXform { if (match) { const drawingName = match[1]; const drawing = options.drawings[drawingName]; - drawing.anchors.forEach((anchor) => { + drawing.anchors.forEach(anchor => { if (anchor.medium) { const image = { type: 'image', @@ -501,7 +501,7 @@ class WorkSheetXform extends BaseXform { } } - model.tables = (model.tables || []).map((tablePart) => { + model.tables = (model.tables || []).map(tablePart => { const rel = rels[tablePart.rId]; return options.tables[rel.Target]; }); diff --git a/lib/xlsx/xform/static-xform.js b/lib/xlsx/xform/static-xform.js index 5c52ac1a4..1bb1ef6fa 100644 --- a/lib/xlsx/xform/static-xform.js +++ b/lib/xlsx/xform/static-xform.js @@ -13,7 +13,7 @@ const XmlStream = require('../../utils/xml-stream'); function build(xmlStream, model) { xmlStream.openNode(model.tag, model.$); if (model.c) { - model.c.forEach((child) => { + model.c.forEach(child => { build(xmlStream, child); }); } diff --git a/lib/xlsx/xform/strings/phonetic-text-xform.js b/lib/xlsx/xform/strings/phonetic-text-xform.js index d8b254573..fdd20588e 100644 --- a/lib/xlsx/xform/strings/phonetic-text-xform.js +++ b/lib/xlsx/xform/strings/phonetic-text-xform.js @@ -28,7 +28,7 @@ class PhoneticTextXform extends BaseXform { }); if (model && model.hasOwnProperty('richText') && model.richText) { const {r} = this.map; - model.richText.forEach((text) => { + model.richText.forEach(text => { r.render(xmlStream, text); }); } else if (model) { diff --git a/lib/xlsx/xform/strings/shared-string-xform.js b/lib/xlsx/xform/strings/shared-string-xform.js index 2ba7c5b3c..e23cfde7f 100644 --- a/lib/xlsx/xform/strings/shared-string-xform.js +++ b/lib/xlsx/xform/strings/shared-string-xform.js @@ -32,7 +32,7 @@ class SharedStringXform extends BaseXform { xmlStream.openNode(this.tag); if (model && model.hasOwnProperty('richText') && model.richText) { if (model.richText.length) { - model.richText.forEach((text) => { + model.richText.forEach(text => { this.map.r.render(xmlStream, text); }); } else { diff --git a/lib/xlsx/xform/strings/shared-strings-xform.js b/lib/xlsx/xform/strings/shared-strings-xform.js index 79ccea7a6..0777b68d0 100644 --- a/lib/xlsx/xform/strings/shared-strings-xform.js +++ b/lib/xlsx/xform/strings/shared-strings-xform.js @@ -77,7 +77,7 @@ class SharedStringsXform extends BaseXform { }); const sx = this.sharedStringXform; - model.values.forEach((sharedString) => { + model.values.forEach(sharedString => { sx.render(xmlStream, sharedString); }); xmlStream.closeNode(); diff --git a/lib/xlsx/xform/style/fill-xform.js b/lib/xlsx/xform/style/fill-xform.js index c25238754..007d03115 100644 --- a/lib/xlsx/xform/style/fill-xform.js +++ b/lib/xlsx/xform/style/fill-xform.js @@ -191,7 +191,7 @@ class GradientFillXform extends BaseXform { } const stopXform = this.map.stop; - model.stops.forEach((stopModel) => { + model.stops.forEach(stopModel => { stopXform.render(xmlStream, stopModel); }); diff --git a/lib/xlsx/xform/style/styles-xform.js b/lib/xlsx/xform/style/styles-xform.js index 78b39be25..6380c12f7 100644 --- a/lib/xlsx/xform/style/styles-xform.js +++ b/lib/xlsx/xform/style/styles-xform.js @@ -98,7 +98,7 @@ class StylesXform extends BaseXform { // model has been built by style manager role (contains xml) if (model.numFmts && model.numFmts.length) { xmlStream.openNode('numFmts', {count: model.numFmts.length}); - model.numFmts.forEach((numFmtXml) => { + model.numFmts.forEach(numFmtXml => { xmlStream.writeXml(numFmtXml); }); xmlStream.closeNode(); @@ -109,19 +109,19 @@ class StylesXform extends BaseXform { this._addFont({size: 11, color: {theme: 1}, name: 'Calibri', family: 2, scheme: 'minor'}); } xmlStream.openNode('fonts', {count: model.fonts.length, 'x14ac:knownFonts': 1}); - model.fonts.forEach((fontXml) => { + model.fonts.forEach(fontXml => { xmlStream.writeXml(fontXml); }); xmlStream.closeNode(); xmlStream.openNode('fills', {count: model.fills.length}); - model.fills.forEach((fillXml) => { + model.fills.forEach(fillXml => { xmlStream.writeXml(fillXml); }); xmlStream.closeNode(); xmlStream.openNode('borders', {count: model.borders.length}); - model.borders.forEach((borderXml) => { + model.borders.forEach(borderXml => { xmlStream.writeXml(borderXml); }); xmlStream.closeNode(); @@ -129,7 +129,7 @@ class StylesXform extends BaseXform { this.map.cellStyleXfs.render(xmlStream, [{numFmtId: 0, fontId: 0, fillId: 0, borderId: 0, xfId: 0}]); xmlStream.openNode('cellXfs', {count: model.styles.length}); - model.styles.forEach((styleXml) => { + model.styles.forEach(styleXml => { xmlStream.writeXml(styleXml); }); xmlStream.closeNode(); @@ -206,7 +206,7 @@ class StylesXform extends BaseXform { }; if (this.model.numFmts) { const numFmtIndex = this.index.numFmt; - this.model.numFmts.forEach((numFmt) => { + this.model.numFmts.forEach(numFmt => { numFmtIndex[numFmt.id] = numFmt.formatCode; }); } diff --git a/lib/xlsx/xform/table/auto-filter-xform.js b/lib/xlsx/xform/table/auto-filter-xform.js index 837612915..0c0230b83 100644 --- a/lib/xlsx/xform/table/auto-filter-xform.js +++ b/lib/xlsx/xform/table/auto-filter-xform.js @@ -24,7 +24,7 @@ class AutoFilterXform extends BaseXform { render(xmlStream, model) { xmlStream.openNode(this.tag, {ref: model.autoFilterRef}); - model.columns.forEach((column) => { + model.columns.forEach(column => { this.map.filterColumn.render(xmlStream, column); }); diff --git a/lib/xlsx/xform/table/table-xform.js b/lib/xlsx/xform/table/table-xform.js index 0c2f4d4e3..002fbda92 100644 --- a/lib/xlsx/xform/table/table-xform.js +++ b/lib/xlsx/xform/table/table-xform.js @@ -111,7 +111,7 @@ class TableXform extends BaseXform { reconcile(model, options) { // fetch the dfxs from styles - model.columns.forEach((column) => { + model.columns.forEach(column => { if (column.dxfId !== undefined) { column.style = options.styles.getDxfStyle(column.dxfId); } diff --git a/lib/xlsx/xlsx.js b/lib/xlsx/xlsx.js index 9138dba33..c9c9d411d 100644 --- a/lib/xlsx/xlsx.js +++ b/lib/xlsx/xlsx.js @@ -88,7 +88,7 @@ class XLSX { media: model.media, mediaIndex: model.mediaIndex, }; - Object.keys(model.drawings).forEach((name) => { + Object.keys(model.drawings).forEach(name => { const drawing = model.drawings[name]; const drawingRel = model.drawingRels[name]; if (drawingRel) { @@ -96,7 +96,7 @@ class XLSX { o[rel.Id] = rel; return o; }, {}); - (drawing.anchors || []).forEach((anchor) => { + (drawing.anchors || []).forEach(anchor => { const hyperlinks = anchor.picture && anchor.picture.hyperlinks; if (hyperlinks && drawingOptions.rels[hyperlinks.rId]) { hyperlinks.hyperlink = drawingOptions.rels[hyperlinks.rId].Target; @@ -111,7 +111,7 @@ class XLSX { const tableOptions = { styles: model.styles, }; - Object.values(model.tables).forEach((table) => { + Object.values(model.tables).forEach(table => { tableXform.reconcile(table, tableOptions); }); @@ -126,7 +126,7 @@ class XLSX { tables: model.tables, vmlDrawings: model.vmlDrawings, }; - model.worksheets.forEach((worksheet) => { + model.worksheets.forEach(worksheet => { worksheet.relationships = model.worksheetRels[worksheet.sheetNo]; worksheetXform.reconcile(worksheet, sheetOptions); }); @@ -191,7 +191,7 @@ class XLSX { model.media.push(medium); resolve(); }); - entry.on('error', (error) => { + entry.on('error', error => { reject(error); }); entry.pipe(streamBuf); @@ -401,7 +401,7 @@ class XLSX { async addMedia(zip, model) { await Promise.all( - model.media.map(async (medium) => { + model.media.map(async medium => { if (medium.type === 'image') { const filename = `xl/media/${medium.name}.${medium.extension}`; if (medium.filename) { @@ -426,7 +426,7 @@ class XLSX { const drawingXform = new DrawingXform(); const relsXform = new RelationshipsXform(); - model.worksheets.forEach((worksheet) => { + model.worksheets.forEach(worksheet => { const {drawing} = worksheet; if (drawing) { drawingXform.prepare(drawing, {}); @@ -442,9 +442,9 @@ class XLSX { addTables(zip, model) { const tableXform = new TableXform(); - model.worksheets.forEach((worksheet) => { + model.worksheets.forEach(worksheet => { const {tables} = worksheet; - tables.forEach((table) => { + tables.forEach(table => { tableXform.prepare(table, {}); const tableXml = tableXform.toXml(table); zip.append(tableXml, {name: `xl/tables/${table.target}`}); @@ -471,7 +471,7 @@ class XLSX { async addThemes(zip, model) { const themes = model.themes || {theme1: theme1Xml}; - Object.keys(themes).forEach((name) => { + Object.keys(themes).forEach(name => { const xml = themes[name]; const path = `xl/theme/${name}.xml`; zip.append(xml, {name: path}); @@ -497,7 +497,7 @@ class XLSX { if (model.sharedStrings.count) { relationships.push({Id: `rId${count++}`, Type: XLSX.RelType.SharedStrings, Target: 'sharedStrings.xml'}); } - model.worksheets.forEach((worksheet) => { + model.worksheets.forEach(worksheet => { worksheet.rId = `rId${count++}`; relationships.push({Id: worksheet.rId, Type: XLSX.RelType.Worksheet, Target: `worksheets/sheet${worksheet.id}.xml`}); }); @@ -532,7 +532,7 @@ class XLSX { const vmlNotesXform = new VmlNotesXform(); // write sheets - model.worksheets.forEach((worksheet) => { + model.worksheets.forEach(worksheet => { let xmlStream = new XmlStream(); worksheetXform.render(xmlStream, worksheet); zip.append(xmlStream.xml, {name: `xl/worksheets/sheet${worksheet.id}.xml`}); @@ -598,9 +598,9 @@ class XLSX { worksheetOptions.commentRefs = model.commentRefs = []; let tableCount = 0; model.tables = []; - model.worksheets.forEach((worksheet) => { + model.worksheets.forEach(worksheet => { // assign unique filenames to tables - worksheet.tables.forEach((table) => { + worksheet.tables.forEach(table => { tableCount++; table.target = `table${tableCount}.xml`; table.id = tableCount; @@ -643,7 +643,7 @@ class XLSX { stream.on('finish', () => { resolve(); }); - stream.on('error', (error) => { + stream.on('error', error => { reject(error); }); diff --git a/spec/browser/exceljs.spec.js b/spec/browser/exceljs.spec.js index ec53d130c..ce7c21e0a 100644 --- a/spec/browser/exceljs.spec.js +++ b/spec/browser/exceljs.spec.js @@ -13,7 +13,7 @@ function unexpectedError(done) { } describe('ExcelJS', () => { - it('should read and write xlsx via binary buffer', (done) => { + it('should read and write xlsx via binary buffer', done => { const wb = new ExcelJS.Workbook(); const ws = wb.addWorksheet('blort'); @@ -22,7 +22,7 @@ describe('ExcelJS', () => { wb.xlsx .writeBuffer() - .then((buffer) => { + .then(buffer => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.load(buffer).then(() => { const ws2 = wb2.getWorksheet('blort'); @@ -33,12 +33,12 @@ describe('ExcelJS', () => { done(); }); }) - .catch((error) => { + .catch(error => { throw error; }) .catch(unexpectedError(done)); }); - it('should read and write xlsx via base64 buffer', (done) => { + it('should read and write xlsx via base64 buffer', done => { const options = { base64: true, }; @@ -50,7 +50,7 @@ describe('ExcelJS', () => { wb.xlsx .writeBuffer(options) - .then((buffer) => { + .then(buffer => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.load(buffer.toString('base64'), options).then(() => { const ws2 = wb2.getWorksheet('blort'); @@ -61,12 +61,12 @@ describe('ExcelJS', () => { done(); }); }) - .catch((error) => { + .catch(error => { throw error; }) .catch(unexpectedError(done)); }); - it('should write csv via buffer', (done) => { + it('should write csv via buffer', done => { const wb = new ExcelJS.Workbook(); const ws = wb.addWorksheet('blort'); @@ -77,13 +77,13 @@ describe('ExcelJS', () => { wb.csv .writeBuffer() - .then((buffer) => { + .then(buffer => { expect(buffer.toString()).toEqual( '"Hello, World!",What time is it?\n7,12pm' ); done(); }) - .catch((error) => { + .catch(error => { throw error; }) .catch(unexpectedError(done)); diff --git a/spec/integration/issues/issue-1328-xlsx-worksheet-reader-date.spec.js b/spec/integration/issues/issue-1328-xlsx-worksheet-reader-date.spec.js index 4dcd50b3d..acfa4da74 100644 --- a/spec/integration/issues/issue-1328-xlsx-worksheet-reader-date.spec.js +++ b/spec/integration/issues/issue-1328-xlsx-worksheet-reader-date.spec.js @@ -17,8 +17,8 @@ describe('github issues: Date field with cache style', () => { } ); workbookReader.read(); - workbookReader.on('worksheet', (worksheet) => - worksheet.on('row', (row) => rows.push(row.values[1])) + workbookReader.on('worksheet', worksheet => + worksheet.on('row', row => rows.push(row.values[1])) ); workbookReader.on('end', resolve); workbookReader.on('error', reject); diff --git a/spec/integration/issues/issue-219-1904-dates.spec.js b/spec/integration/issues/issue-219-1904-dates.spec.js index 5a339a1d4..f9861063c 100644 --- a/spec/integration/issues/issue-219-1904-dates.spec.js +++ b/spec/integration/issues/issue-219-1904-dates.spec.js @@ -27,7 +27,7 @@ describe('github issues', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { expect(wb2.properties.date1904).to.equal(true); const ws2 = wb2.getWorksheet('Sheet1'); diff --git a/spec/integration/issues/issue-234-vertical-tab-char.spec.js b/spec/integration/issues/issue-234-vertical-tab-char.spec.js index f4bb90d42..c1e2cbd46 100644 --- a/spec/integration/issues/issue-234-vertical-tab-char.spec.js +++ b/spec/integration/issues/issue-234-vertical-tab-char.spec.js @@ -20,7 +20,7 @@ describe('github issues', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('Sheet1'); expect(ws2.getCell('A1').value).to.equal('Hello, World!'); expect(ws2.getCell('A2').value).to.equal('Hello, World!'); diff --git a/spec/integration/issues/issue-257-sheet-order.spec.js b/spec/integration/issues/issue-257-sheet-order.spec.js index 44c2ee1b6..cb3e4556e 100644 --- a/spec/integration/issues/issue-257-sheet-order.spec.js +++ b/spec/integration/issues/issue-257-sheet-order.spec.js @@ -6,7 +6,7 @@ describe('github issues', () => { return wb.xlsx .readFile('./spec/integration/data/test-issue-257.xlsx') .then(() => { - expect(wb.worksheets.map((ws) => ws.name)).to.deep.equal([ + expect(wb.worksheets.map(ws => ws.name)).to.deep.equal([ 'First', 'Second', ]); diff --git a/spec/integration/issues/issue-275-hyperlink-query-param.spec.js b/spec/integration/issues/issue-275-hyperlink-query-param.spec.js index 0d52695d6..662414ae4 100644 --- a/spec/integration/issues/issue-275-hyperlink-query-param.spec.js +++ b/spec/integration/issues/issue-275-hyperlink-query-param.spec.js @@ -27,7 +27,7 @@ describe('github issues', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('Sheet1'); expect(ws2.getCell('A1').value).to.deep.equal(hyperlink); }); diff --git a/spec/integration/issues/issue-623-borders-for-merged-cell.spec.js b/spec/integration/issues/issue-623-borders-for-merged-cell.spec.js index efce01008..073c87266 100644 --- a/spec/integration/issues/issue-623-borders-for-merged-cell.spec.js +++ b/spec/integration/issues/issue-623-borders-for-merged-cell.spec.js @@ -20,7 +20,7 @@ describe('github issues', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { // written file should have same borders const worksheet = wb2.getWorksheet(1); checkBorder(worksheet.getCell('B2'), ['left', 'top']); @@ -32,7 +32,7 @@ describe('github issues', () => { }); function checkBorder(cell, borders) { - borders.forEach((b) => { + borders.forEach(b => { expect(cell.style.border).to.have.property(b); }); } diff --git a/spec/integration/issues/issue-703-speciel-cell-file.spec.js b/spec/integration/issues/issue-703-speciel-cell-file.spec.js index 95267d339..cb7ead21c 100644 --- a/spec/integration/issues/issue-703-speciel-cell-file.spec.js +++ b/spec/integration/issues/issue-703-speciel-cell-file.spec.js @@ -32,7 +32,7 @@ describe('github issues', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('Sheet1'); for (let i = 0; i < specialValues.length; i++) { const value = specialValues[i]; diff --git a/spec/integration/issues/issue-991-csv-read-dates.spec.js b/spec/integration/issues/issue-991-csv-read-dates.spec.js index 4b6236568..e2746c7b5 100644 --- a/spec/integration/issues/issue-991-csv-read-dates.spec.js +++ b/spec/integration/issues/issue-991-csv-read-dates.spec.js @@ -5,7 +5,7 @@ describe('github issues', () => { const wb = new ExcelJS.Workbook(); return wb.csv .readFile('./spec/integration/data/test-issue-991.csv') - .then((worksheet) => { + .then(worksheet => { expect(worksheet.getCell('A1').value.toString()).to.equal( new Date('2019-11-04T00:00:00').toString() ); diff --git a/spec/integration/pr/pr-896/test-pr-896.spec.js b/spec/integration/pr/pr-896/test-pr-896.spec.js index 89e778917..ee92bf20f 100644 --- a/spec/integration/pr/pr-896/test-pr-896.spec.js +++ b/spec/integration/pr/pr-896/test-pr-896.spec.js @@ -53,7 +53,7 @@ describe('pr related issues', () => { const wb2 = new Excel.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('sheet1'); expect(ws2).to.not.be.undefined(); expect(ws2.getCell('A1').value).to.deep.equal(TEST_VALUE); diff --git a/spec/integration/pr/test-pr-1431.spec.js b/spec/integration/pr/test-pr-1431.spec.js index 15fa9bb43..5c3708f92 100644 --- a/spec/integration/pr/test-pr-1431.spec.js +++ b/spec/integration/pr/test-pr-1431.spec.js @@ -35,8 +35,8 @@ describe('github issues', () => { } ); - workbookReader.on('worksheet', (worksheet) => - worksheet.on('row', (row) => { + workbookReader.on('worksheet', worksheet => + worksheet.on('row', row => { expect(row.values[1]).to.eql(rowData[0]); expect(row.values[2]).to.equal(rowData[1]); diff --git a/spec/integration/pr/test-pr-896.spec.js b/spec/integration/pr/test-pr-896.spec.js index 4d00ff1a1..7870c15c0 100644 --- a/spec/integration/pr/test-pr-896.spec.js +++ b/spec/integration/pr/test-pr-896.spec.js @@ -19,7 +19,7 @@ describe('pr related issues', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('foo'); expect(ws2.getCell('A1').value).to.equal(' leading'); expect(ws2.getCell('A1').note).to.equal(' leading'); @@ -43,7 +43,7 @@ describe('pr related issues', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('foo'); expect(ws2.getCell('A1').value).to.equal('Hello,\nWorld!'); expect(ws2.getCell('A1').note).to.equal('Later,\nAlligator!'); diff --git a/spec/integration/workbook-xlsx-reader.spec.js b/spec/integration/workbook-xlsx-reader.spec.js index 525731029..f6ad0a773 100644 --- a/spec/integration/workbook-xlsx-reader.spec.js +++ b/spec/integration/workbook-xlsx-reader.spec.js @@ -31,7 +31,7 @@ describe('WorkbookReader', () => { () => { throw new Error('Promise unexpectedly fulfilled'); }, - (err) => { + err => { expect(err.message).to.equal('Max row count (10) exceeded'); } ); @@ -46,7 +46,7 @@ describe('WorkbookReader', () => { () => { throw new Error('Promise unexpectedly fulfilled'); }, - (err) => { + err => { expect(err.message).to.equal('Max row count (100) exceeded'); } ); @@ -73,7 +73,7 @@ describe('WorkbookReader', () => { () => { throw new Error('Promise unexpectedly fulfilled'); }, - (err) => { + err => { expect(err.message).to.equal('Max column count (15) exceeded'); } ); @@ -88,7 +88,7 @@ describe('WorkbookReader', () => { () => { throw new Error('Promise unexpectedly fulfilled'); }, - (err) => { + err => { expect(err.message).to.equal('Max column count (10) exceeded'); } ); @@ -117,7 +117,7 @@ describe('WorkbookReader', () => { () => { throw new Error('Promise unexpectedly fulfilled'); }, - (err) => { + err => { expect(err.message).to.equal('Max row count (10) exceeded'); } ); @@ -274,7 +274,7 @@ describe('WorkbookReader', () => { () => { throw new Error('Promise unexpectedly fulfilled'); }, - (err) => { + err => { expect(err.message).to.equal( '3:1: text data outside of root node.' ); @@ -310,14 +310,14 @@ describe('WorkbookReader', () => { describe('with image`s tl anchor', () => { it('Should integer part of col equals nativeCol', function() { - this.worksheet.getImages().forEach((image) => { + this.worksheet.getImages().forEach(image => { expect(Math.floor(image.range.tl.col)).to.equal( image.range.tl.nativeCol ); }); }); it('Should integer part of row equals nativeRow', function() { - this.worksheet.getImages().forEach((image) => { + this.worksheet.getImages().forEach(image => { expect(Math.floor(image.range.tl.row)).to.equal( image.range.tl.nativeRow ); @@ -326,7 +326,7 @@ describe('WorkbookReader', () => { it('Should anchor width equals to column width when custom', function() { const ws = this.worksheet; - ws.getImages().forEach((image) => { + ws.getImages().forEach(image => { const col = ws.getColumn(image.range.tl.nativeCol + 1); if (col.isCustomWidth) { @@ -341,7 +341,7 @@ describe('WorkbookReader', () => { it('Should anchor height equals to row height', function() { const ws = this.worksheet; - ws.getImages().forEach((image) => { + ws.getImages().forEach(image => { const row = ws.getRow(image.range.tl.nativeRow + 1); if (row.height) { @@ -357,14 +357,14 @@ describe('WorkbookReader', () => { describe('with image`s br anchor', () => { it('Should integer part of col equals nativeCol', function() { - this.worksheet.getImages().forEach((image) => { + this.worksheet.getImages().forEach(image => { expect(Math.floor(image.range.br.col)).to.equal( image.range.br.nativeCol ); }); }); it('Should integer part of row equals nativeRow', function() { - this.worksheet.getImages().forEach((image) => { + this.worksheet.getImages().forEach(image => { expect(Math.floor(image.range.br.row)).to.equal( image.range.br.nativeRow ); @@ -373,7 +373,7 @@ describe('WorkbookReader', () => { it('Should anchor width equals to column width when custom', function() { const ws = this.worksheet; - ws.getImages().forEach((image) => { + ws.getImages().forEach(image => { const col = ws.getColumn(image.range.br.nativeCol + 1); if (col.isCustomWidth) { @@ -388,7 +388,7 @@ describe('WorkbookReader', () => { it('Should anchor height equals to row height', function() { const ws = this.worksheet; - ws.getImages().forEach((image) => { + ws.getImages().forEach(image => { const row = ws.getRow(image.range.br.nativeRow + 1); if (row.height) { diff --git a/spec/integration/workbook-xlsx-writer/workbook-xlsx-writer.spec.js b/spec/integration/workbook-xlsx-writer/workbook-xlsx-writer.spec.js index f35025375..6feb93aca 100644 --- a/spec/integration/workbook-xlsx-writer/workbook-xlsx-writer.spec.js +++ b/spec/integration/workbook-xlsx-writer/workbook-xlsx-writer.spec.js @@ -36,7 +36,7 @@ describe('WorkbookWriter', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { testUtils.checkTestBook(wb2, 'xlsx'); }); }); @@ -64,7 +64,7 @@ describe('WorkbookWriter', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('Hello'); expect(ws2.getCell('A1').value).to.deep.equal({ formula: 'ROW()+COLUMN()', @@ -110,7 +110,7 @@ describe('WorkbookWriter', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('Hello'); expect(ws2.autoFilter).to.equal('A1:B1'); }); @@ -132,7 +132,7 @@ describe('WorkbookWriter', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { testUtils.checkTestBook(wb2, 'xlsx', undefined, { checkStyles: false, }); @@ -173,10 +173,10 @@ describe('WorkbookWriter', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('blort'); ['A1', 'B1', 'C1', 'A2', 'B2', 'C2', 'A3', 'B3', 'C3'].forEach( - (address) => { + address => { expect(ws2.getCell(address).value).to.equal(address); } ); @@ -248,7 +248,7 @@ describe('WorkbookWriter', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('Hello'); expect(ws2.getCell('A1').value).to.deep.equal({ richText: [ @@ -285,7 +285,7 @@ describe('WorkbookWriter', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { for (i = 1; i <= numSheets; i++) { const ws2 = wb2.getWorksheet(`sheet${i}`); expect(ws2).to.be.ok(); @@ -336,7 +336,7 @@ describe('WorkbookWriter', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('blort'); expect(ws2.getCell('A1').name).to.equal('five'); @@ -366,7 +366,7 @@ describe('WorkbookWriter', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('blort'); expect(ws2.getCell('A1').value).to.equal(xmlCharacters); }); @@ -386,7 +386,7 @@ describe('WorkbookWriter', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { testUtils.checkTestBook(wb2, 'xlsx', ['dataValidations']); }); }); @@ -411,7 +411,7 @@ describe('WorkbookWriter', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { testUtils.checkTestBook(wb2, 'xlsx', ['dataValidations']); }); }); @@ -584,7 +584,7 @@ describe('WorkbookWriter', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { testUtils.checkTestBook(wb2, 'xlsx', ['conditionalFormatting']); }); }); diff --git a/spec/integration/workbook/images.spec.js b/spec/integration/workbook/images.spec.js index ac26256c4..423293f7d 100644 --- a/spec/integration/workbook/images.spec.js +++ b/spec/integration/workbook/images.spec.js @@ -37,7 +37,7 @@ describe('Workbook', () => { return fsReadFileAsync(IMAGE_FILENAME); }) - .then((imageData) => { + .then(imageData => { const backgroundId2 = ws2.getBackgroundImageId(); const image = wb2.getImage(backgroundId2); @@ -81,7 +81,7 @@ describe('Workbook', () => { return fsReadFileAsync(IMAGE_FILENAME); }) - .then((imageData) => { + .then(imageData => { const images = ws2.getImages(); expect(images.length).to.equal(1); @@ -125,7 +125,7 @@ describe('Workbook', () => { return fsReadFileAsync(IMAGE_FILENAME); }) - .then((imageData) => { + .then(imageData => { const images = ws2.getImages(); expect(images.length).to.equal(1); @@ -166,7 +166,7 @@ describe('Workbook', () => { return fsReadFileAsync(IMAGE_FILENAME); }) - .then((imageData) => { + .then(imageData => { const images = ws2.getImages(); expect(images.length).to.equal(1); @@ -213,7 +213,7 @@ describe('Workbook', () => { return fsReadFileAsync(IMAGE_FILENAME); }) - .then((imageData) => { + .then(imageData => { const images = ws2.getImages(); expect(images.length).to.equal(1); @@ -271,7 +271,7 @@ describe('Workbook', () => { return fsReadFileAsync(IMAGE_FILENAME); }) - .then((imageData) => { + .then(imageData => { const images = ws2.getImages(); expect(images.length).to.equal(2); diff --git a/spec/integration/workbook/styles.spec.js b/spec/integration/workbook/styles.spec.js index 1762dce08..5d205fe15 100644 --- a/spec/integration/workbook/styles.spec.js +++ b/spec/integration/workbook/styles.spec.js @@ -47,10 +47,10 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('blort'); ['A1', 'B1', 'C1', 'A2', 'B2', 'C2', 'A3', 'B3', 'C3'].forEach( - (address) => { + address => { expect(ws2.getCell(address).value).to.equal(address); } ); @@ -125,7 +125,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('blort'); expect(ws2.getCell('B4').fill).to.deep.equal( diff --git a/spec/integration/workbook/workbook.spec.js b/spec/integration/workbook/workbook.spec.js index fb56b0694..850147d0b 100644 --- a/spec/integration/workbook/workbook.spec.js +++ b/spec/integration/workbook/workbook.spec.js @@ -19,7 +19,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { testUtils.checkTestBook(wb2, 'xlsx'); }); }); @@ -40,7 +40,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { testUtils.checkTestBook(wb2, 'xlsx'); }); }); @@ -58,7 +58,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { testUtils.checkTestBook(wb2, 'xlsx'); }); }); @@ -79,7 +79,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { testUtils.checkTestBook(wb2, 'xlsx'); }); }); @@ -97,7 +97,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { testUtils.checkTestBook(wb2, 'xlsx'); }); }); @@ -120,7 +120,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { expect(wb2.getWorksheet('Hello, World!')).to.be.ok(); expect(wb2.getWorksheet('This & That')).to.be.ok(); }); @@ -140,7 +140,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { expect(wb2.creator).to.equal(wb.creator); expect(wb2.lastModifiedBy).to.equal(wb.lastModifiedBy); expect(wb2.created).to.equalDate(wb.created); @@ -167,7 +167,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('printHeader'); expect(ws2.pageSetup.printTitlesRow).to.equal('1:2'); expect(ws2.pageSetup.printTitlesColumn).to.be.undefined(); @@ -197,7 +197,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('printColumn'); expect(ws2.pageSetup.printTitlesRow).to.be.undefined(); expect(ws2.pageSetup.printTitlesColumn).to.equal('A:B'); @@ -242,7 +242,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('printHeaderAndColumn'); expect(ws2.pageSetup.printTitlesRow).to.equal('1:2'); expect(ws2.pageSetup.printTitlesColumn).to.equal('A:B'); @@ -262,7 +262,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('Hello'); expect(ws2.getCell('A1').value).to.deep.equal({ formula: 'ROW()+COLUMN()', @@ -303,7 +303,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('Hello'); expect(ws2.autoFilter).to.equal('A1:B1'); }); @@ -321,7 +321,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { expect(wb2.company).to.equal(wb.company); expect(wb2.manager).to.equal(wb.manager); }); @@ -342,7 +342,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { expect(wb2.title).to.equal(wb.title); expect(wb2.subject).to.equal(wb.subject); expect(wb2.keywords).to.equal(wb.keywords); @@ -364,7 +364,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { expect(wb2.language).to.equal(wb.language); expect(wb2.revision).to.equal(wb.revision); expect(wb2.contentStatus).to.equal(wb.contentStatus); @@ -383,7 +383,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('Hello'); expect(ws2.getCell('A1').value).to.equal('Foo'); @@ -403,7 +403,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { testUtils.checkTestBook(wb2, 'xlsx', ['dataValidations']); }); }); @@ -439,7 +439,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { for (i = 1; i <= numSheets; i++) { const ws2 = wb2.getWorksheet(`sheet${i}`); expect(ws2).to.be.ok(); @@ -459,7 +459,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.csv.readFile(TEST_CSV_FILE_NAME).then(() => wb2); }) - .then((wb2) => { + .then(wb2 => { testUtils.checkTestBook(wb2, 'csv'); }); }); @@ -495,7 +495,7 @@ describe('Workbook', () => { .readFile(TEST_CSV_FILE_NAME, readOptions) .then(() => wb2); }) - .then((wb2) => { + .then(wb2 => { testUtils.checkTestBook(wb2, 'csv', false, writeOptions); }); }); @@ -552,7 +552,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2a = wb2.getWorksheet('blort'); const ws2b = wb2.getWorksheet('foo'); @@ -635,7 +635,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('duplicateTest'); expect(ws2.getCell('A2').value).to.equal('OneInfo'); @@ -662,7 +662,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('duplicateTest'); expect(ws2.getCell('A1').value).to.equal('OneInfo'); @@ -687,7 +687,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('duplicateTest'); expect(ws2.getCell('A1').value).to.equal('OneInfo'); @@ -712,7 +712,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('duplicateTest'); expect(ws2.getCell('A1').value).to.equal('OneInfo'); @@ -739,7 +739,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('blort'); expect(ws2.getCell('B2').value).to.equal('B2'); @@ -776,7 +776,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('blort'); expect(ws2.getCell('B2').font).to.deep.equal( @@ -874,7 +874,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { testUtils.checkTestBook(wb2, 'xlsx', sheets, options); }); }); @@ -947,7 +947,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('frozen'); expect(ws2).to.be.ok(); expect(ws2.getCell('A1').value).to.equal('Let it Snow!'); @@ -1024,7 +1024,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { const ws2 = wb2.getWorksheet('split'); expect(ws2).to.be.ok(); expect(ws2.getCell('A1').value).to.equal('Do the splits!'); @@ -1092,7 +1092,7 @@ describe('Workbook', () => { const wb2 = new ExcelJS.Workbook(); return wb2.xlsx.readFile(TEST_XLSX_FILE_NAME); }) - .then((wb2) => { + .then(wb2 => { expect(wb2.views).to.deep.equal(wb.views); const ws1b = wb2.getWorksheet('one'); diff --git a/spec/integration/worksheet-xlsx-writer.spec.js b/spec/integration/worksheet-xlsx-writer.spec.js index 24a556a9c..38d743389 100644 --- a/spec/integration/worksheet-xlsx-writer.spec.js +++ b/spec/integration/worksheet-xlsx-writer.spec.js @@ -297,7 +297,7 @@ describe('WorksheetWriter', () => { row3[3] = 'Sam'; row3[5] = dateValue1; rows.push(row3); - rows.forEach((row) => { + rows.forEach(row => { if (row) { ws.addRow(row); } diff --git a/spec/integration/worksheet.spec.js b/spec/integration/worksheet.spec.js index ff07a2134..4a3756283 100644 --- a/spec/integration/worksheet.spec.js +++ b/spec/integration/worksheet.spec.js @@ -326,7 +326,7 @@ describe('Worksheet', () => { row3[3] = 'Sam'; row3[5] = dateValue1; rows.push(row3); - rows.forEach((row) => { + rows.forEach(row => { if (row) { ws.addRow(row); } @@ -500,7 +500,7 @@ describe('Worksheet', () => { row3[3] = 'Other Doe'; row3[5] = dateValue3; rows.push(row3); - rows.forEach((row) => { + rows.forEach(row => { if (row) { // insert on row 1 every time and thus finally reversed order ws.insertRow(1, row); @@ -1056,7 +1056,7 @@ describe('Worksheet', () => { it('Should not break when importing a .numbers file', () => new ExcelJS.Workbook().xlsx .readFile(path.resolve(__dirname, 'data', 'numbers.numbers')) - .then((workbook) => { + .then(workbook => { expect(workbook).to.have.property('worksheets'); expect(workbook.worksheets).to.have.length(0); })); @@ -1065,7 +1065,7 @@ describe('Worksheet', () => { it('Should not break when importing an Excel file that contains a chartsheet', () => new ExcelJS.Workbook().xlsx .readFile(path.resolve(__dirname, 'data', 'chart-sheet.xlsx')) - .then((workbook) => { + .then(workbook => { expect(workbook).to.have.property('worksheets'); expect(workbook.worksheets).to.have.length(1); })); @@ -1078,7 +1078,7 @@ describe('Worksheet', () => { ]; for (const file of fileList) { - it(`Should set hidden attribute correctly (${file})`, (done) => { + it(`Should set hidden attribute correctly (${file})`, done => { const wb = new ExcelJS.Workbook(); wb.xlsx .readFile( @@ -1103,7 +1103,7 @@ describe('Worksheet', () => { done(); }) - .catch((error) => { + .catch(error => { done(error); }); }); diff --git a/spec/unit/doc/defined-names.spec.js b/spec/unit/doc/defined-names.spec.js index 582c3c963..08111f614 100644 --- a/spec/unit/doc/defined-names.spec.js +++ b/spec/unit/doc/defined-names.spec.js @@ -77,8 +77,8 @@ describe('DefinedNames', () => { dn.add('horizontal!C1', 'horizontal'); dn.add('horizontal!D1', 'horizontal'); - ['A', 'B', 'C', 'D'].forEach((col) => { - [1, 2, 3, 4].forEach((row) => { + ['A', 'B', 'C', 'D'].forEach(col => { + [1, 2, 3, 4].forEach(row => { dn.add(`square!${col}${row}`, 'square'); }); }); diff --git a/spec/unit/doc/worksheet-table.spec.js b/spec/unit/doc/worksheet-table.spec.js index 9f69c6c3e..f87495279 100644 --- a/spec/unit/doc/worksheet-table.spec.js +++ b/spec/unit/doc/worksheet-table.spec.js @@ -157,7 +157,7 @@ describe('Worksheet', () => { table.removeColumns(1); table.commit(); - const newValues = values.map((rVals) => spliceArray(rVals, 1, 1)); + const newValues = values.map(rVals => spliceArray(rVals, 1, 1)); checkTable('A1', ws, newValues); }); diff --git a/spec/unit/doc/worksheet.values.spec.js b/spec/unit/doc/worksheet.values.spec.js index 3731dd48a..da6784db9 100644 --- a/spec/unit/doc/worksheet.values.spec.js +++ b/spec/unit/doc/worksheet.values.spec.js @@ -309,7 +309,7 @@ describe('Worksheet', () => { row3[3] = 'Sam'; row3[5] = dateValue1; rows.push(row3); - rows.forEach((row) => { + rows.forEach(row => { if (row) { ws.addRow(row); } @@ -572,7 +572,7 @@ describe('Worksheet', () => { {id: '123', name: 'Jack', dob: new Date(), age: 0}, {id: '124', name: 'Jill', dob: new Date(), age: 0}, ]; - values.forEach((value) => { + values.forEach(value => { ws.addRow(value); }); diff --git a/spec/unit/utils/stream-buf.spec.js b/spec/unit/utils/stream-buf.spec.js index d7cfe36bc..d51489013 100644 --- a/spec/unit/utils/stream-buf.spec.js +++ b/spec/unit/utils/stream-buf.spec.js @@ -27,7 +27,7 @@ describe('StreamBuf', () => { expect(chunk.toString('UTF8')).to.equal('Hello, World!'); }); - it('signals end', (done) => { + it('signals end', done => { const stream = new StreamBuf(); stream.on('finish', () => { done(); diff --git a/spec/unit/utils/utils.spec.js b/spec/unit/utils/utils.spec.js index 8b6b14aa4..53b7a6326 100644 --- a/spec/unit/utils/utils.spec.js +++ b/spec/unit/utils/utils.spec.js @@ -25,13 +25,13 @@ describe('utils', () => { }); }); describe('isDateFmt', () => { - ['yyyy-mm-dd'].forEach((fmt) => { + ['yyyy-mm-dd'].forEach(fmt => { it(`'${fmt}' a date`, () => { expect(utils.isDateFmt(fmt)).to.be.true(); }); }); - ['', '[Green]#,##0 ;[Red](#,##0)'].forEach((fmt) => { + ['', '[Green]#,##0 ;[Red](#,##0)'].forEach(fmt => { it(`'${fmt}' is not a date`, () => { expect(utils.isDateFmt(fmt)).to.be.false(); }); diff --git a/spec/unit/xlsx/xform/compy-xform.js b/spec/unit/xlsx/xform/compy-xform.js index 447904316..db3e98432 100644 --- a/spec/unit/xlsx/xform/compy-xform.js +++ b/spec/unit/xlsx/xform/compy-xform.js @@ -18,14 +18,14 @@ class CompyXform extends BaseXform { } prepare(model, options) { - this.children.forEach((child) => { + this.children.forEach(child => { child.xform.prepare(model[child.tag], options); }); } render(xmlStream, model) { xmlStream.openNode(this.tag, this.attrs); - this.children.forEach((child) => { + this.children.forEach(child => { child.xform.render(xmlStream, model[child.name]); }); xmlStream.closeNode(); @@ -68,7 +68,7 @@ class CompyXform extends BaseXform { } reconcile(model, options) { - this.children.forEach((child) => { + this.children.forEach(child => { child.xform.prepare(model[child.tag], options); }); } diff --git a/spec/unit/xlsx/xform/test-xform-helper.js b/spec/unit/xlsx/xform/test-xform-helper.js index 05312e491..8cadea8a4 100644 --- a/spec/unit/xlsx/xform/test-xform-helper.js +++ b/spec/unit/xlsx/xform/test-xform-helper.js @@ -23,7 +23,7 @@ function getExpectation(expectation, name) { const its = { prepare(expectation) { it('Prepare Model', () => - new Promise((resolve) => { + new Promise(resolve => { const model = getExpectation(expectation, 'initialModel'); const result = getExpectation(expectation, 'preparedModel'); @@ -36,7 +36,7 @@ const its = { render(expectation) { it('Render to XML', () => - new Promise((resolve) => { + new Promise(resolve => { const model = getExpectation(expectation, 'preparedModel'); const result = getExpectation(expectation, 'xml'); @@ -54,7 +54,7 @@ const its = { 'prepare-render': function(expectation) { // when implementation details get in the way of testing the prepared result it('Prepare and Render to XML', () => - new Promise((resolve) => { + new Promise(resolve => { const model = getExpectation(expectation, 'initialModel'); const result = getExpectation(expectation, 'xml'); @@ -71,7 +71,7 @@ const its = { renderIn(expectation) { it('Render in Composite to XML ', () => - new Promise((resolve) => { + new Promise(resolve => { const model = { pre: true, child: getExpectation(expectation, 'preparedModel'), @@ -136,7 +136,7 @@ const its = { stream.end(); xform .parse(parseSax(stream)) - .then((model) => { + .then(model => { // console.log('parsed Model', JSON.stringify(model)); // console.log('expected Model', JSON.stringify(result)); @@ -165,7 +165,7 @@ const its = { stream.end(); xform .parse(parseSax(stream)) - .then((model) => { + .then(model => { // eliminate the undefined const clone = cloneDeep(model, false); @@ -180,7 +180,7 @@ const its = { reconcile(expectation) { it('Reconcile Model', () => - new Promise((resolve) => { + new Promise(resolve => { const model = getExpectation(expectation, 'parsedModel'); const result = getExpectation(expectation, 'reconciledModel'); @@ -197,10 +197,10 @@ const its = { }; function testXform(expectations) { - each(expectations, (expectation) => { + each(expectations, expectation => { const tests = getExpectation(expectation, 'tests'); describe(expectation.title, () => { - each(tests, (test) => { + each(tests, test => { its[test](expectation); }); }); diff --git a/spec/utils/index.js b/spec/utils/index.js index 5fa9177ea..9cf3cb13b 100644 --- a/spec/utils/index.js +++ b/spec/utils/index.js @@ -67,7 +67,7 @@ module.exports = { {x: 1, y: 2, width: 10000, height: 20000, firstSheet: 0, activeTab: 0}, ]; - sheets.forEach((sheet) => { + sheets.forEach(sheet => { const testSheet = _.get(testSheets, sheet); testSheet.addSheet(workbook, options); }); @@ -95,7 +95,7 @@ module.exports = { ]); } - sheets.forEach((sheet) => { + sheets.forEach(sheet => { const testSheet = _.get(testSheets, sheet); testSheet.checkSheet(workbook, options); }); diff --git a/spec/utils/test-conditional-formatting-sheet.js b/spec/utils/test-conditional-formatting-sheet.js index 62e655957..2dea87319 100644 --- a/spec/utils/test-conditional-formatting-sheet.js +++ b/spec/utils/test-conditional-formatting-sheet.js @@ -8,7 +8,7 @@ const self = { addSheet(wb) { const ws = wb.addWorksheet('conditional-formatting'); const {types} = self.conditionalFormattings; - types.forEach((type) => { + types.forEach(type => { const conditionalFormatting = self.getConditionalFormatting(type); if (conditionalFormatting) { ws.addConditionalFormatting(conditionalFormatting); @@ -20,7 +20,7 @@ const self = { const ws = wb.getWorksheet('conditional-formatting'); expect(ws).to.not.be.undefined(); expect(ws.conditionalFormattings).to.not.be.undefined(); - (ws.conditionalFormattings && ws.conditionalFormattings).forEach((item) => { + (ws.conditionalFormattings && ws.conditionalFormattings).forEach(item => { const type = item.rules && item.rules[0].type; const conditionalFormatting = self.getConditionalFormatting(type); expect(item).to.have.property('ref'); diff --git a/spec/utils/test-data-validation-sheet.js b/spec/utils/test-data-validation-sheet.js index 88847d22c..4481ae9ea 100644 --- a/spec/utils/test-data-validation-sheet.js +++ b/spec/utils/test-data-validation-sheet.js @@ -85,7 +85,7 @@ const self = { }; // two rows of the same validation to test dataValidation optimisation - ['A22', 'A23'].forEach((address) => { + ['A22', 'A23'].forEach(address => { ws.getCell(address).value = tools.concatenateFormula('Five Numbers'); }); [ @@ -99,7 +99,7 @@ const self = { 'D23', 'E23', 'F23', - ].forEach((address) => { + ].forEach(address => { ws.getCell(address).dataValidation = JSON.parse( JSON.stringify(self.dataValidations.shared) ); @@ -159,7 +159,7 @@ const self = { 'D23', 'E23', 'F23', - ].forEach((address) => { + ].forEach(address => { expect(ws.getCell(address).dataValidation).to.deep.equal( self.dataValidations.shared ); diff --git a/spec/utils/test-spliced-sheet.js b/spec/utils/test-spliced-sheet.js index 02fd4b2c5..f08ee7c72 100644 --- a/spec/utils/test-spliced-sheet.js +++ b/spec/utils/test-spliced-sheet.js @@ -335,8 +335,8 @@ module.exports = { wsSquare.addRow(['3,1', '3,2', '3,3', '3,4']); wsSquare.addRow(['4,1', '4,2', '4,3', '4,4']); - ['A', 'B', 'C', 'D'].forEach((col) => { - [1, 2, 3, 4].forEach((row) => { + ['A', 'B', 'C', 'D'].forEach(col => { + [1, 2, 3, 4].forEach(row => { wsSquare.getCell(col + row).name = 'square'; }); }); @@ -349,8 +349,8 @@ module.exports = { wsSingles.getCell('D1').value = '1,4'; wsSingles.getCell('D4').value = '4,4'; - ['A', 'D'].forEach((col) => { - [1, 4].forEach((row) => { + ['A', 'D'].forEach(col => { + [1, 4].forEach(row => { wsSingles.getCell(col + row).name = `single-${col}${row}`; }); }); @@ -377,8 +377,8 @@ module.exports = { '4,4', ]); - ['A', 'B', 'C', 'D'].forEach((col) => { - [1, 2, 3].forEach((row) => { + ['A', 'B', 'C', 'D'].forEach(col => { + [1, 2, 3].forEach(row => { if (row === 3) { expect(wsSquare.getCell(col + row).name).to.be.undefined(); } else { @@ -407,8 +407,8 @@ module.exports = { wsSquare.addRow(['3,1', '3,2', '3,3', '3,4']); wsSquare.addRow(['4,1', '4,2', '4,3', '4,4']); - ['A', 'B', 'C', 'D'].forEach((col) => { - [1, 2, 3, 4].forEach((row) => { + ['A', 'B', 'C', 'D'].forEach(col => { + [1, 2, 3, 4].forEach(row => { wsSquare.getCell(col + row).name = 'square'; }); }); @@ -421,8 +421,8 @@ module.exports = { wsSingles.getCell('D1').value = '1,4'; wsSingles.getCell('D4').value = '4,4'; - ['A', 'D'].forEach((col) => { - [1, 4].forEach((row) => { + ['A', 'D'].forEach(col => { + [1, 4].forEach(row => { wsSingles.getCell(col + row).name = `single-${col}${row}`; }); }); @@ -470,8 +470,8 @@ module.exports = { '4,4', ]); - ['A', 'B', 'C', 'D'].forEach((col) => { - [1, 2, 3, 4, 5].forEach((row) => { + ['A', 'B', 'C', 'D'].forEach(col => { + [1, 2, 3, 4, 5].forEach(row => { if (row === 3) { expect(wsSquare.getCell(col + row).name).to.be.undefined(); } else { @@ -506,8 +506,8 @@ module.exports = { wsSquare.addRow(['3,1', '3,2', '3,3', '3,4']); wsSquare.addRow(['4,1', '4,2', '4,3', '4,4']); - ['A', 'B', 'C', 'D'].forEach((col) => { - [1, 2, 3, 4].forEach((row) => { + ['A', 'B', 'C', 'D'].forEach(col => { + [1, 2, 3, 4].forEach(row => { wsSquare.getCell(col + row).name = 'square'; }); }); @@ -520,8 +520,8 @@ module.exports = { wsSingles.getCell('D1').value = '1,4'; wsSingles.getCell('D4').value = '4,4'; - ['A', 'D'].forEach((col) => { - [1, 4].forEach((row) => { + ['A', 'D'].forEach(col => { + [1, 4].forEach(row => { wsSingles.getCell(col + row).name = `single-${col}${row}`; }); }); @@ -562,8 +562,8 @@ module.exports = { '4,4', ]); - ['A', 'B', 'C', 'D'].forEach((col) => { - [1, 2, 3, 4].forEach((row) => { + ['A', 'B', 'C', 'D'].forEach(col => { + [1, 2, 3, 4].forEach(row => { if (row === 2) { expect(wsSquare.getCell(col + row).name).to.be.undefined(); } else { @@ -1028,8 +1028,8 @@ module.exports = { wsSquare.addRow(['3,1', '3,2', '3,3', '3,4']); wsSquare.addRow(['4,1', '4,2', '4,3', '4,4']); - ['A', 'B', 'C', 'D'].forEach((col) => { - [1, 2, 3, 4].forEach((row) => { + ['A', 'B', 'C', 'D'].forEach(col => { + [1, 2, 3, 4].forEach(row => { wsSquare.getCell(col + row).name = 'square'; }); }); @@ -1042,8 +1042,8 @@ module.exports = { wsSingles.getCell('D1').value = '1,4'; wsSingles.getCell('D4').value = '4,4'; - ['A', 'D'].forEach((col) => { - [1, 4].forEach((row) => { + ['A', 'D'].forEach(col => { + [1, 4].forEach(row => { wsSingles.getCell(col + row).name = `single-${col}${row}`; }); }); @@ -1060,8 +1060,8 @@ module.exports = { expect(wsSquare.getRow(3).values).to.deep.equal([, '3,1', '3,4']); expect(wsSquare.getRow(4).values).to.deep.equal([, '4,1', '4,4']); - ['A', 'B', 'C', 'D'].forEach((col) => { - [1, 2, 3].forEach((row) => { + ['A', 'B', 'C', 'D'].forEach(col => { + [1, 2, 3].forEach(row => { if (['C', 'D'].includes(col)) { expect(wsSquare.getCell(col + row).name).to.be.undefined(); } else { @@ -1090,8 +1090,8 @@ module.exports = { wsSquare.addRow(['3,1', '3,2', '3,3', '3,4']); wsSquare.addRow(['4,1', '4,2', '4,3', '4,4']); - ['A', 'B', 'C', 'D'].forEach((col) => { - [1, 2, 3, 4].forEach((row) => { + ['A', 'B', 'C', 'D'].forEach(col => { + [1, 2, 3, 4].forEach(row => { wsSquare.getCell(col + row).name = 'square'; }); }); @@ -1104,8 +1104,8 @@ module.exports = { wsSingles.getCell('D1').value = '1,4'; wsSingles.getCell('D4').value = '4,4'; - ['A', 'D'].forEach((col) => { - [1, 4].forEach((row) => { + ['A', 'D'].forEach(col => { + [1, 4].forEach(row => { wsSingles.getCell(col + row).name = `single-${col}${row}`; }); }); @@ -1150,8 +1150,8 @@ module.exports = { '4,4', ]); - ['A', 'B', 'C', 'D', 'E'].forEach((col) => { - [1, 2, 3, 4].forEach((row) => { + ['A', 'B', 'C', 'D', 'E'].forEach(col => { + [1, 2, 3, 4].forEach(row => { if (col === 'C') { expect(wsSquare.getCell(col + row).name).to.be.undefined(); } else { @@ -1194,8 +1194,8 @@ module.exports = { wsSquare.addRow(['3,1', '3,2', '3,3', '3,4']); wsSquare.addRow(['4,1', '4,2', '4,3', '4,4']); - ['A', 'B', 'C', 'D'].forEach((col) => { - [1, 2, 3, 4].forEach((row) => { + ['A', 'B', 'C', 'D'].forEach(col => { + [1, 2, 3, 4].forEach(row => { wsSquare.getCell(col + row).name = 'square'; }); }); @@ -1208,8 +1208,8 @@ module.exports = { wsSingles.getCell('D1').value = '1,4'; wsSingles.getCell('D4').value = '4,4'; - ['A', 'D'].forEach((col) => { - [1, 4].forEach((row) => { + ['A', 'D'].forEach(col => { + [1, 4].forEach(row => { wsSingles.getCell(col + row).name = `single-${col}${row}`; }); }); @@ -1250,8 +1250,8 @@ module.exports = { '4,4', ]); - ['A', 'B', 'C', 'D'].forEach((col) => { - [1, 2, 3, 4].forEach((row) => { + ['A', 'B', 'C', 'D'].forEach(col => { + [1, 2, 3, 4].forEach(row => { if (col === 'B') { expect(wsSquare.getCell(col + row).name).to.be.undefined(); } else { diff --git a/spec/utils/test-values-sheet.js b/spec/utils/test-values-sheet.js index 34ef805fa..2bbc45be3 100644 --- a/spec/utils/test-values-sheet.js +++ b/spec/utils/test-values-sheet.js @@ -358,7 +358,7 @@ const self = { formula: 'A9', result: 1, }); - ['B11', 'C11', 'D11', 'E11'].forEach((address) => { + ['B11', 'C11', 'D11', 'E11'].forEach(address => { expect(ws.getCell(address).value).to.equal(1); }); } diff --git a/spec/utils/test-workbook-reader.js b/spec/utils/test-workbook-reader.js index 111c0accf..4994701e6 100644 --- a/spec/utils/test-workbook-reader.js +++ b/spec/utils/test-workbook-reader.js @@ -31,10 +31,10 @@ module.exports = { return new Promise((resolve, reject) => { let rowCount = 0; - wb.on('worksheet', (ws) => { + wb.on('worksheet', ws => { // Sheet name stored in workbook. Not guaranteed here // expect(ws.name).to.equal('blort'); - ws.on('row', (row) => { + ws.on('row', row => { rowCount++; try { switch (row.number) { diff --git a/spec/utils/tools.js b/spec/utils/tools.js index afd67881c..5ac472fd3 100644 --- a/spec/utils/tools.js +++ b/spec/utils/tools.js @@ -23,7 +23,7 @@ const tools = { }, concatenateFormula(...args) { - const values = args.map((value) => `"${value}"`); + const values = args.map(value => `"${value}"`); return { formula: `CONCATENATE(${values.join(',')})`, }; diff --git a/test/test-a1.js b/test/test-a1.js index e910ace27..edb4ca7c4 100644 --- a/test/test-a1.js +++ b/test/test-a1.js @@ -16,6 +16,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); diff --git a/test/test-cf.js b/test/test-cf.js index 2c1ae37f9..a1e016161 100644 --- a/test/test-cf.js +++ b/test/test-cf.js @@ -654,6 +654,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); diff --git a/test/test-chart.js b/test/test-chart.js index ef81025ab..43201e6ea 100644 --- a/test/test-chart.js +++ b/test/test-chart.js @@ -49,6 +49,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); diff --git a/test/test-colour-cell.js b/test/test-colour-cell.js index a2f9f5242..ce308ebde 100644 --- a/test/test-colour-cell.js +++ b/test/test-colour-cell.js @@ -56,6 +56,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); diff --git a/test/test-comment-new.js b/test/test-comment-new.js index 8e979c41e..840439468 100644 --- a/test/test-comment-new.js +++ b/test/test-comment-new.js @@ -102,6 +102,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); diff --git a/test/test-comment-stream-writer.js b/test/test-comment-stream-writer.js index 30145b0ea..0693a9323 100644 --- a/test/test-comment-stream-writer.js +++ b/test/test-comment-stream-writer.js @@ -101,6 +101,6 @@ wb.commit() console.log('Done.'); console.log('Time taken:', micros); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); diff --git a/test/test-comments.js b/test/test-comments.js index 5ceb64c3a..481bd5991 100644 --- a/test/test-comments.js +++ b/test/test-comments.js @@ -4,7 +4,7 @@ const wb = new Excel.Workbook(); wb.xlsx .readFile(require.resolve('./data/comments.xlsx')) .then(() => { - wb.worksheets.forEach((sheet) => { + wb.worksheets.forEach(sheet => { console.info(sheet.getCell('A1').model); sheet.getCell('B2').value = 'Zeb'; sheet.getCell('B2').comment = { diff --git a/test/test-copy.js b/test/test-copy.js index 6b1706756..c78399348 100644 --- a/test/test-copy.js +++ b/test/test-copy.js @@ -19,6 +19,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch((error) => { + .catch(error => { console.error('Error', error.stack); }); diff --git a/test/test-default-height.js b/test/test-default-height.js index b968811d0..8c02cd89a 100644 --- a/test/test-default-height.js +++ b/test/test-default-height.js @@ -24,6 +24,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch((error) => { + .catch(error => { console.error(error.stack); }); diff --git a/test/test-formula.js b/test/test-formula.js index bf8a6741a..a0abf43c1 100644 --- a/test/test-formula.js +++ b/test/test-formula.js @@ -30,7 +30,7 @@ ws.getCell('F4').value = {sharedFormula: 'F1', result: 4}; // function fill ws.getCell('H1').value = 1; -ws.fillFormula('H2:H20', 'H1+1', (row) => row); +ws.fillFormula('H2:H20', 'H1+1', row => row); // array formula @@ -51,6 +51,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); diff --git a/test/test-header-footer.js b/test/test-header-footer.js index 0cfb1caf1..d616f9afa 100644 --- a/test/test-header-footer.js +++ b/test/test-header-footer.js @@ -19,6 +19,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); diff --git a/test/test-hyperlink.js b/test/test-hyperlink.js index 059c919b5..704bcf18a 100644 --- a/test/test-hyperlink.js +++ b/test/test-hyperlink.js @@ -21,6 +21,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); diff --git a/test/test-image-one-cell-anchor.js b/test/test-image-one-cell-anchor.js index c4d65896e..6c21a2aad 100644 --- a/test/test-image-one-cell-anchor.js +++ b/test/test-image-one-cell-anchor.js @@ -37,6 +37,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch((error) => { + .catch(error => { console.error(error.stack); }); diff --git a/test/test-image-oneCell.js b/test/test-image-oneCell.js index 551befae3..c7ccc9243 100644 --- a/test/test-image-oneCell.js +++ b/test/test-image-oneCell.js @@ -28,6 +28,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch((error) => { + .catch(error => { console.error(error.stack); }); diff --git a/test/test-image-out.js b/test/test-image-out.js index 814e966fa..4333ee76a 100644 --- a/test/test-image-out.js +++ b/test/test-image-out.js @@ -37,6 +37,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch((error) => { + .catch(error => { console.error(error.stack); }); diff --git a/test/test-image-stream-writer.js b/test/test-image-stream-writer.js index 01e53e2a2..5d0d3c093 100644 --- a/test/test-image-stream-writer.js +++ b/test/test-image-stream-writer.js @@ -23,6 +23,6 @@ wb.commit() console.log('Done.'); console.log('Time taken:', micros); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); diff --git a/test/test-jszip.js b/test/test-jszip.js index 47fef58c9..5d5b70ece 100644 --- a/test/test-jszip.js +++ b/test/test-jszip.js @@ -10,11 +10,11 @@ const jsZip = new JSZip(); fsp .readFileAsync(filename) - .then((data) => { + .then(data => { console.log('data', data); return jsZip.loadAsync(data); }) - .then((zip) => { + .then(zip => { zip.forEach((path, entry) => { if (!entry.dir) { // console.log(path, entry) diff --git a/test/test-merge-align.js b/test/test-merge-align.js index fd3432461..743867ca4 100644 --- a/test/test-merge-align.js +++ b/test/test-merge-align.js @@ -24,6 +24,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); diff --git a/test/test-newline.js b/test/test-newline.js index f124ecd40..0e022f01f 100644 --- a/test/test-newline.js +++ b/test/test-newline.js @@ -23,6 +23,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); diff --git a/test/test-protection-spinCount.js b/test/test-protection-spinCount.js index de378d117..39f84278a 100644 --- a/test/test-protection-spinCount.js +++ b/test/test-protection-spinCount.js @@ -51,6 +51,6 @@ async function save() { } } -save().catch((error) => { +save().catch(error => { console.log(error.message); }); diff --git a/test/test-protection.js b/test/test-protection.js index f1500883e..51ebd5d26 100644 --- a/test/test-protection.js +++ b/test/test-protection.js @@ -27,6 +27,6 @@ async function save() { console.log('Time taken:', stopwatch.microseconds); } -save().catch((error) => { +save().catch(error => { console.log(error.message); }); diff --git a/test/test-table.js b/test/test-table.js index 07bb6abd3..f0401552d 100644 --- a/test/test-table.js +++ b/test/test-table.js @@ -66,6 +66,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); diff --git a/test/testArray.js b/test/testArray.js index 16891e826..148974957 100644 --- a/test/testArray.js +++ b/test/testArray.js @@ -8,6 +8,6 @@ a[1] = 'one'; a[5] = 'five'; a[0] = 'zero'; -_.each(a, (i) => { +_.each(a, i => { console.log(i); }); diff --git a/test/testBigBookIn.js b/test/testBigBookIn.js index aba029ae1..35dd68f94 100644 --- a/test/testBigBookIn.js +++ b/test/testBigBookIn.js @@ -89,15 +89,15 @@ if (useStream) { console.log('reached end of stream'); }); wb.on('finished', report); - wb.on('worksheet', (worksheet) => { + wb.on('worksheet', worksheet => { worksheet.on('row', checkRow); }); - wb.on('hyperlinks', (hyperlinks) => { + wb.on('hyperlinks', hyperlinks => { hyperlinks.on('hyperlink', () => { hyperlinkCount++; }); }); - wb.on('entry', (entry) => { + wb.on('entry', entry => { console.log(JSON.stringify(entry)); }); switch (options.plan) { diff --git a/test/testBigBookOut.js b/test/testBigBookOut.js index 4a395f54c..ed9a4b29c 100644 --- a/test/testBigBookOut.js +++ b/test/testBigBookOut.js @@ -134,7 +134,7 @@ function allDone() { console.log(`Sums: ${colCount}`); console.log(`Time: ${stopwatch}`); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); } diff --git a/test/testBookFont.js b/test/testBookFont.js index 4df3499c7..79e9e9332 100644 --- a/test/testBookFont.js +++ b/test/testBookFont.js @@ -6,14 +6,14 @@ const workbook = new Workbook(); workbook.xlsx .readFile(filename) .then(() => { - workbook.eachSheet((worksheet) => { + workbook.eachSheet(worksheet => { console.log( `Sheet ${worksheet.id} - ${worksheet.name}, Dims=${JSON.stringify( worksheet.dimensions )}` ); - worksheet.eachRow((row) => { - row.eachCell((cell) => { + worksheet.eachRow(row => { + row.eachCell(cell => { if (cell.font.strike) { console.log(`Strikethrough: ${cell.value}`); } @@ -21,6 +21,6 @@ workbook.xlsx }); }); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); diff --git a/test/testBookOut.js b/test/testBookOut.js index 4c557596c..74b3f0241 100644 --- a/test/testBookOut.js +++ b/test/testBookOut.js @@ -358,6 +358,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); diff --git a/test/testBookOutS.js b/test/testBookOutS.js index 49e862459..2f323ab3e 100644 --- a/test/testBookOutS.js +++ b/test/testBookOutS.js @@ -289,6 +289,6 @@ wb.commit() .then(() => { console.log('Done.'); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); diff --git a/test/testBookRead.js b/test/testBookRead.js index dd23afefe..492091474 100644 --- a/test/testBookRead.js +++ b/test/testBookRead.js @@ -6,7 +6,7 @@ const workbook = new Workbook(); workbook.xlsx .readFile(filename) .then(() => { - workbook.eachSheet((worksheet) => { + workbook.eachSheet(worksheet => { console.log( `Sheet ${worksheet.id} - ${worksheet.name}, Dims=${JSON.stringify( worksheet.dimensions @@ -14,6 +14,6 @@ workbook.xlsx ); }); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); diff --git a/test/testCsvOut.js b/test/testCsvOut.js index eb24f43a6..2be90dc98 100644 --- a/test/testCsvOut.js +++ b/test/testCsvOut.js @@ -59,6 +59,6 @@ wb.csv .then(() => { console.log('Done.'); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); diff --git a/test/testImageIn.js b/test/testImageIn.js index 367078ebb..da15ccdf0 100644 --- a/test/testImageIn.js +++ b/test/testImageIn.js @@ -19,6 +19,6 @@ wb.xlsx const {image} = ws.background; console.log('Media', image.name, image.type, image.buffer.length); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); diff --git a/test/testMergedBorder.js b/test/testMergedBorder.js index 9998d4a8b..634cca36f 100644 --- a/test/testMergedBorder.js +++ b/test/testMergedBorder.js @@ -42,6 +42,6 @@ wb.xlsx .then(() => { console.log('Done.'); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); diff --git a/test/testMultiplePrintAreaOut.js b/test/testMultiplePrintAreaOut.js index 0fa720cfc..b6728f051 100644 --- a/test/testMultiplePrintAreaOut.js +++ b/test/testMultiplePrintAreaOut.js @@ -35,6 +35,6 @@ wb.xlsx .then(() => { console.log('Done.'); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); diff --git a/test/testPerformance.js b/test/testPerformance.js index 9b41cc2e6..eac5b2436 100644 --- a/test/testPerformance.js +++ b/test/testPerformance.js @@ -156,7 +156,7 @@ function runTests(options) { // run each test with a 10 second pause between (to let GC do its stuff) promise = promise.then(() => runTest(options) - .then((result) => { + .then(result => { results.push(result); }) .delay(sleepTime) @@ -180,13 +180,13 @@ function runTests(options) { let mainPromise = Promise.resolve(); // var mainPromise = execute(125, 'stream', 'plain', 'own'); -_.each(counts, (count) => { +_.each(counts, count => { mainPromise = mainPromise.then(() => { resultSheet.addRow().getCell('count').value = count; }); - _.each(workbooks, (workbook) => { - _.each(styles, (style) => { - _.each(strings, (str) => { + _.each(workbooks, workbook => { + _.each(styles, style => { + _.each(strings, str => { mainPromise = mainPromise.then( runTests({ count, @@ -208,7 +208,7 @@ mainPromise = mainPromise .then(() => { console.log('All Done'); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); diff --git a/test/testPrintAreaOut.js b/test/testPrintAreaOut.js index eea8fea58..c5f0c8788 100644 --- a/test/testPrintAreaOut.js +++ b/test/testPrintAreaOut.js @@ -35,6 +35,6 @@ wb.xlsx .then(() => { console.log('Done.'); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); diff --git a/test/testPrintColRowOut.js b/test/testPrintColRowOut.js index 8edf20016..ebfdb3878 100644 --- a/test/testPrintColRowOut.js +++ b/test/testPrintColRowOut.js @@ -41,6 +41,6 @@ wb.xlsx console.log('Done.'); console.log('Time taken:', micros); }) - .catch((error) => { + .catch(error => { console.log(error.message); }); diff --git a/test/testProcess.js b/test/testProcess.js index 8037af3da..1c311fc34 100644 --- a/test/testProcess.js +++ b/test/testProcess.js @@ -22,7 +22,7 @@ wb.xlsx .then(() => { console.log('Loaded', inputFile); - wb.eachSheet((sheet) => { + wb.eachSheet(sheet => { console.log(sheet.name); }); @@ -39,7 +39,7 @@ wb.xlsx .then(() => { assert(passed, 'Something went wrong', 'All tests passed!'); }) - .catch((error) => { + .catch(error => { console.error(error.message); console.error(error.stack); }); diff --git a/test/testSax2.js b/test/testSax2.js index d841aaec2..20ebe4d95 100644 --- a/test/testSax2.js +++ b/test/testSax2.js @@ -45,7 +45,7 @@ e.on('finished', () => { let row = null; let cell = null; -parser.on('opentag', (node) => { +parser.on('opentag', node => { // console.log('opentag ' + node.name); switch (node.name) { case 'row': { @@ -64,13 +64,13 @@ parser.on('opentag', (node) => { default: } }); -parser.on('text', (text) => { +parser.on('text', text => { // console.log('text ' + text); if (cell) { cell.value += text; } }); -parser.on('closetag', (name) => { +parser.on('closetag', name => { // console.log('closetag ' + name); switch (name) { case 'row': diff --git a/test/testSharedStrings.js b/test/testSharedStrings.js index 2c9216deb..69cc1ca6c 100644 --- a/test/testSharedStrings.js +++ b/test/testSharedStrings.js @@ -17,4 +17,4 @@ wb.xlsx .then(() => { console.log('done'); }) - .catch((e) => console.log(e)); + .catch(e => console.log(e)); diff --git a/test/testStringBuf.js b/test/testStringBuf.js index c93bdd720..1adc440a8 100644 --- a/test/testStringBuf.js +++ b/test/testStringBuf.js @@ -87,6 +87,6 @@ const results = {}; Promise.resolve(results) .then(testWrite) .then(testGrow) - .then((r) => { + .then(r => { console.log(JSON.stringify(r, null, ' ')); }); diff --git a/test/testStringtable.js b/test/testStringtable.js index 4ac07989c..96a93fae9 100644 --- a/test/testStringtable.js +++ b/test/testStringtable.js @@ -7,7 +7,7 @@ const filename = process.argv[2]; const st = new SharedStrings(null); const lst = ['Hello', 'Hello', 'World', 'Hello\nWorld!', 'Hello, "World!"']; -_.each(lst, (item) => { +_.each(lst, item => { st.add(item); }); diff --git a/test/testTemplate.js b/test/testTemplate.js index 875f4258a..2fdd7421d 100644 --- a/test/testTemplate.js +++ b/test/testTemplate.js @@ -3,7 +3,7 @@ const Excel = require('../excel'); const workbook = new Excel.Workbook(); workbook.xlsx .readFile('./out/template.xlsx') - .then((stream) => { + .then(stream => { const options = { useSharedStrings: true, useStyles: true, @@ -15,7 +15,7 @@ workbook.xlsx console.log('Done.'); }); }) - .catch((error) => { + .catch(error => { console.error(error.message); console.error(error.stack); }); diff --git a/test/testXlsxIn.js b/test/testXlsxIn.js index 1dc45250e..589263929 100644 --- a/test/testXlsxIn.js +++ b/test/testXlsxIn.js @@ -21,6 +21,6 @@ wb.xlsx console.log(id, sheet.name); }); }) - .catch((error) => { + .catch(error => { console.error('something went wrong', error.stack); }); diff --git a/test/utils/column-sum.js b/test/utils/column-sum.js index b58c5b029..6419c992f 100644 --- a/test/utils/column-sum.js +++ b/test/utils/column-sum.js @@ -4,14 +4,14 @@ const ColumnSum = (module.exports = function(columns) { this.columns = columns; this.sums = []; this.count = 0; - _.each(this.columns, (column) => { + _.each(this.columns, column => { this.sums[column] = 0; }); }); ColumnSum.prototype = { add(row) { - _.each(this.columns, (column) => { + _.each(this.columns, column => { this.sums[column] += row.getCell(column).value; }); this.count++; @@ -22,7 +22,7 @@ ColumnSum.prototype = { }, toAverages() { return this.sum - .map((value) => (value ? value / this.count : value)) + .map(value => (value ? value / this.count : value)) .join(', '); }, }; diff --git a/test/utils/utils.js b/test/utils/utils.js index c7586c244..7a30f2633 100644 --- a/test/utils/utils.js +++ b/test/utils/utils.js @@ -38,7 +38,7 @@ const main = { deferred.reject(err); } else { const promises = []; - _.each(files, (file) => { + _.each(files, file => { promises.push(remove(`${path}/${file}`)); }); @@ -46,7 +46,7 @@ const main = { .then(() => { deferred.resolve(); }) - .catch((error) => { + .catch(error => { deferred.reject(error); }); } From 8ec8baa5c68c45fb6de14aa0b7d24928d131d1c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=40Siemienik=20Pawe=C5=82?= Date: Mon, 28 Sep 2020 22:53:31 +0200 Subject: [PATCH 3/4] change max-len value, lint:fix --- .eslintrc | 2 +- .prettier | 2 +- benchmark.js | 34 ++++- excel.js | 4 +- lib/csv/csv.js | 11 +- lib/csv/stream-converter.js | 6 +- lib/doc/anchor.js | 8 +- lib/doc/cell.js | 7 +- lib/doc/column.js | 11 +- lib/doc/defined-names.js | 8 +- lib/doc/range.js | 7 +- lib/doc/row.js | 4 +- lib/doc/workbook.js | 13 +- lib/doc/worksheet.js | 28 +++- lib/stream/xlsx/sheet-rels-writer.js | 4 +- lib/stream/xlsx/workbook-reader.js | 14 +- lib/stream/xlsx/workbook-writer.js | 24 +++- lib/stream/xlsx/worksheet-reader.js | 5 +- lib/stream/xlsx/worksheet-writer.js | 6 +- lib/utils/cell-matrix.js | 4 +- lib/utils/col-cache.js | 42 +++++- lib/utils/shared-formula.js | 49 +++---- lib/utils/under-dash.js | 7 +- lib/utils/utils.js | 4 +- lib/xlsx/defaultnumformats.js | 126 +++++++++++++++--- lib/xlsx/rel-type.js | 12 +- lib/xlsx/xform/book/workbook-xform.js | 21 ++- lib/xlsx/xform/comment/vml-anchor-xform.js | 4 +- .../xform/comment/vml-client-data-xform.js | 6 +- lib/xlsx/xform/comment/vml-notes-xform.js | 7 +- lib/xlsx/xform/comment/vml-shape-xform.js | 6 +- lib/xlsx/xform/core/content-types-xform.js | 33 ++++- lib/xlsx/xform/core/core-xform.js | 12 +- lib/xlsx/xform/sheet/cell-xform.js | 8 +- .../xform/sheet/cf-ext/databar-ext-xform.js | 28 +++- .../sheet/cf/conditional-formattings-xform.js | 5 +- lib/xlsx/xform/sheet/col-xform.js | 12 +- .../xform/sheet/outline-properties-xform.js | 8 +- lib/xlsx/xform/sheet/row-xform.js | 11 +- lib/xlsx/xform/sheet/sheet-view-xform.js | 5 +- lib/xlsx/xform/sheet/worksheet-xform.js | 29 +++- lib/xlsx/xform/strings/text-xform.js | 4 +- lib/xlsx/xform/style/alignment-xform.js | 28 +++- lib/xlsx/xform/style/font-xform.js | 5 +- lib/xlsx/xform/style/styles-xform.js | 45 +++++-- lib/xlsx/xlsx.js | 15 ++- 46 files changed, 585 insertions(+), 149 deletions(-) diff --git a/.eslintrc b/.eslintrc index 9342c97f5..69ebb7529 100644 --- a/.eslintrc +++ b/.eslintrc @@ -19,7 +19,7 @@ "default-case": ["off"], "func-names": ["off", "never"], "global-require": ["off"], - "max-len": ["error", {"code": 160, "ignoreComments": true, "ignoreStrings": true}], + "max-len": ["error", {"code": 100, "ignoreComments": true, "ignoreStrings": true}], "no-console": ["error", { "allow": ["warn"] }], "no-continue": ["off"], "no-mixed-operators": ["error", {"allowSamePrecedence": true}], diff --git a/.prettier b/.prettier index dc9121c80..808c4a5ee 100644 --- a/.prettier +++ b/.prettier @@ -1,6 +1,6 @@ { "bracketSpacing": false, - "printWidth": 160, + "printWidth": 100, "trailingComma": "all", "bracketSpacing": true, "arrowParens": "avoid" diff --git a/benchmark.js b/benchmark.js index ca698f02d..9070a0013 100644 --- a/benchmark.js +++ b/benchmark.js @@ -8,7 +8,9 @@ const runs = 3; await runProfiling('huge xlsx file streams', () => { return new Promise((resolve, reject) => { // Data taken from http://eforexcel.com/wp/downloads-18-sample-csv-files-data-sets-for-testing-sales/ - const workbookReader = new ExcelJS.stream.xlsx.WorkbookReader('./spec/integration/data/huge.xlsx'); + const workbookReader = new ExcelJS.stream.xlsx.WorkbookReader( + './spec/integration/data/huge.xlsx' + ); workbookReader.read(); let worksheetCount = 0; @@ -32,7 +34,9 @@ const runs = 3; await runProfiling('huge xlsx file async iteration', async () => { // Data taken from http://eforexcel.com/wp/downloads-18-sample-csv-files-data-sets-for-testing-sales/ - const workbookReader = new ExcelJS.stream.xlsx.WorkbookReader('spec/integration/data/huge.xlsx'); + const workbookReader = new ExcelJS.stream.xlsx.WorkbookReader( + 'spec/integration/data/huge.xlsx' + ); let worksheetCount = 0; let rowCount = 0; for await (const worksheetReader of workbookReader) { @@ -55,13 +59,21 @@ const runs = 3; async function runProfiling(name, run) { console.log(''); console.log('####################################################'); - console.log(`WARMUP: Current memory usage: ${currentMemoryUsage({runGarbageCollector: true})} MB`); + console.log( + `WARMUP: Current memory usage: ${currentMemoryUsage({runGarbageCollector: true})} MB` + ); console.log(`WARMUP: ${name} profiling started`); const warmupStartTime = Date.now(); await run(); console.log(`WARMUP: ${name} profiling finished in ${Date.now() - warmupStartTime}ms`); - console.log(`WARMUP: Current memory usage (before GC): ${currentMemoryUsage({runGarbageCollector: false})} MB`); - console.log(`WARMUP: Current memory usage (after GC): ${currentMemoryUsage({runGarbageCollector: true})} MB`); + console.log( + `WARMUP: Current memory usage (before GC): ${currentMemoryUsage({ + runGarbageCollector: false, + })} MB` + ); + console.log( + `WARMUP: Current memory usage (after GC): ${currentMemoryUsage({runGarbageCollector: true})} MB` + ); for (let i = 1; i <= runs; i += 1) { console.log(''); @@ -70,8 +82,16 @@ async function runProfiling(name, run) { const startTime = Date.now(); await run(); // eslint-disable-line no-await-in-loop console.log(`RUN ${i}: ${name} profiling finished in ${Date.now() - startTime}ms`); - console.log(`RUN ${i}: Current memory usage (before GC): ${currentMemoryUsage({runGarbageCollector: false})} MB`); - console.log(`RUN ${i}: Current memory usage (after GC): ${currentMemoryUsage({runGarbageCollector: true})} MB`); + console.log( + `RUN ${i}: Current memory usage (before GC): ${currentMemoryUsage({ + runGarbageCollector: false, + })} MB` + ); + console.log( + `RUN ${i}: Current memory usage (after GC): ${currentMemoryUsage({ + runGarbageCollector: true, + })} MB` + ); } } diff --git a/excel.js b/excel.js index 4524877bb..acbb71bb8 100644 --- a/excel.js +++ b/excel.js @@ -5,7 +5,9 @@ */ if (parseInt(process.versions.node.split('.')[0], 10) < 10) { - throw new Error('For node versions older than 10, please use the ES5 Import: https://github.com/exceljs/exceljs#es5-imports'); + throw new Error( + 'For node versions older than 10, please use the ES5 Import: https://github.com/exceljs/exceljs#es5-imports' + ); } module.exports = require('./lib/exceljs.nodejs.js'); diff --git a/lib/csv/csv.js b/lib/csv/csv.js index fb6c70024..74a51084b 100644 --- a/lib/csv/csv.js +++ b/lib/csv/csv.js @@ -46,7 +46,12 @@ class CSV { return new Promise((resolve, reject) => { const worksheet = this.workbook.addWorksheet(options.sheetName); - const dateFormats = options.dateFormats || ['YYYY-MM-DD[T]HH:mm:ssZ', 'YYYY-MM-DD[T]HH:mm:ss', 'MM-DD-YYYY', 'YYYY-MM-DD']; + const dateFormats = options.dateFormats || [ + 'YYYY-MM-DD[T]HH:mm:ssZ', + 'YYYY-MM-DD[T]HH:mm:ss', + 'MM-DD-YYYY', + 'YYYY-MM-DD', + ]; const map = options.map || function(datum) { @@ -130,7 +135,9 @@ class CSV { } if (value instanceof Date) { if (dateFormat) { - return dateUTC ? dayjs.utc(value).format(dateFormat) : dayjs(value).format(dateFormat); + return dateUTC + ? dayjs.utc(value).format(dateFormat) + : dayjs(value).format(dateFormat); } return dateUTC ? dayjs.utc(value).format() : dayjs(value).format(); } diff --git a/lib/csv/stream-converter.js b/lib/csv/stream-converter.js index 639aa5b7d..f7706b25a 100644 --- a/lib/csv/stream-converter.js +++ b/lib/csv/stream-converter.js @@ -80,7 +80,11 @@ class StreamConverter { this.writeStarted = true; } - this.inner.write(this.convertInwards(data), encoding ? this.innerEncoding : undefined, callback); + this.inner.write( + this.convertInwards(data), + encoding ? this.innerEncoding : undefined, + callback + ); } read() { diff --git a/lib/doc/anchor.js b/lib/doc/anchor.js index c98bef374..a1f6cda98 100644 --- a/lib/doc/anchor.js +++ b/lib/doc/anchor.js @@ -56,13 +56,17 @@ class Anchor { } get colWidth() { - return this.worksheet && this.worksheet.getColumn(this.nativeCol + 1) && this.worksheet.getColumn(this.nativeCol + 1).isCustomWidth + return this.worksheet && + this.worksheet.getColumn(this.nativeCol + 1) && + this.worksheet.getColumn(this.nativeCol + 1).isCustomWidth ? Math.floor(this.worksheet.getColumn(this.nativeCol + 1).width * 10000) : 640000; } get rowHeight() { - return this.worksheet && this.worksheet.getRow(this.nativeRow + 1) && this.worksheet.getRow(this.nativeRow + 1).height + return this.worksheet && + this.worksheet.getRow(this.nativeRow + 1) && + this.worksheet.getRow(this.nativeRow + 1).height ? Math.floor(this.worksheet.getRow(this.nativeRow + 1).height * 10000) : 180000; } diff --git a/lib/doc/cell.js b/lib/doc/cell.js index 3ae2457a8..251dded27 100644 --- a/lib/doc/cell.js +++ b/lib/doc/cell.js @@ -787,7 +787,9 @@ class FormulaValue { get dependencies() { // find all the ranges and cells mentioned in the formula const ranges = this.formula.match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g); - const cells = this.formula.replace(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g, '').match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}/g); + const cells = this.formula + .replace(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g, '') + .match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}/g); return { ranges, cells, @@ -860,7 +862,8 @@ class FormulaValue { if (!this._translatedFormula && this.model.sharedFormula) { const {worksheet} = this.cell; const master = worksheet.findCell(this.model.sharedFormula); - this._translatedFormula = master && slideFormula(master.formula, master.address, this.model.address); + this._translatedFormula = + master && slideFormula(master.formula, master.address, this.model.address); } return this._translatedFormula; } diff --git a/lib/doc/column.js b/lib/doc/column.js index e5f8ceef0..f7636172c 100644 --- a/lib/doc/column.js +++ b/lib/doc/column.js @@ -122,7 +122,9 @@ class Column { } get collapsed() { - return !!(this._outlineLevel && this._outlineLevel >= this._worksheet.properties.outlineLevelCol); + return !!( + this._outlineLevel && this._outlineLevel >= this._worksheet.properties.outlineLevelCol + ); } toString() { @@ -134,7 +136,12 @@ class Column { } equivalentTo(other) { - return this.width === other.width && this.hidden === other.hidden && this.outlineLevel === other.outlineLevel && _.isEqual(this.style, other.style); + return ( + this.width === other.width && + this.hidden === other.hidden && + this.outlineLevel === other.outlineLevel && + _.isEqual(this.style, other.style) + ); } get isDefault() { diff --git a/lib/doc/defined-names.js b/lib/doc/defined-names.js index 597744207..cb3a4942f 100644 --- a/lib/doc/defined-names.js +++ b/lib/doc/defined-names.js @@ -73,7 +73,9 @@ class DefinedNames { } getNamesEx(address) { - return _.map(this.matrixMap, (matrix, name) => matrix.findCellEx(address) && name).filter(Boolean); + return _.map(this.matrixMap, (matrix, name) => matrix.findCellEx(address) && name).filter( + Boolean + ); } _explore(matrix, cell) { @@ -172,7 +174,9 @@ class DefinedNames { get model() { // To get names per cell - just iterate over all names finding cells if they exist - return _.map(this.matrixMap, (matrix, name) => this.getRanges(name, matrix)).filter(definedName => definedName.ranges.length); + return _.map(this.matrixMap, (matrix, name) => this.getRanges(name, matrix)).filter( + definedName => definedName.ranges.length + ); } set model(value) { diff --git a/lib/doc/range.js b/lib/doc/range.js index ff0ef8c00..096ebf1ed 100644 --- a/lib/doc/range.js +++ b/lib/doc/range.js @@ -237,7 +237,12 @@ class Range { containsEx(address) { if (address.sheetName && this.sheetName && address.sheetName !== this.sheetName) return false; - return address.row >= this.top && address.row <= this.bottom && address.col >= this.left && address.col <= this.right; + return ( + address.row >= this.top && + address.row <= this.bottom && + address.col >= this.left && + address.col <= this.right + ); } forEachAddress(cb) { diff --git a/lib/doc/row.js b/lib/doc/row.js index 520cc7fe9..054f52a6a 100644 --- a/lib/doc/row.js +++ b/lib/doc/row.js @@ -324,7 +324,9 @@ class Row { } get collapsed() { - return !!(this._outlineLevel && this._outlineLevel >= this._worksheet.properties.outlineLevelRow); + return !!( + this._outlineLevel && this._outlineLevel >= this._worksheet.properties.outlineLevelRow + ); } // ========================================================================= diff --git a/lib/doc/workbook.js b/lib/doc/workbook.js index 98c42c0ea..0044a7fad 100644 --- a/lib/doc/workbook.js +++ b/lib/doc/workbook.js @@ -59,7 +59,9 @@ class Workbook { if (options) { if (typeof options === 'string') { // eslint-disable-next-line no-console - console.trace('tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { argb: "rbg value" } }'); + console.trace( + 'tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { argb: "rbg value" } }' + ); options = { properties: { tabColor: {argb: options}, @@ -67,7 +69,9 @@ class Workbook { }; } else if (options.argb || options.theme || options.indexed) { // eslint-disable-next-line no-console - console.trace('tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { ... } }'); + console.trace( + 'tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { ... } }' + ); options = { properties: { tabColor: options, @@ -76,7 +80,10 @@ class Workbook { } } - const lastOrderNo = this._worksheets.reduce((acc, ws) => ((ws && ws.orderNo) > acc ? ws.orderNo : acc), 0); + const lastOrderNo = this._worksheets.reduce( + (acc, ws) => ((ws && ws.orderNo) > acc ? ws.orderNo : acc), + 0 + ); const worksheetOptions = Object.assign({}, options, { id, name, diff --git a/lib/doc/worksheet.js b/lib/doc/worksheet.js index b1ca37852..3bcfb377b 100644 --- a/lib/doc/worksheet.js +++ b/lib/doc/worksheet.js @@ -68,7 +68,11 @@ class Worksheet { orientation: 'portrait', horizontalDpi: 4294967295, verticalDpi: 4294967295, - fitToPage: !!(options.pageSetup && (options.pageSetup.fitToWidth || options.pageSetup.fitToHeight) && !options.pageSetup.scale), + fitToPage: !!( + options.pageSetup && + (options.pageSetup.fitToWidth || options.pageSetup.fitToHeight) && + !options.pageSetup.scale + ), pageOrder: 'downThenOver', blackAndWhite: false, draft: false, @@ -693,13 +697,21 @@ class Worksheet { }; if (options && 'spinCount' in options) { // force spinCount to be integer >= 0 - options.spinCount = Number.isFinite(options.spinCount) ? Math.round(Math.max(0, options.spinCount)) : 100000; + options.spinCount = Number.isFinite(options.spinCount) + ? Math.round(Math.max(0, options.spinCount)) + : 100000; } if (password) { this.sheetProtection.algorithmName = 'SHA-512'; this.sheetProtection.saltValue = Encryptor.randomBytes(16).toString('base64'); - this.sheetProtection.spinCount = options && 'spinCount' in options ? options.spinCount : 100000; // allow user specified spinCount - this.sheetProtection.hashValue = Encryptor.convertPasswordToHash(password, 'SHA512', this.sheetProtection.saltValue, this.sheetProtection.spinCount); + this.sheetProtection.spinCount = + options && 'spinCount' in options ? options.spinCount : 100000; // allow user specified spinCount + this.sheetProtection.hashValue = Encryptor.convertPasswordToHash( + password, + 'SHA512', + this.sheetProtection.saltValue, + this.sheetProtection.spinCount + ); } if (options) { this.sheetProtection = Object.assign(this.sheetProtection, options); @@ -755,13 +767,17 @@ class Worksheet { // Deprecated get tabColor() { // eslint-disable-next-line no-console - console.trace('worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor'); + console.trace( + 'worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor' + ); return this.properties.tabColor; } set tabColor(value) { // eslint-disable-next-line no-console - console.trace('worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor'); + console.trace( + 'worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor' + ); this.properties.tabColor = value; } diff --git a/lib/stream/xlsx/sheet-rels-writer.js b/lib/stream/xlsx/sheet-rels-writer.js index 28fb8b92a..6ef9beaba 100644 --- a/lib/stream/xlsx/sheet-rels-writer.js +++ b/lib/stream/xlsx/sheet-rels-writer.js @@ -103,7 +103,9 @@ class SheetRelsWriter { '/>' ); } else { - this.stream.write(``); + this.stream.write( + `` + ); } return rId; diff --git a/lib/stream/xlsx/workbook-reader.js b/lib/stream/xlsx/workbook-reader.js index cbaa81e59..8e686319f 100644 --- a/lib/stream/xlsx/workbook-reader.js +++ b/lib/stream/xlsx/workbook-reader.js @@ -280,7 +280,12 @@ class WorkbookReader extends EventEmitter { *_parseWorksheet(iterator, sheetNo) { this._emitEntry({type: 'worksheet', id: sheetNo}); - const worksheetReader = new WorksheetReader({workbook: this, id: sheetNo, iterator, options: this.options}); + const worksheetReader = new WorksheetReader({ + workbook: this, + id: sheetNo, + iterator, + options: this.options, + }); if (this.options.worksheets === 'emit') { yield {eventType: 'worksheet', value: worksheetReader}; } @@ -288,7 +293,12 @@ class WorkbookReader extends EventEmitter { *_parseHyperlinks(iterator, sheetNo) { this._emitEntry({type: 'hyperlinks', id: sheetNo}); - const hyperlinksReader = new HyperlinkReader({workbook: this, id: sheetNo, iterator, options: this.options}); + const hyperlinksReader = new HyperlinkReader({ + workbook: this, + id: sheetNo, + iterator, + options: this.options, + }); if (this.options.hyperlinks === 'emit') { yield {eventType: 'hyperlinks', value: hyperlinksReader}; } diff --git a/lib/stream/xlsx/workbook-writer.js b/lib/stream/xlsx/workbook-writer.js index 6816c58d6..2d97cec88 100644 --- a/lib/stream/xlsx/workbook-writer.js +++ b/lib/stream/xlsx/workbook-writer.js @@ -99,7 +99,14 @@ class WorkbookWriter { await this.promise; await this.addMedia(); await this._commitWorksheets(); - await Promise.all([this.addContentTypes(), this.addApp(), this.addCore(), this.addSharedStrings(), this.addStyles(), this.addWorkbookRels()]); + await Promise.all([ + this.addContentTypes(), + this.addApp(), + this.addCore(), + this.addSharedStrings(), + this.addStyles(), + this.addWorkbookRels(), + ]); await this.addWorkbook(); return this._finalize(); } @@ -131,7 +138,8 @@ class WorkbookWriter { // shared string handling // in fact, it's even possible to switch it mid-sheet options = options || {}; - const useSharedStrings = options.useSharedStrings !== undefined ? options.useSharedStrings : this.useSharedStrings; + const useSharedStrings = + options.useSharedStrings !== undefined ? options.useSharedStrings : this.useSharedStrings; if (options.tabColor) { // eslint-disable-next-line no-console @@ -281,12 +289,20 @@ class WorkbookWriter { {Id: `rId${count++}`, Type: RelType.Theme, Target: 'theme/theme1.xml'}, ]; if (this.sharedStrings.count) { - relationships.push({Id: `rId${count++}`, Type: RelType.SharedStrings, Target: 'sharedStrings.xml'}); + relationships.push({ + Id: `rId${count++}`, + Type: RelType.SharedStrings, + Target: 'sharedStrings.xml', + }); } this._worksheets.forEach(worksheet => { if (worksheet) { worksheet.rId = `rId${count++}`; - relationships.push({Id: worksheet.rId, Type: RelType.Worksheet, Target: `worksheets/sheet${worksheet.id}.xml`}); + relationships.push({ + Id: worksheet.rId, + Type: RelType.Worksheet, + Target: `worksheets/sheet${worksheet.id}.xml`, + }); } }); return new Promise(resolve => { diff --git a/lib/stream/xlsx/worksheet-reader.js b/lib/stream/xlsx/worksheet-reader.js index 8ad59d3d3..ade13f426 100644 --- a/lib/stream/xlsx/worksheet-reader.js +++ b/lib/stream/xlsx/worksheet-reader.js @@ -321,7 +321,10 @@ class WorksheetReader extends EventEmitter { default: if (utils.isDateFmt(cell.numFmt)) { - cell.value = utils.excelToDate(parseFloat(c.v.text), properties.model && properties.model.date1904); + cell.value = utils.excelToDate( + parseFloat(c.v.text), + properties.model && properties.model.date1904 + ); } else { cell.value = parseFloat(c.v.text); } diff --git a/lib/stream/xlsx/worksheet-writer.js b/lib/stream/xlsx/worksheet-writer.js index 47a199c62..480b59fe8 100644 --- a/lib/stream/xlsx/worksheet-writer.js +++ b/lib/stream/xlsx/worksheet-writer.js @@ -142,7 +142,11 @@ class WorksheetWriter { orientation: 'portrait', horizontalDpi: 4294967295, verticalDpi: 4294967295, - fitToPage: !!(options.pageSetup && (options.pageSetup.fitToWidth || options.pageSetup.fitToHeight) && !options.pageSetup.scale), + fitToPage: !!( + options.pageSetup && + (options.pageSetup.fitToWidth || options.pageSetup.fitToHeight) && + !options.pageSetup.scale + ), pageOrder: 'downThenOver', blackAndWhite: false, draft: false, diff --git a/lib/utils/cell-matrix.js b/lib/utils/cell-matrix.js index 121b5141d..7c0956b76 100644 --- a/lib/utils/cell-matrix.js +++ b/lib/utils/cell-matrix.js @@ -130,7 +130,9 @@ class CellMatrix { return row[col]; } if (create) { - return (row[col] = this.template ? Object.assign(address, JSON.parse(JSON.stringify(this.template))) : address); + return (row[col] = this.template + ? Object.assign(address, JSON.parse(JSON.stringify(this.template))) + : address); } return undefined; } diff --git a/lib/utils/col-cache.js b/lib/utils/col-cache.js index 00b83e693..e6bacc187 100644 --- a/lib/utils/col-cache.js +++ b/lib/utils/col-cache.js @@ -1,7 +1,34 @@ // ========================================================================= // Column Letter to Number conversion const colCache = { - _dictionary: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'], + _dictionary: [ + 'A', + 'B', + 'C', + 'D', + 'E', + 'F', + 'G', + 'H', + 'I', + 'J', + 'K', + 'L', + 'M', + 'N', + 'O', + 'P', + 'Q', + 'R', + 'S', + 'T', + 'U', + 'V', + 'W', + 'X', + 'Y', + 'Z', + ], _l2n: {}, _n2l: [], _level(n) { @@ -179,7 +206,13 @@ const colCache = { right, sheetName, tl: {address: tl, col: left, row: top, $col$row: `$${this.n2l(left)}$${top}`, sheetName}, - br: {address: br, col: right, row: bottom, $col$row: `$${this.n2l(right)}$${bottom}`, sheetName}, + br: { + address: br, + col: right, + row: bottom, + $col$row: `$${this.n2l(right)}$${bottom}`, + sheetName, + }, dimensions: `${tl}:${br}`, }; } @@ -202,7 +235,10 @@ const colCache = { case 2: return colCache.encodeAddress(arguments[0], arguments[1]); case 4: - return `${colCache.encodeAddress(arguments[0], arguments[1])}:${colCache.encodeAddress(arguments[2], arguments[3])}`; + return `${colCache.encodeAddress(arguments[0], arguments[1])}:${colCache.encodeAddress( + arguments[2], + arguments[3] + )}`; default: throw new Error('Can only encode with 2 or 4 arguments'); } diff --git a/lib/utils/shared-formula.js b/lib/utils/shared-formula.js index ad8d70d28..0c9f241fb 100644 --- a/lib/utils/shared-formula.js +++ b/lib/utils/shared-formula.js @@ -7,33 +7,36 @@ const CRrx = /^([$])?([a-z]+)([$])?([1-9][0-9]*)$/i; function slideFormula(formula, fromCell, toCell) { const offset = colCache.decode(fromCell); const to = colCache.decode(toCell); - return formula.replace(replacementCandidateRx, (refMatch, sheet, sheetMaybe, addrPart, trailingParen) => { - if (trailingParen) { - return refMatch; - } - const match = CRrx.exec(addrPart); - if (match) { - const colDollar = match[1]; - const colStr = match[2].toUpperCase(); - const rowDollar = match[3]; - const rowStr = match[4]; - if (colStr.length > 3 || (colStr.length === 3 && colStr > 'XFD')) { - // > XFD is the highest col number in excel 2007 and beyond, so this is a named range + return formula.replace( + replacementCandidateRx, + (refMatch, sheet, sheetMaybe, addrPart, trailingParen) => { + if (trailingParen) { return refMatch; } - let col = colCache.l2n(colStr); - let row = parseInt(rowStr, 10); - if (!colDollar) { - col += to.col - offset.col; + const match = CRrx.exec(addrPart); + if (match) { + const colDollar = match[1]; + const colStr = match[2].toUpperCase(); + const rowDollar = match[3]; + const rowStr = match[4]; + if (colStr.length > 3 || (colStr.length === 3 && colStr > 'XFD')) { + // > XFD is the highest col number in excel 2007 and beyond, so this is a named range + return refMatch; + } + let col = colCache.l2n(colStr); + let row = parseInt(rowStr, 10); + if (!colDollar) { + col += to.col - offset.col; + } + if (!rowDollar) { + row += to.row - offset.row; + } + const res = (sheet || '') + (colDollar || '') + colCache.n2l(col) + (rowDollar || '') + row; + return res; } - if (!rowDollar) { - row += to.row - offset.row; - } - const res = (sheet || '') + (colDollar || '') + colCache.n2l(col) + (rowDollar || '') + row; - return res; + return refMatch; } - return refMatch; - }); + ); } module.exports = { diff --git a/lib/utils/under-dash.js b/lib/utils/under-dash.js index 150e1d2a3..47a12b0fb 100644 --- a/lib/utils/under-dash.js +++ b/lib/utils/under-dash.js @@ -84,7 +84,12 @@ const _ = { }, escapeHtml(html) { - return html.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, '''); + return html + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); }, strcmp(a, b) { diff --git a/lib/utils/utils.js b/lib/utils/utils.js index f13669a87..9f79d632e 100644 --- a/lib/utils/utils.js +++ b/lib/utils/utils.js @@ -54,7 +54,9 @@ const utils = { return 25569 + d.getTime() / (24 * 3600 * 1000) - (date1904 ? 1462 : 0); }, excelToDate(v, date1904) { - const millisecondSinceEpoch = Math.round((v - 25569 + (date1904 ? 1462 : 0)) * 24 * 3600 * 1000); + const millisecondSinceEpoch = Math.round( + (v - 25569 + (date1904 ? 1462 : 0)) * 24 * 3600 * 1000 + ); return new Date(millisecondSinceEpoch); }, parsePath(filepath) { diff --git a/lib/xlsx/defaultnumformats.js b/lib/xlsx/defaultnumformats.js index 5839409f8..b0b7d08f0 100644 --- a/lib/xlsx/defaultnumformats.js +++ b/lib/xlsx/defaultnumformats.js @@ -19,16 +19,61 @@ module.exports = { 21: {f: 'h:mm:ss'}, 22: {f: 'm/d/yy "h":mm'}, - 27: {'zh-tw': '[$-404]e/m/d', 'zh-cn': 'yyyy"年"m"月"', 'ja-jp': '[$-411]ge.m.d', 'ko-kr': 'yyyy"年" mm"月" dd"日"'}, - 28: {'zh-tw': '[$-404]e"年"m"月"d"日"', 'zh-cn': 'm"月"d"日"', 'ja-jp': '[$-411]ggge"年"m"月"d"日"', 'ko-kr': 'mm-dd'}, - 29: {'zh-tw': '[$-404]e"年"m"月"d"日"', 'zh-cn': 'm"月"d"日"', 'ja-jp': '[$-411]ggge"年"m"月"d"日"', 'ko-kr': 'mm-dd'}, + 27: { + 'zh-tw': '[$-404]e/m/d', + 'zh-cn': 'yyyy"年"m"月"', + 'ja-jp': '[$-411]ge.m.d', + 'ko-kr': 'yyyy"年" mm"月" dd"日"', + }, + 28: { + 'zh-tw': '[$-404]e"年"m"月"d"日"', + 'zh-cn': 'm"月"d"日"', + 'ja-jp': '[$-411]ggge"年"m"月"d"日"', + 'ko-kr': 'mm-dd', + }, + 29: { + 'zh-tw': '[$-404]e"年"m"月"d"日"', + 'zh-cn': 'm"月"d"日"', + 'ja-jp': '[$-411]ggge"年"m"月"d"日"', + 'ko-kr': 'mm-dd', + }, 30: {'zh-tw': 'm/d/yy ', 'zh-cn': 'm-d-yy', 'ja-jp': 'm/d/yy', 'ko-kr': 'mm-dd-yy'}, - 31: {'zh-tw': 'yyyy"年"m"月"d"日"', 'zh-cn': 'yyyy"年"m"月"d"日"', 'ja-jp': 'yyyy"年"m"月"d"日"', 'ko-kr': 'yyyy"년" mm"월" dd"일"'}, - 32: {'zh-tw': 'hh"時"mm"分"', 'zh-cn': 'h"时"mm"分"', 'ja-jp': 'h"時"mm"分"', 'ko-kr': 'h"시" mm"분"'}, - 33: {'zh-tw': 'hh"時"mm"分"ss"秒"', 'zh-cn': 'h"时"mm"分"ss"秒"', 'ja-jp': 'h"時"mm"分"ss"秒"', 'ko-kr': 'h"시" mm"분" ss"초"'}, - 34: {'zh-tw': '上午/下午 hh"時"mm"分"', 'zh-cn': '上午/下午 h"时"mm"分"', 'ja-jp': 'yyyy"年"m"月"', 'ko-kr': 'yyyy-mm-dd'}, - 35: {'zh-tw': '上午/下午 hh"時"mm"分"ss"秒"', 'zh-cn': '上午/下午 h"时"mm"分"ss"秒"', 'ja-jp': 'm"月"d"日"', 'ko-kr': 'yyyy-mm-dd'}, - 36: {'zh-tw': '[$-404]e/m/d', 'zh-cn': 'yyyy"年"m"月"', 'ja-jp': '[$-411]ge.m.d', 'ko-kr': 'yyyy"年" mm"月" dd"日"'}, + 31: { + 'zh-tw': 'yyyy"年"m"月"d"日"', + 'zh-cn': 'yyyy"年"m"月"d"日"', + 'ja-jp': 'yyyy"年"m"月"d"日"', + 'ko-kr': 'yyyy"년" mm"월" dd"일"', + }, + 32: { + 'zh-tw': 'hh"時"mm"分"', + 'zh-cn': 'h"时"mm"分"', + 'ja-jp': 'h"時"mm"分"', + 'ko-kr': 'h"시" mm"분"', + }, + 33: { + 'zh-tw': 'hh"時"mm"分"ss"秒"', + 'zh-cn': 'h"时"mm"分"ss"秒"', + 'ja-jp': 'h"時"mm"分"ss"秒"', + 'ko-kr': 'h"시" mm"분" ss"초"', + }, + 34: { + 'zh-tw': '上午/下午 hh"時"mm"分"', + 'zh-cn': '上午/下午 h"时"mm"分"', + 'ja-jp': 'yyyy"年"m"月"', + 'ko-kr': 'yyyy-mm-dd', + }, + 35: { + 'zh-tw': '上午/下午 hh"時"mm"分"ss"秒"', + 'zh-cn': '上午/下午 h"时"mm"分"ss"秒"', + 'ja-jp': 'm"月"d"日"', + 'ko-kr': 'yyyy-mm-dd', + }, + 36: { + 'zh-tw': '[$-404]e/m/d', + 'zh-cn': 'yyyy"年"m"月"', + 'ja-jp': '[$-411]ge.m.d', + 'ko-kr': 'yyyy"年" mm"月" dd"日"', + }, 37: {f: '#,##0 ;(#,##0)'}, 38: {f: '#,##0 ;[Red](#,##0)'}, @@ -40,15 +85,60 @@ module.exports = { 48: {f: '##0.0E+0'}, 49: {f: '@'}, - 50: {'zh-tw': '[$-404]e/m/d', 'zh-cn': 'yyyy"年"m"月"', 'ja-jp': '[$-411]ge.m.d', 'ko-kr': 'yyyy"年" mm"月" dd"日"'}, - 51: {'zh-tw': '[$-404]e"年"m"月"d"日"', 'zh-cn': 'm"月"d"日"', 'ja-jp': '[$-411]ggge"年"m"月"d"日"', 'ko-kr': 'mm-dd'}, - 52: {'zh-tw': '上午/下午 hh"時"mm"分"', 'zh-cn': 'yyyy"年"m"月"', 'ja-jp': 'yyyy"年"m"月"', 'ko-kr': 'yyyy-mm-dd'}, - 53: {'zh-tw': '上午/下午 hh"時"mm"分"ss"秒"', 'zh-cn': 'm"月"d"日"', 'ja-jp': 'm"月"d"日"', 'ko-kr': 'yyyy-mm-dd'}, - 54: {'zh-tw': '[$-404]e"年"m"月"d"日"', 'zh-cn': 'm"月"d"日"', 'ja-jp': '[$-411]ggge"年"m"月"d"日"', 'ko-kr': 'mm-dd'}, - 55: {'zh-tw': '上午/下午 hh"時"mm"分"', 'zh-cn': '上午/下午 h"时"mm"分"', 'ja-jp': 'yyyy"年"m"月"', 'ko-kr': 'yyyy-mm-dd'}, - 56: {'zh-tw': '上午/下午 hh"時"mm"分"ss"秒"', 'zh-cn': '上午/下午 h"时"mm"分"ss"秒"', 'ja-jp': 'm"月"d"日"', 'ko-kr': 'yyyy-mm-dd'}, - 57: {'zh-tw': '[$-404]e/m/d', 'zh-cn': 'yyyy"年"m"月"', 'ja-jp': '[$-411]ge.m.d', 'ko-kr': 'yyyy"年" mm"月" dd"日"'}, - 58: {'zh-tw': '[$-404]e"年"m"月"d"日"', 'zh-cn': 'm"月"d"日"', 'ja-jp': '[$-411]ggge"年"m"月"d"日"', 'ko-kr': 'mm-dd'}, + 50: { + 'zh-tw': '[$-404]e/m/d', + 'zh-cn': 'yyyy"年"m"月"', + 'ja-jp': '[$-411]ge.m.d', + 'ko-kr': 'yyyy"年" mm"月" dd"日"', + }, + 51: { + 'zh-tw': '[$-404]e"年"m"月"d"日"', + 'zh-cn': 'm"月"d"日"', + 'ja-jp': '[$-411]ggge"年"m"月"d"日"', + 'ko-kr': 'mm-dd', + }, + 52: { + 'zh-tw': '上午/下午 hh"時"mm"分"', + 'zh-cn': 'yyyy"年"m"月"', + 'ja-jp': 'yyyy"年"m"月"', + 'ko-kr': 'yyyy-mm-dd', + }, + 53: { + 'zh-tw': '上午/下午 hh"時"mm"分"ss"秒"', + 'zh-cn': 'm"月"d"日"', + 'ja-jp': 'm"月"d"日"', + 'ko-kr': 'yyyy-mm-dd', + }, + 54: { + 'zh-tw': '[$-404]e"年"m"月"d"日"', + 'zh-cn': 'm"月"d"日"', + 'ja-jp': '[$-411]ggge"年"m"月"d"日"', + 'ko-kr': 'mm-dd', + }, + 55: { + 'zh-tw': '上午/下午 hh"時"mm"分"', + 'zh-cn': '上午/下午 h"时"mm"分"', + 'ja-jp': 'yyyy"年"m"月"', + 'ko-kr': 'yyyy-mm-dd', + }, + 56: { + 'zh-tw': '上午/下午 hh"時"mm"分"ss"秒"', + 'zh-cn': '上午/下午 h"时"mm"分"ss"秒"', + 'ja-jp': 'm"月"d"日"', + 'ko-kr': 'yyyy-mm-dd', + }, + 57: { + 'zh-tw': '[$-404]e/m/d', + 'zh-cn': 'yyyy"年"m"月"', + 'ja-jp': '[$-411]ge.m.d', + 'ko-kr': 'yyyy"年" mm"月" dd"日"', + }, + 58: { + 'zh-tw': '[$-404]e"年"m"月"d"日"', + 'zh-cn': 'm"月"d"日"', + 'ja-jp': '[$-411]ggge"年"m"月"d"日"', + 'ko-kr': 'mm-dd', + }, 59: {'th-th': 't0'}, 60: {'th-th': 't0.00'}, diff --git a/lib/xlsx/rel-type.js b/lib/xlsx/rel-type.js index 611cd3a98..7cd0a3d05 100644 --- a/lib/xlsx/rel-type.js +++ b/lib/xlsx/rel-type.js @@ -1,16 +1,20 @@ 'use strict'; module.exports = { - OfficeDocument: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', + OfficeDocument: + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', Worksheet: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet', CalcChain: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain', - SharedStrings: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings', + SharedStrings: + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings', Styles: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles', Theme: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', Hyperlink: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', Image: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', - CoreProperties: 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', - ExtenderProperties: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', + CoreProperties: + 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', + ExtenderProperties: + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', Comments: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments', VmlDrawing: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing', Table: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/table', diff --git a/lib/xlsx/xform/book/workbook-xform.js b/lib/xlsx/xform/book/workbook-xform.js index 2047d72c8..5c10a5857 100644 --- a/lib/xlsx/xform/book/workbook-xform.js +++ b/lib/xlsx/xform/book/workbook-xform.js @@ -19,9 +19,17 @@ class WorkbookXform extends BaseXform { this.map = { fileVersion: WorkbookXform.STATIC_XFORMS.fileVersion, workbookPr: new WorkbookPropertiesXform(), - bookViews: new ListXform({tag: 'bookViews', count: false, childXform: new WorkbookViewXform()}), + bookViews: new ListXform({ + tag: 'bookViews', + count: false, + childXform: new WorkbookViewXform(), + }), sheets: new ListXform({tag: 'sheets', count: false, childXform: new SheetXform()}), - definedNames: new ListXform({tag: 'definedNames', count: false, childXform: new DefinedNameXform()}), + definedNames: new ListXform({ + tag: 'definedNames', + count: false, + childXform: new DefinedNameXform(), + }), calcPr: new WorkbookCalcPropertiesXform(), }; } @@ -45,7 +53,10 @@ class WorkbookXform extends BaseXform { }); } - if (sheet.pageSetup && (sheet.pageSetup.printTitlesRow || sheet.pageSetup.printTitlesColumn)) { + if ( + sheet.pageSetup && + (sheet.pageSetup.printTitlesRow || sheet.pageSetup.printTitlesColumn) + ) { const ranges = []; if (sheet.pageSetup.printTitlesColumn) { @@ -183,7 +194,9 @@ class WorkbookXform extends BaseXform { worksheet.pageSetup = {}; } const range = colCache.decodeEx(definedName.ranges[0]); - worksheet.pageSetup.printArea = worksheet.pageSetup.printArea ? `${worksheet.pageSetup.printArea}&&${range.dimensions}` : range.dimensions; + worksheet.pageSetup.printArea = worksheet.pageSetup.printArea + ? `${worksheet.pageSetup.printArea}&&${range.dimensions}` + : range.dimensions; } } else if (definedName.name === '_xlnm.Print_Titles') { worksheet = worksheets[definedName.localSheetId]; diff --git a/lib/xlsx/xform/comment/vml-anchor-xform.js b/lib/xlsx/xform/comment/vml-anchor-xform.js index 1ed68a02c..3e00136e0 100644 --- a/lib/xlsx/xform/comment/vml-anchor-xform.js +++ b/lib/xlsx/xform/comment/vml-anchor-xform.js @@ -31,7 +31,9 @@ class VmlAnchorXform extends BaseXform { } render(xmlStream, model) { - const rect = model.anchor ? this.getAnchorRect(model.anchor) : this.getDefaultRect(model.refAddress); + const rect = model.anchor + ? this.getAnchorRect(model.anchor) + : this.getDefaultRect(model.refAddress); xmlStream.leafNode('x:Anchor', null, rect.join(', ')); } diff --git a/lib/xlsx/xform/comment/vml-client-data-xform.js b/lib/xlsx/xform/comment/vml-client-data-xform.js index 7fc24d353..f09a3c7fd 100644 --- a/lib/xlsx/xform/comment/vml-client-data-xform.js +++ b/lib/xlsx/xform/comment/vml-client-data-xform.js @@ -79,7 +79,11 @@ class VmlClientDataXform extends BaseXform { } normalizeModel() { - const position = Object.assign({}, this.map['x:MoveWithCells'].model, this.map['x:SizeWithCells'].model); + const position = Object.assign( + {}, + this.map['x:MoveWithCells'].model, + this.map['x:SizeWithCells'].model + ); const len = Object.keys(position).length; this.model.editAs = POSITION_TYPE[len]; this.model.anchor = this.map['x:Anchor'].text; diff --git a/lib/xlsx/xform/comment/vml-notes-xform.js b/lib/xlsx/xform/comment/vml-notes-xform.js index 28fe95474..4b1a2ab9c 100644 --- a/lib/xlsx/xform/comment/vml-notes-xform.js +++ b/lib/xlsx/xform/comment/vml-notes-xform.js @@ -25,7 +25,12 @@ class VmlNotesXform extends BaseXform { xmlStream.leafNode('o:idmap', {'v:ext': 'edit', data: 1}); xmlStream.closeNode(); - xmlStream.openNode('v:shapetype', {id: '_x0000_t202', coordsize: '21600,21600', 'o:spt': 202, path: 'm,l,21600r21600,l21600,xe'}); + xmlStream.openNode('v:shapetype', { + id: '_x0000_t202', + coordsize: '21600,21600', + 'o:spt': 202, + path: 'm,l,21600r21600,l21600,xe', + }); xmlStream.leafNode('v:stroke', {joinstyle: 'miter'}); xmlStream.leafNode('v:path', {gradientshapeok: 't', 'o:connecttype': 'rect'}); xmlStream.closeNode(); diff --git a/lib/xlsx/xform/comment/vml-shape-xform.js b/lib/xlsx/xform/comment/vml-shape-xform.js index a34ad3136..6eb0bfeba 100644 --- a/lib/xlsx/xform/comment/vml-shape-xform.js +++ b/lib/xlsx/xform/comment/vml-shape-xform.js @@ -71,7 +71,8 @@ class VmlShapeXform extends BaseXform { switch (name) { case this.tag: this.model.margins.inset = this.map['v:textbox'].model && this.map['v:textbox'].model.inset; - this.model.protection = this.map['x:ClientData'].model && this.map['x:ClientData'].model.protection; + this.model.protection = + this.map['x:ClientData'].model && this.map['x:ClientData'].model.protection; this.model.anchor = this.map['x:ClientData'].model && this.map['x:ClientData'].model.anchor; this.model.editAs = this.map['x:ClientData'].model && this.map['x:ClientData'].model.editAs; return false; @@ -84,7 +85,8 @@ class VmlShapeXform extends BaseXform { VmlShapeXform.V_SHAPE_ATTRIBUTES = (model, index) => ({ id: `_x0000_s${1025 + index}`, type: '#_x0000_t202', - style: 'position:absolute; margin-left:105.3pt;margin-top:10.5pt;width:97.8pt;height:59.1pt;z-index:1;visibility:hidden', + style: + 'position:absolute; margin-left:105.3pt;margin-top:10.5pt;width:97.8pt;height:59.1pt;z-index:1;visibility:hidden', fillcolor: 'infoBackground [80]', strokecolor: 'none [81]', 'o:insetmode': model.note.margins && model.note.margins.insetmode, diff --git a/lib/xlsx/xform/core/content-types-xform.js b/lib/xlsx/xform/core/content-types-xform.js index d3babcf61..2999c62aa 100644 --- a/lib/xlsx/xform/core/content-types-xform.js +++ b/lib/xlsx/xform/core/content-types-xform.js @@ -21,7 +21,10 @@ class ContentTypesXform extends BaseXform { } }); - xmlStream.leafNode('Default', {Extension: 'rels', ContentType: 'application/vnd.openxmlformats-package.relationships+xml'}); + xmlStream.leafNode('Default', { + Extension: 'rels', + ContentType: 'application/vnd.openxmlformats-package.relationships+xml', + }); xmlStream.leafNode('Default', {Extension: 'xml', ContentType: 'application/xml'}); xmlStream.leafNode('Override', { @@ -31,17 +34,27 @@ class ContentTypesXform extends BaseXform { model.worksheets.forEach(worksheet => { const name = `/xl/worksheets/sheet${worksheet.id}.xml`; - xmlStream.leafNode('Override', {PartName: name, ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml'}); + xmlStream.leafNode('Override', { + PartName: name, + ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml', + }); }); - xmlStream.leafNode('Override', {PartName: '/xl/theme/theme1.xml', ContentType: 'application/vnd.openxmlformats-officedocument.theme+xml'}); - xmlStream.leafNode('Override', {PartName: '/xl/styles.xml', ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml'}); + xmlStream.leafNode('Override', { + PartName: '/xl/theme/theme1.xml', + ContentType: 'application/vnd.openxmlformats-officedocument.theme+xml', + }); + xmlStream.leafNode('Override', { + PartName: '/xl/styles.xml', + ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml', + }); const hasSharedStrings = model.sharedStrings && model.sharedStrings.count; if (hasSharedStrings) { xmlStream.leafNode('Override', { PartName: '/xl/sharedStrings.xml', - ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml', + ContentType: + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml', }); } @@ -77,8 +90,14 @@ class ContentTypesXform extends BaseXform { }); } - xmlStream.leafNode('Override', {PartName: '/docProps/core.xml', ContentType: 'application/vnd.openxmlformats-package.core-properties+xml'}); - xmlStream.leafNode('Override', {PartName: '/docProps/app.xml', ContentType: 'application/vnd.openxmlformats-officedocument.extended-properties+xml'}); + xmlStream.leafNode('Override', { + PartName: '/docProps/core.xml', + ContentType: 'application/vnd.openxmlformats-package.core-properties+xml', + }); + xmlStream.leafNode('Override', { + PartName: '/docProps/app.xml', + ContentType: 'application/vnd.openxmlformats-officedocument.extended-properties+xml', + }); xmlStream.closeNode(); } diff --git a/lib/xlsx/xform/core/core-xform.js b/lib/xlsx/xform/core/core-xform.js index 1edb90df8..cedde0f77 100644 --- a/lib/xlsx/xform/core/core-xform.js +++ b/lib/xlsx/xform/core/core-xform.js @@ -23,8 +23,16 @@ class CoreXform extends BaseXform { 'cp:version': new StringXform({tag: 'cp:version'}), 'cp:contentStatus': new StringXform({tag: 'cp:contentStatus'}), 'cp:contentType': new StringXform({tag: 'cp:contentType'}), - 'dcterms:created': new DateXform({tag: 'dcterms:created', attrs: CoreXform.DateAttrs, format: CoreXform.DateFormat}), - 'dcterms:modified': new DateXform({tag: 'dcterms:modified', attrs: CoreXform.DateAttrs, format: CoreXform.DateFormat}), + 'dcterms:created': new DateXform({ + tag: 'dcterms:created', + attrs: CoreXform.DateAttrs, + format: CoreXform.DateFormat, + }), + 'dcterms:modified': new DateXform({ + tag: 'dcterms:modified', + attrs: CoreXform.DateAttrs, + format: CoreXform.DateFormat, + }), }; } diff --git a/lib/xlsx/xform/sheet/cell-xform.js b/lib/xlsx/xform/sheet/cell-xform.js index 2e78bf36c..41715695a 100644 --- a/lib/xlsx/xform/sheet/cell-xform.js +++ b/lib/xlsx/xform/sheet/cell-xform.js @@ -107,7 +107,9 @@ class CellXform extends BaseXform { } else if (model.sharedFormula) { const master = options.formulae[model.sharedFormula]; if (!master) { - throw new Error(`Shared Formula master must exist above and or left of clone for cell ${model.address}`); + throw new Error( + `Shared Formula master must exist above and or left of clone for cell ${model.address}` + ); } if (master.si === undefined) { master.shareType = 'shared'; @@ -326,7 +328,9 @@ class CellXform extends BaseXform { case 'v': case 't': if (this.model.value && this.model.value.richText) { - this.model.value.richText.text = this.model.value.richText.text ? this.model.value.richText.text + text : text; + this.model.value.richText.text = this.model.value.richText.text + ? this.model.value.richText.text + text + : text; } else { this.model.value = this.model.value ? this.model.value + text : text; } diff --git a/lib/xlsx/xform/sheet/cf-ext/databar-ext-xform.js b/lib/xlsx/xform/sheet/cf-ext/databar-ext-xform.js index 05feeb3e6..0901c5ab0 100644 --- a/lib/xlsx/xform/sheet/cf-ext/databar-ext-xform.js +++ b/lib/xlsx/xform/sheet/cf-ext/databar-ext-xform.js @@ -11,8 +11,12 @@ class DatabarExtXform extends CompositeXform { this.map = { 'x14:cfvo': (this.cfvoXform = new CfvoExtXform()), 'x14:borderColor': (this.borderColorXform = new ColorXform('x14:borderColor')), - 'x14:negativeBorderColor': (this.negativeBorderColorXform = new ColorXform('x14:negativeBorderColor')), - 'x14:negativeFillColor': (this.negativeFillColorXform = new ColorXform('x14:negativeFillColor')), + 'x14:negativeBorderColor': (this.negativeBorderColorXform = new ColorXform( + 'x14:negativeBorderColor' + )), + 'x14:negativeFillColor': (this.negativeFillColorXform = new ColorXform( + 'x14:negativeFillColor' + )), 'x14:axisColor': (this.axisColorXform = new ColorXform('x14:axisColor')), }; } @@ -33,8 +37,14 @@ class DatabarExtXform extends CompositeXform { maxLength: BaseXform.toIntAttribute(model.maxLength, 100, true), border: BaseXform.toBoolAttribute(model.border, false), gradient: BaseXform.toBoolAttribute(model.gradient, true), - negativeBarColorSameAsPositive: BaseXform.toBoolAttribute(model.negativeBarColorSameAsPositive, true), - negativeBarBorderColorSameAsPositive: BaseXform.toBoolAttribute(model.negativeBarBorderColorSameAsPositive, true), + negativeBarColorSameAsPositive: BaseXform.toBoolAttribute( + model.negativeBarColorSameAsPositive, + true + ), + negativeBarBorderColorSameAsPositive: BaseXform.toBoolAttribute( + model.negativeBarBorderColorSameAsPositive, + true + ), axisPosition: BaseXform.toAttribute(model.axisPosition, 'auto'), direction: BaseXform.toAttribute(model.direction, 'leftToRight'), }); @@ -58,8 +68,14 @@ class DatabarExtXform extends CompositeXform { maxLength: BaseXform.toIntValue(attributes.maxLength, 100), border: BaseXform.toBoolValue(attributes.border, false), gradient: BaseXform.toBoolValue(attributes.gradient, true), - negativeBarColorSameAsPositive: BaseXform.toBoolValue(attributes.negativeBarColorSameAsPositive, true), - negativeBarBorderColorSameAsPositive: BaseXform.toBoolValue(attributes.negativeBarBorderColorSameAsPositive, true), + negativeBarColorSameAsPositive: BaseXform.toBoolValue( + attributes.negativeBarColorSameAsPositive, + true + ), + negativeBarBorderColorSameAsPositive: BaseXform.toBoolValue( + attributes.negativeBarBorderColorSameAsPositive, + true + ), axisPosition: BaseXform.toStringValue(attributes.axisPosition, 'auto'), direction: BaseXform.toStringValue(attributes.direction, 'leftToRight'), }; diff --git a/lib/xlsx/xform/sheet/cf/conditional-formattings-xform.js b/lib/xlsx/xform/sheet/cf/conditional-formattings-xform.js index 11756865c..548b16f63 100644 --- a/lib/xlsx/xform/sheet/cf/conditional-formattings-xform.js +++ b/lib/xlsx/xform/sheet/cf/conditional-formattings-xform.js @@ -19,7 +19,10 @@ class ConditionalFormattingsXform extends BaseXform { prepare(model, options) { // ensure each rule has a priority value - let nextPriority = model.reduce((p, cf) => Math.max(p, ...cf.rules.map(rule => rule.priority || 0)), 1); + let nextPriority = model.reduce( + (p, cf) => Math.max(p, ...cf.rules.map(rule => rule.priority || 0)), + 1 + ); model.forEach(cf => { cf.rules.forEach(rule => { if (!rule.priority) { diff --git a/lib/xlsx/xform/sheet/col-xform.js b/lib/xlsx/xform/sheet/col-xform.js index fe87f4dc8..93003cbdf 100644 --- a/lib/xlsx/xform/sheet/col-xform.js +++ b/lib/xlsx/xform/sheet/col-xform.js @@ -43,12 +43,20 @@ class ColXform extends BaseXform { const model = (this.model = { min: parseInt(node.attributes.min || '0', 10), max: parseInt(node.attributes.max || '0', 10), - width: node.attributes.width === undefined ? undefined : parseFloat(node.attributes.width || '0'), + width: + node.attributes.width === undefined + ? undefined + : parseFloat(node.attributes.width || '0'), }); if (node.attributes.style) { model.styleId = parseInt(node.attributes.style, 10); } - if (node.attributes.hidden === true || node.attributes.hidden === 'true' || node.attributes.hidden === 1 || node.attributes.hidden === '1') { + if ( + node.attributes.hidden === true || + node.attributes.hidden === 'true' || + node.attributes.hidden === 1 || + node.attributes.hidden === '1' + ) { model.hidden = true; } if (node.attributes.bestFit) { diff --git a/lib/xlsx/xform/sheet/outline-properties-xform.js b/lib/xlsx/xform/sheet/outline-properties-xform.js index b494c2490..59de15266 100644 --- a/lib/xlsx/xform/sheet/outline-properties-xform.js +++ b/lib/xlsx/xform/sheet/outline-properties-xform.js @@ -21,8 +21,12 @@ class OutlinePropertiesXform extends BaseXform { parseOpen(node) { if (node.name === this.tag) { this.model = { - summaryBelow: isDefined(node.attributes.summaryBelow) ? Boolean(Number(node.attributes.summaryBelow)) : undefined, - summaryRight: isDefined(node.attributes.summaryRight) ? Boolean(Number(node.attributes.summaryRight)) : undefined, + summaryBelow: isDefined(node.attributes.summaryBelow) + ? Boolean(Number(node.attributes.summaryBelow)) + : undefined, + summaryRight: isDefined(node.attributes.summaryRight) + ? Boolean(Number(node.attributes.summaryRight)) + : undefined, }; return true; } diff --git a/lib/xlsx/xform/sheet/row-xform.js b/lib/xlsx/xform/sheet/row-xform.js index c278839f1..4ccb73fee 100644 --- a/lib/xlsx/xform/sheet/row-xform.js +++ b/lib/xlsx/xform/sheet/row-xform.js @@ -67,7 +67,9 @@ class RowXform extends BaseXform { } if (node.name === 'row') { this.numRowsSeen += 1; - const spans = node.attributes.spans ? node.attributes.spans.split(':').map(span => parseInt(span, 10)) : [undefined, undefined]; + const spans = node.attributes.spans + ? node.attributes.spans.split(':').map(span => parseInt(span, 10)) + : [undefined, undefined]; const model = (this.model = { number: parseInt(node.attributes.r, 10), min: spans[0], @@ -77,7 +79,12 @@ class RowXform extends BaseXform { if (node.attributes.s) { model.styleId = parseInt(node.attributes.s, 10); } - if (node.attributes.hidden === true || node.attributes.hidden === 'true' || node.attributes.hidden === 1 || node.attributes.hidden === '1') { + if ( + node.attributes.hidden === true || + node.attributes.hidden === 'true' || + node.attributes.hidden === 1 || + node.attributes.hidden === '1' + ) { model.hidden = true; } if (node.attributes.bestFit) { diff --git a/lib/xlsx/xform/sheet/sheet-view-xform.js b/lib/xlsx/xform/sheet/sheet-view-xform.js index 7e6db038d..f53fdcd1f 100644 --- a/lib/xlsx/xform/sheet/sheet-view-xform.js +++ b/lib/xlsx/xform/sheet/sheet-view-xform.js @@ -50,7 +50,10 @@ class SheetViewXform extends BaseXform { xSplit = model.xSplit || 0; ySplit = model.ySplit || 0; topLeftCell = model.topLeftCell || colCache.getAddress(ySplit + 1, xSplit + 1).address; - activePane = (model.xSplit && model.ySplit && 'bottomRight') || (model.xSplit && 'topRight') || 'bottomLeft'; + activePane = + (model.xSplit && model.ySplit && 'bottomRight') || + (model.xSplit && 'topRight') || + 'bottomLeft'; xmlStream.leafNode('pane', { xSplit: model.xSplit || undefined, diff --git a/lib/xlsx/xform/sheet/worksheet-xform.js b/lib/xlsx/xform/sheet/worksheet-xform.js index bf68ab725..4b36e37ba 100644 --- a/lib/xlsx/xform/sheet/worksheet-xform.js +++ b/lib/xlsx/xform/sheet/worksheet-xform.js @@ -96,7 +96,11 @@ class WorkSheetXform extends BaseXform { this.map = { sheetPr: new SheetPropertiesXform(), dimension: new DimensionXform(), - sheetViews: new ListXform({tag: 'sheetViews', count: false, childXform: new SheetViewXform()}), + sheetViews: new ListXform({ + tag: 'sheetViews', + count: false, + childXform: new SheetViewXform(), + }), sheetFormatPr: new SheetFormatPropertiesXform(), cols: new ListXform({tag: 'cols', count: false, childXform: new ColXform()}), sheetData: new ListXform({ @@ -109,7 +113,11 @@ class WorkSheetXform extends BaseXform { autoFilter: new AutoFilterXform(), mergeCells: new ListXform({tag: 'mergeCells', count: true, childXform: new MergeCellXform()}), rowBreaks: new RowBreaksXform(), - hyperlinks: new ListXform({tag: 'hyperlinks', count: false, childXform: new HyperlinkXform()}), + hyperlinks: new ListXform({ + tag: 'hyperlinks', + count: false, + childXform: new HyperlinkXform(), + }), pageMargins: new PageMarginsXform(), dataValidations: new DataValidationsXform(), pageSetup: new PageSetupXform(), @@ -212,7 +220,10 @@ class WorkSheetXform extends BaseXform { Target: `../drawings/${drawing.name}.xml`, }); } - let rIdImage = this.preImageId === medium.imageId ? drawingRelsHash[medium.imageId] : drawingRelsHash[drawing.rels.length]; + let rIdImage = + this.preImageId === medium.imageId + ? drawingRelsHash[medium.imageId] + : drawingRelsHash[drawing.rels.length]; if (!rIdImage) { rIdImage = nextRid(drawing.rels); drawingRelsHash[drawing.rels.length] = rIdImage; @@ -387,10 +398,18 @@ class WorkSheetXform extends BaseXform { properties.outlineProperties = this.map.sheetPr.model.outlineProperties; } const sheetProperties = { - fitToPage: (this.map.sheetPr.model && this.map.sheetPr.model.pageSetup && this.map.sheetPr.model.pageSetup.fitToPage) || false, + fitToPage: + (this.map.sheetPr.model && + this.map.sheetPr.model.pageSetup && + this.map.sheetPr.model.pageSetup.fitToPage) || + false, margins: this.map.pageMargins.model, }; - const pageSetup = Object.assign(sheetProperties, this.map.pageSetup.model, this.map.printOptions.model); + const pageSetup = Object.assign( + sheetProperties, + this.map.pageSetup.model, + this.map.printOptions.model + ); const conditionalFormattings = mergeConditionalFormattings( this.map.conditionalFormatting.model, this.map.extLst.model && this.map.extLst.model['x14:conditionalFormattings'] diff --git a/lib/xlsx/xform/strings/text-xform.js b/lib/xlsx/xform/strings/text-xform.js index 5482f21ff..7604306e1 100644 --- a/lib/xlsx/xform/strings/text-xform.js +++ b/lib/xlsx/xform/strings/text-xform.js @@ -17,7 +17,9 @@ class TextXform extends BaseXform { } get model() { - return this._text.join('').replace(/_x([0-9A-F]{4})_/g, ($0, $1) => String.fromCharCode(parseInt($1, 16))); + return this._text + .join('') + .replace(/_x([0-9A-F]{4})_/g, ($0, $1) => String.fromCharCode(parseInt($1, 16))); } parseOpen(node) { diff --git a/lib/xlsx/xform/style/alignment-xform.js b/lib/xlsx/xform/style/alignment-xform.js index a38b3daab..6cd7eb11a 100644 --- a/lib/xlsx/xform/style/alignment-xform.js +++ b/lib/xlsx/xform/style/alignment-xform.js @@ -4,7 +4,15 @@ const utils = require('../../../utils/utils'); const BaseXform = require('../base-xform'); const validation = { - horizontalValues: ['left', 'center', 'right', 'fill', 'centerContinuous', 'distributed', 'justify'].reduce((p, v) => { + horizontalValues: [ + 'left', + 'center', + 'right', + 'fill', + 'centerContinuous', + 'distributed', + 'justify', + ].reduce((p, v) => { p[v] = true; return p; }, {}), @@ -132,12 +140,24 @@ class AlignmentXform extends BaseXform { } } add(node.attributes.horizontal, 'horizontal', node.attributes.horizontal); - add(node.attributes.vertical, 'vertical', node.attributes.vertical === 'center' ? 'middle' : node.attributes.vertical); + add( + node.attributes.vertical, + 'vertical', + node.attributes.vertical === 'center' ? 'middle' : node.attributes.vertical + ); add(node.attributes.wrapText, 'wrapText', !!node.attributes.wrapText); add(node.attributes.shrinkToFit, 'shrinkToFit', !!node.attributes.shrinkToFit); add(node.attributes.indent, 'indent', parseInt(node.attributes.indent, 10)); - add(node.attributes.textRotation, 'textRotation', textRotationXform.toModel(node.attributes.textRotation)); - add(node.attributes.readingOrder, 'readingOrder', node.attributes.readingOrder === '2' ? 'rtl' : 'ltr'); + add( + node.attributes.textRotation, + 'textRotation', + textRotationXform.toModel(node.attributes.textRotation) + ); + add( + node.attributes.readingOrder, + 'readingOrder', + node.attributes.readingOrder === '2' ? 'rtl' : 'ltr' + ); this.model = valid ? model : null; } diff --git a/lib/xlsx/xform/style/font-xform.js b/lib/xlsx/xform/style/font-xform.js index 0d71f47ff..56cf006c8 100644 --- a/lib/xlsx/xform/style/font-xform.js +++ b/lib/xlsx/xform/style/font-xform.js @@ -32,7 +32,10 @@ class FontXform extends BaseXform { strike: {prop: 'strike', xform: new BooleanXform({tag: 'strike', attr: 'val'})}, sz: {prop: 'size', xform: new IntegerXform({tag: 'sz', attr: 'val'})}, }; - this.map[this.options.fontNameTag] = {prop: 'name', xform: new StringXform({tag: this.options.fontNameTag, attr: 'val'})}; + this.map[this.options.fontNameTag] = { + prop: 'name', + xform: new StringXform({tag: this.options.fontNameTag, attr: 'val'}), + }; } get tag() { diff --git a/lib/xlsx/xform/style/styles-xform.js b/lib/xlsx/xform/style/styles-xform.js index 6380c12f7..e1071c424 100644 --- a/lib/xlsx/xform/style/styles-xform.js +++ b/lib/xlsx/xform/style/styles-xform.js @@ -24,11 +24,20 @@ class StylesXform extends BaseXform { this.map = { numFmts: new ListXform({tag: 'numFmts', count: true, childXform: new NumFmtXform()}), - fonts: new ListXform({tag: 'fonts', count: true, childXform: new FontXform(), $: {'x14ac:knownFonts': 1}}), + fonts: new ListXform({ + tag: 'fonts', + count: true, + childXform: new FontXform(), + $: {'x14ac:knownFonts': 1}, + }), fills: new ListXform({tag: 'fills', count: true, childXform: new FillXform()}), borders: new ListXform({tag: 'borders', count: true, childXform: new BorderXform()}), cellStyleXfs: new ListXform({tag: 'cellStyleXfs', count: true, childXform: new StyleXform()}), - cellXfs: new ListXform({tag: 'cellXfs', count: true, childXform: new StyleXform({xfId: true})}), + cellXfs: new ListXform({ + tag: 'cellXfs', + count: true, + childXform: new StyleXform({xfId: true}), + }), dxfs: new ListXform({tag: 'dxfs', always: true, count: true, childXform: new DxfXform()}), // for style manager @@ -126,7 +135,9 @@ class StylesXform extends BaseXform { }); xmlStream.closeNode(); - this.map.cellStyleXfs.render(xmlStream, [{numFmtId: 0, fontId: 0, fillId: 0, borderId: 0, xfId: 0}]); + this.map.cellStyleXfs.render(xmlStream, [ + {numFmtId: 0, fontId: 0, fillId: 0, borderId: 0, xfId: 0}, + ]); xmlStream.openNode('cellXfs', {count: model.styles.length}); model.styles.forEach(styleXml => { @@ -139,7 +150,9 @@ class StylesXform extends BaseXform { this.map.fonts.render(xmlStream, model.fonts); this.map.fills.render(xmlStream, model.fills); this.map.borders.render(xmlStream, model.borders); - this.map.cellStyleXfs.render(xmlStream, [{numFmtId: 0, fontId: 0, fillId: 0, borderId: 0, xfId: 0}]); + this.map.cellStyleXfs.render(xmlStream, [ + {numFmtId: 0, fontId: 0, fillId: 0, borderId: 0, xfId: 0}, + ]); this.map.cellXfs.render(xmlStream, model.styles); } @@ -300,7 +313,8 @@ class StylesXform extends BaseXform { // ------------------------------------------------------- // number format if (style.numFmtId) { - const numFmt = this.index.numFmt[style.numFmtId] || NumFmtXform.getDefaultFmtCode(style.numFmtId); + const numFmt = + this.index.numFmt[style.numFmtId] || NumFmtXform.getDefaultFmtCode(style.numFmtId); if (numFmt) { model.numFmt = numFmt; } @@ -419,20 +433,33 @@ StylesXform.STYLESHEET_ATTRIBUTES = { 'xmlns:x16r2': 'http://schemas.microsoft.com/office/spreadsheetml/2015/02/main', }; StylesXform.STATIC_XFORMS = { - cellStyles: new StaticXform({tag: 'cellStyles', $: {count: 1}, c: [{tag: 'cellStyle', $: {name: 'Normal', xfId: 0, builtinId: 0}}]}), + cellStyles: new StaticXform({ + tag: 'cellStyles', + $: {count: 1}, + c: [{tag: 'cellStyle', $: {name: 'Normal', xfId: 0, builtinId: 0}}], + }), dxfs: new StaticXform({tag: 'dxfs', $: {count: 0}}), - tableStyles: new StaticXform({tag: 'tableStyles', $: {count: 0, defaultTableStyle: 'TableStyleMedium2', defaultPivotStyle: 'PivotStyleLight16'}}), + tableStyles: new StaticXform({ + tag: 'tableStyles', + $: {count: 0, defaultTableStyle: 'TableStyleMedium2', defaultPivotStyle: 'PivotStyleLight16'}, + }), extLst: new StaticXform({ tag: 'extLst', c: [ { tag: 'ext', - $: {uri: '{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}', 'xmlns:x14': 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/main'}, + $: { + uri: '{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}', + 'xmlns:x14': 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/main', + }, c: [{tag: 'x14:slicerStyles', $: {defaultSlicerStyle: 'SlicerStyleLight1'}}], }, { tag: 'ext', - $: {uri: '{9260A510-F301-46a8-8635-F512D64BE5F5}', 'xmlns:x15': 'http://schemas.microsoft.com/office/spreadsheetml/2010/11/main'}, + $: { + uri: '{9260A510-F301-46a8-8635-F512D64BE5F5}', + 'xmlns:x15': 'http://schemas.microsoft.com/office/spreadsheetml/2010/11/main', + }, c: [{tag: 'x15:timelineStyles', $: {defaultTimelineStyle: 'TimeSlicerStyleLight1'}}], }, ], diff --git a/lib/xlsx/xlsx.js b/lib/xlsx/xlsx.js index c9c9d411d..5a81b4415 100644 --- a/lib/xlsx/xlsx.js +++ b/lib/xlsx/xlsx.js @@ -495,11 +495,19 @@ class XLSX { {Id: `rId${count++}`, Type: XLSX.RelType.Theme, Target: 'theme/theme1.xml'}, ]; if (model.sharedStrings.count) { - relationships.push({Id: `rId${count++}`, Type: XLSX.RelType.SharedStrings, Target: 'sharedStrings.xml'}); + relationships.push({ + Id: `rId${count++}`, + Type: XLSX.RelType.SharedStrings, + Target: 'sharedStrings.xml', + }); } model.worksheets.forEach(worksheet => { worksheet.rId = `rId${count++}`; - relationships.push({Id: worksheet.rId, Type: XLSX.RelType.Worksheet, Target: `worksheets/sheet${worksheet.id}.xml`}); + relationships.push({ + Id: worksheet.rId, + Type: XLSX.RelType.Worksheet, + Target: `worksheets/sheet${worksheet.id}.xml`, + }); }); const xform = new RelationshipsXform(); const xml = xform.toXml(relationships); @@ -572,7 +580,8 @@ class XLSX { model.created = model.created || new Date(); model.modified = model.modified || new Date(); - model.useSharedStrings = options.useSharedStrings !== undefined ? options.useSharedStrings : true; + model.useSharedStrings = + options.useSharedStrings !== undefined ? options.useSharedStrings : true; model.useStyles = options.useStyles !== undefined ? options.useStyles : true; // Manage the shared strings From 25babc7f29809d71e3ffc84dead45e065f483d0a Mon Sep 17 00:00:00 2001 From: Andreas Lubbe Date: Tue, 29 Sep 2020 08:48:52 +0200 Subject: [PATCH 4/4] Reset prettier's bracketSpacing to false --- .prettier | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.prettier b/.prettier index 808c4a5ee..470c46807 100644 --- a/.prettier +++ b/.prettier @@ -2,6 +2,6 @@ "bracketSpacing": false, "printWidth": 100, "trailingComma": "all", - "bracketSpacing": true, + "bracketSpacing": false, "arrowParens": "avoid" } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy