From 7c7b36d9c3630fd0a29e7c43a799a752ea914ba2 Mon Sep 17 00:00:00 2001 From: "Libor M." Date: Sun, 3 Nov 2024 15:18:13 +0100 Subject: [PATCH] fix formatting --- src/DocumentContext.js | 4 ++-- src/LayoutBuilder.js | 6 +++--- src/Renderer.js | 4 ++-- standard-fonts/Helvetica.js | 1 - tests/unit/DocMeasure.spec.js | 2 +- tests/unit/Printer.spec.js | 2 +- tests/unit/StyleContextStack.spec.js | 2 +- tests/unit/TableProcessor.spec.js | 18 +++++++++--------- tests/unit/columnCalculator.spec.js | 8 ++++---- 9 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/DocumentContext.js b/src/DocumentContext.js index bdcf7d78b..11b414372 100644 --- a/src/DocumentContext.js +++ b/src/DocumentContext.js @@ -26,7 +26,7 @@ class DocumentContext extends EventEmitter { availableHeight: this.availableHeight, availableWidth: this.availableWidth, page: this.page, - bottomByPage: bottomByPage ? bottomByPage : {}, + bottomByPage: bottomByPage ? bottomByPage : {}, bottomMost: { x: this.x, y: this.y, @@ -43,7 +43,7 @@ class DocumentContext extends EventEmitter { } } - updateBottomByPage () { + updateBottomByPage() { const lastSnapshot = this.snapshots[this.snapshots.length - 1]; const lastPage = this.page; let previousBottom = -Number.MIN_VALUE; diff --git a/src/LayoutBuilder.js b/src/LayoutBuilder.js index f56d3fac6..37dc80247 100644 --- a/src/LayoutBuilder.js +++ b/src/LayoutBuilder.js @@ -624,12 +624,12 @@ class LayoutBuilder { * @property {number} target.prevY - Updated to the maximum `prevY` value between `break1` and `break2`. * @property {number} target.y - Updated to the minimum `y` value between `break1` and `break2`. */ - _resolveBreakY (break1, break2, target) { + _resolveBreakY(break1, break2, target) { target.prevY = Math.max(break1.prevY, break2.prevY); target.y = Math.min(break1.y, break2.y); }; - _storePageBreakData (data, startsRowSpan, pageBreaks, tableNode) { + _storePageBreakData(data, startsRowSpan, pageBreaks, tableNode) { if (!startsRowSpan) { let pageDesc = this._getPageBreak(pageBreaks, data.prevPage); let pageDescBySpan = this._getPageBreakListBySpan(tableNode, data.prevPage, data.rowIndex); @@ -830,7 +830,7 @@ class LayoutBuilder { } return { - pageBreaksBySpan : pageBreaksByRowSpan, + pageBreaksBySpan: pageBreaksByRowSpan, pageBreaks: pageBreaks, positions: positions }; diff --git a/src/Renderer.js b/src/Renderer.js index 0663a1239..9c1f323c7 100644 --- a/src/Renderer.js +++ b/src/Renderer.js @@ -56,7 +56,7 @@ class Renderer { let renderedItems = 0; for (let i = 0; i < pages.length; i++) { - this.pdfDocument.addPage({size: [pages[i].pageSize.width, pages[i].pageSize.height]}); + this.pdfDocument.addPage({ size: [pages[i].pageSize.width, pages[i].pageSize.height] }); let page = pages[i]; for (let ii = 0, il = page.items.length; ii < il; ii++) { @@ -349,7 +349,7 @@ class Renderer { this.pdfDocument.link(svg.x, svg.y, svg._width, svg._height, svg.link); } if (svg.linkToPage) { - this.pdfDocument.ref({Type: 'Action', S: 'GoTo', D: [svg.linkToPage, 0, 0]}).end(); + this.pdfDocument.ref({ Type: 'Action', S: 'GoTo', D: [svg.linkToPage, 0, 0] }).end(); this.pdfDocument.annotate(svg.x, svg.y, svg._width, svg._height, { Subtype: 'Link', Dest: [svg.linkToPage - 1, 'XYZ', null, null, null] }); } if (svg.linkToDestination) { diff --git a/standard-fonts/Helvetica.js b/standard-fonts/Helvetica.js index 57de33f6e..5234d5114 100644 --- a/standard-fonts/Helvetica.js +++ b/standard-fonts/Helvetica.js @@ -6,4 +6,3 @@ module.exports = { bolditalics: 'Helvetica-BoldOblique' } }; - diff --git a/tests/unit/DocMeasure.spec.js b/tests/unit/DocMeasure.spec.js index b22d12bb7..a632e8cfa 100644 --- a/tests/unit/DocMeasure.spec.js +++ b/tests/unit/DocMeasure.spec.js @@ -181,7 +181,7 @@ describe('DocMeasure', function () { }); it('should not increase listMarker when list item is a nested list', function () { - var node = { ol: ['parent item 1', { ol: ['nested item 1', 'nested item 2']}, 'parent item 2'] }; + var node = { ol: ['parent item 1', { ol: ['nested item 1', 'nested item 2'] }, 'parent item 2'] }; docPreprocessor.preprocessList(node); var result = docMeasure.measureOrderedList(node); diff --git a/tests/unit/Printer.spec.js b/tests/unit/Printer.spec.js index b7ceb03c0..cad7daecc 100644 --- a/tests/unit/Printer.spec.js +++ b/tests/unit/Printer.spec.js @@ -99,7 +99,7 @@ describe('Printer', function () { }); - it('should not switch width and height for pdfkit if page orientation changes from landscape to landscape',async function () { + it('should not switch width and height for pdfkit if page orientation changes from landscape to landscape', async function () { printer = new Printer(fontDescriptors); var docDefinition = { pageOrientation: 'portrait', diff --git a/tests/unit/StyleContextStack.spec.js b/tests/unit/StyleContextStack.spec.js index 9e4ec3ef4..ce60b1567 100644 --- a/tests/unit/StyleContextStack.spec.js +++ b/tests/unit/StyleContextStack.spec.js @@ -134,7 +134,7 @@ describe('StyleContextStack', function () { it('should not push any style if no style nor style-property is defined', function () { assert.equal(fullStack.autopush({ anotherProperty: 'test' }), 1); assert.equal(fullStack.styleOverrides.length, 1); - styleProperties.forEach(function(key) { + styleProperties.forEach(function (key) { assert.equal(fullStack.styleOverrides[0][key], undefined); }); }); diff --git a/tests/unit/TableProcessor.spec.js b/tests/unit/TableProcessor.spec.js index 1ba1fce9c..75afaca6f 100644 --- a/tests/unit/TableProcessor.spec.js +++ b/tests/unit/TableProcessor.spec.js @@ -241,7 +241,7 @@ describe('TableProcessor', function () { inputTable.table.keepWithHeaderRows = 2; var tableProcessor = new TableProcessor(inputTable); - tableProcessor.drawHorizontalLine = function() { }; + tableProcessor.drawHorizontalLine = function () { }; tableProcessor.beginTable(fakeWriter); assert.equal(tableProcessor.headerRows, 0); assert.equal(tableProcessor.rowsWithoutPageBreak, 0); @@ -252,7 +252,7 @@ describe('TableProcessor', function () { inputTable.table.keepWithHeaderRows = 2; var tableProcessor = new TableProcessor(inputTable); - tableProcessor.drawHorizontalLine = function() { }; + tableProcessor.drawHorizontalLine = function () { }; tableProcessor.beginTable(fakeWriter); assert.equal(tableProcessor.headerRows, 0); assert.equal(tableProcessor.rowsWithoutPageBreak, 0); @@ -264,7 +264,7 @@ describe('TableProcessor', function () { inputTable.table.keepWithHeaderRows = 2; var tableProcessor = new TableProcessor(inputTable); - tableProcessor.drawHorizontalLine = function() { }; + tableProcessor.drawHorizontalLine = function () { }; tableProcessor.beginTable(fakeWriter); assert.equal(tableProcessor.headerRows, 0); assert.equal(tableProcessor.rowsWithoutPageBreak, 0); @@ -275,7 +275,7 @@ describe('TableProcessor', function () { inputTable.table.keepWithHeaderRows = 2; var tableProcessor = new TableProcessor(inputTable); - tableProcessor.drawHorizontalLine = function() { }; + tableProcessor.drawHorizontalLine = function () { }; tableProcessor.beginTable(fakeWriter); assert.equal(tableProcessor.headerRows, 0); assert.equal(tableProcessor.rowsWithoutPageBreak, 0); @@ -286,7 +286,7 @@ describe('TableProcessor', function () { inputTable.table.keepWithHeaderRows = 1.5; var tableProcessor = new TableProcessor(inputTable); - tableProcessor.drawHorizontalLine = function() { }; + tableProcessor.drawHorizontalLine = function () { }; tableProcessor.beginTable(fakeWriter); assert.equal(tableProcessor.headerRows, 1); assert.equal(tableProcessor.rowsWithoutPageBreak, 1); @@ -297,7 +297,7 @@ describe('TableProcessor', function () { inputTable.table.keepWithHeaderRows = '1.5'; var tableProcessor = new TableProcessor(inputTable); - tableProcessor.drawHorizontalLine = function() { }; + tableProcessor.drawHorizontalLine = function () { }; tableProcessor.beginTable(fakeWriter); assert.equal(tableProcessor.headerRows, 2); assert.equal(tableProcessor.rowsWithoutPageBreak, 2); @@ -308,7 +308,7 @@ describe('TableProcessor', function () { inputTable.table.keepWithHeaderRows = 2; var tableProcessor = new TableProcessor(inputTable); - tableProcessor.drawHorizontalLine = function() { }; + tableProcessor.drawHorizontalLine = function () { }; tableProcessor.beginTable(fakeWriter); assert.equal(tableProcessor.rowsWithoutPageBreak, 3); assert.equal(tableProcessor.headerRows, 1); @@ -319,7 +319,7 @@ describe('TableProcessor', function () { inputTable.table.keepWithHeaderRows = 0; var tableProcessor = new TableProcessor(inputTable); - tableProcessor.drawHorizontalLine = function() { }; + tableProcessor.drawHorizontalLine = function () { }; tableProcessor.beginTable(fakeWriter); assert.equal(tableProcessor.rowsWithoutPageBreak, 1); assert.equal(tableProcessor.headerRows, 1); @@ -330,7 +330,7 @@ describe('TableProcessor', function () { inputTable.table.keepWithHeaderRows = 0; var tableProcessor = new TableProcessor(inputTable); - tableProcessor.drawHorizontalLine = function() { }; + tableProcessor.drawHorizontalLine = function () { }; assert.throws(() => tableProcessor.beginTable(fakeWriter), /Too few rows in the table/); }); }); diff --git a/tests/unit/columnCalculator.spec.js b/tests/unit/columnCalculator.spec.js index 120dda9c2..f3059b967 100644 --- a/tests/unit/columnCalculator.spec.js +++ b/tests/unit/columnCalculator.spec.js @@ -151,8 +151,8 @@ describe('ColumnCalculator', function () { ]; const tableNode = { table: { - widths: ['50%', '25%', '25%'], - body: [['50%', '25%', '25%']] + widths: ['50%', '25%', '25%'], + body: [['50%', '25%', '25%']] }, _layout: { vLineWidth: function (i) { @@ -169,10 +169,10 @@ describe('ColumnCalculator', function () { return 4; } }, - paddingLeft: function(i) { + paddingLeft: function (i) { return i === 0 ? 5 : 3; }, - paddingRight: function() { + paddingRight: function () { return 7; } }