Skip to content

Commit d0e57f0

Browse files
authored
Merge pull request #1477 from alubbe/linter
Run linter with prettier 2
2 parents 25a21f0 + 25babc7 commit d0e57f0

File tree

103 files changed

+1074
-629
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+1074
-629
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
"node": true
1414
},
1515
"rules": {
16+
"arrow-parens": ["error", "as-needed"],
1617
"class-methods-use-this": ["off"],
1718
"comma-dangle": ["error", {"arrays": "always-multiline", "objects": "always-multiline", "imports": "always-multiline", "exports": "always-multiline", "functions": "never"}],
1819
"default-case": ["off"],
1920
"func-names": ["off", "never"],
2021
"global-require": ["off"],
21-
"max-len": ["error", {"code": 160, "ignoreComments": true, "ignoreStrings": true}],
22+
"max-len": ["error", {"code": 100, "ignoreComments": true, "ignoreStrings": true}],
2223
"no-console": ["error", { "allow": ["warn"] }],
2324
"no-continue": ["off"],
2425
"no-mixed-operators": ["error", {"allowSamePrecedence": true}],

.prettier

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"bracketSpacing": false,
3-
"printWidth": 160,
3+
"printWidth": 100,
44
"trailingComma": "all",
5-
"bracketSpacing": false
5+
"bracketSpacing": false,
6+
"arrowParens": "avoid"
67
}

benchmark.js

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ const runs = 3;
88
await runProfiling('huge xlsx file streams', () => {
99
return new Promise((resolve, reject) => {
1010
// Data taken from http://eforexcel.com/wp/downloads-18-sample-csv-files-data-sets-for-testing-sales/
11-
const workbookReader = new ExcelJS.stream.xlsx.WorkbookReader('./spec/integration/data/huge.xlsx');
11+
const workbookReader = new ExcelJS.stream.xlsx.WorkbookReader(
12+
'./spec/integration/data/huge.xlsx'
13+
);
1214
workbookReader.read();
1315

1416
let worksheetCount = 0;
@@ -32,7 +34,9 @@ const runs = 3;
3234

3335
await runProfiling('huge xlsx file async iteration', async () => {
3436
// Data taken from http://eforexcel.com/wp/downloads-18-sample-csv-files-data-sets-for-testing-sales/
35-
const workbookReader = new ExcelJS.stream.xlsx.WorkbookReader('spec/integration/data/huge.xlsx');
37+
const workbookReader = new ExcelJS.stream.xlsx.WorkbookReader(
38+
'spec/integration/data/huge.xlsx'
39+
);
3640
let worksheetCount = 0;
3741
let rowCount = 0;
3842
for await (const worksheetReader of workbookReader) {
@@ -55,13 +59,21 @@ const runs = 3;
5559
async function runProfiling(name, run) {
5660
console.log('');
5761
console.log('####################################################');
58-
console.log(`WARMUP: Current memory usage: ${currentMemoryUsage({runGarbageCollector: true})} MB`);
62+
console.log(
63+
`WARMUP: Current memory usage: ${currentMemoryUsage({runGarbageCollector: true})} MB`
64+
);
5965
console.log(`WARMUP: ${name} profiling started`);
6066
const warmupStartTime = Date.now();
6167
await run();
6268
console.log(`WARMUP: ${name} profiling finished in ${Date.now() - warmupStartTime}ms`);
63-
console.log(`WARMUP: Current memory usage (before GC): ${currentMemoryUsage({runGarbageCollector: false})} MB`);
64-
console.log(`WARMUP: Current memory usage (after GC): ${currentMemoryUsage({runGarbageCollector: true})} MB`);
69+
console.log(
70+
`WARMUP: Current memory usage (before GC): ${currentMemoryUsage({
71+
runGarbageCollector: false,
72+
})} MB`
73+
);
74+
console.log(
75+
`WARMUP: Current memory usage (after GC): ${currentMemoryUsage({runGarbageCollector: true})} MB`
76+
);
6577

6678
for (let i = 1; i <= runs; i += 1) {
6779
console.log('');
@@ -70,8 +82,16 @@ async function runProfiling(name, run) {
7082
const startTime = Date.now();
7183
await run(); // eslint-disable-line no-await-in-loop
7284
console.log(`RUN ${i}: ${name} profiling finished in ${Date.now() - startTime}ms`);
73-
console.log(`RUN ${i}: Current memory usage (before GC): ${currentMemoryUsage({runGarbageCollector: false})} MB`);
74-
console.log(`RUN ${i}: Current memory usage (after GC): ${currentMemoryUsage({runGarbageCollector: true})} MB`);
85+
console.log(
86+
`RUN ${i}: Current memory usage (before GC): ${currentMemoryUsage({
87+
runGarbageCollector: false,
88+
})} MB`
89+
);
90+
console.log(
91+
`RUN ${i}: Current memory usage (after GC): ${currentMemoryUsage({
92+
runGarbageCollector: true,
93+
})} MB`
94+
);
7595
}
7696
}
7797

excel.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
*/
66

77
if (parseInt(process.versions.node.split('.')[0], 10) < 10) {
8-
throw new Error('For node versions older than 10, please use the ES5 Import: https://github.com/exceljs/exceljs#es5-imports');
8+
throw new Error(
9+
'For node versions older than 10, please use the ES5 Import: https://github.com/exceljs/exceljs#es5-imports'
10+
);
911
}
1012

1113
module.exports = require('./lib/exceljs.nodejs.js');

lib/csv/csv.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ const fs = require('fs');
22
const fastCsv = require('fast-csv');
33
const customParseFormat = require('dayjs/plugin/customParseFormat');
44
const utc = require('dayjs/plugin/utc');
5-
const dayjs = require('dayjs')
6-
.extend(customParseFormat)
7-
.extend(utc);
5+
const dayjs = require('dayjs').extend(customParseFormat).extend(utc);
86
const StreamBuf = require('../utils/stream-buf');
97

108
const {
@@ -48,7 +46,12 @@ class CSV {
4846
return new Promise((resolve, reject) => {
4947
const worksheet = this.workbook.addWorksheet(options.sheetName);
5048

51-
const dateFormats = options.dateFormats || ['YYYY-MM-DD[T]HH:mm:ssZ', 'YYYY-MM-DD[T]HH:mm:ss', 'MM-DD-YYYY', 'YYYY-MM-DD'];
49+
const dateFormats = options.dateFormats || [
50+
'YYYY-MM-DD[T]HH:mm:ssZ',
51+
'YYYY-MM-DD[T]HH:mm:ss',
52+
'MM-DD-YYYY',
53+
'YYYY-MM-DD',
54+
];
5255
const map =
5356
options.map ||
5457
function(datum) {
@@ -132,7 +135,9 @@ class CSV {
132135
}
133136
if (value instanceof Date) {
134137
if (dateFormat) {
135-
return dateUTC ? dayjs.utc(value).format(dateFormat) : dayjs(value).format(dateFormat);
138+
return dateUTC
139+
? dayjs.utc(value).format(dateFormat)
140+
: dayjs(value).format(dateFormat);
136141
}
137142
return dateUTC ? dayjs.utc(value).format() : dayjs(value).format();
138143
}

lib/csv/stream-converter.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ class StreamConverter {
8080
this.writeStarted = true;
8181
}
8282

83-
this.inner.write(this.convertInwards(data), encoding ? this.innerEncoding : undefined, callback);
83+
this.inner.write(
84+
this.convertInwards(data),
85+
encoding ? this.innerEncoding : undefined,
86+
callback
87+
);
8488
}
8589

8690
read() {

lib/doc/anchor.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,17 @@ class Anchor {
5656
}
5757

5858
get colWidth() {
59-
return this.worksheet && this.worksheet.getColumn(this.nativeCol + 1) && this.worksheet.getColumn(this.nativeCol + 1).isCustomWidth
59+
return this.worksheet &&
60+
this.worksheet.getColumn(this.nativeCol + 1) &&
61+
this.worksheet.getColumn(this.nativeCol + 1).isCustomWidth
6062
? Math.floor(this.worksheet.getColumn(this.nativeCol + 1).width * 10000)
6163
: 640000;
6264
}
6365

6466
get rowHeight() {
65-
return this.worksheet && this.worksheet.getRow(this.nativeRow + 1) && this.worksheet.getRow(this.nativeRow + 1).height
67+
return this.worksheet &&
68+
this.worksheet.getRow(this.nativeRow + 1) &&
69+
this.worksheet.getRow(this.nativeRow + 1).height
6670
? Math.floor(this.worksheet.getRow(this.nativeRow + 1).height * 10000)
6771
: 180000;
6872
}

lib/doc/cell.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,9 @@ class FormulaValue {
787787
get dependencies() {
788788
// find all the ranges and cells mentioned in the formula
789789
const ranges = this.formula.match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g);
790-
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);
790+
const cells = this.formula
791+
.replace(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g, '')
792+
.match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}/g);
791793
return {
792794
ranges,
793795
cells,
@@ -860,7 +862,8 @@ class FormulaValue {
860862
if (!this._translatedFormula && this.model.sharedFormula) {
861863
const {worksheet} = this.cell;
862864
const master = worksheet.findCell(this.model.sharedFormula);
863-
this._translatedFormula = master && slideFormula(master.formula, master.address, this.model.address);
865+
this._translatedFormula =
866+
master && slideFormula(master.formula, master.address, this.model.address);
864867
}
865868
return this._translatedFormula;
866869
}

lib/doc/column.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ class Column {
122122
}
123123

124124
get collapsed() {
125-
return !!(this._outlineLevel && this._outlineLevel >= this._worksheet.properties.outlineLevelCol);
125+
return !!(
126+
this._outlineLevel && this._outlineLevel >= this._worksheet.properties.outlineLevelCol
127+
);
126128
}
127129

128130
toString() {
@@ -134,7 +136,12 @@ class Column {
134136
}
135137

136138
equivalentTo(other) {
137-
return this.width === other.width && this.hidden === other.hidden && this.outlineLevel === other.outlineLevel && _.isEqual(this.style, other.style);
139+
return (
140+
this.width === other.width &&
141+
this.hidden === other.hidden &&
142+
this.outlineLevel === other.outlineLevel &&
143+
_.isEqual(this.style, other.style)
144+
);
138145
}
139146

140147
get isDefault() {

lib/doc/defined-names.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ class DefinedNames {
7373
}
7474

7575
getNamesEx(address) {
76-
return _.map(this.matrixMap, (matrix, name) => matrix.findCellEx(address) && name).filter(Boolean);
76+
return _.map(this.matrixMap, (matrix, name) => matrix.findCellEx(address) && name).filter(
77+
Boolean
78+
);
7779
}
7880

7981
_explore(matrix, cell) {
@@ -172,7 +174,9 @@ class DefinedNames {
172174

173175
get model() {
174176
// To get names per cell - just iterate over all names finding cells if they exist
175-
return _.map(this.matrixMap, (matrix, name) => this.getRanges(name, matrix)).filter(definedName => definedName.ranges.length);
177+
return _.map(this.matrixMap, (matrix, name) => this.getRanges(name, matrix)).filter(
178+
definedName => definedName.ranges.length
179+
);
176180
}
177181

178182
set model(value) {

0 commit comments

Comments
 (0)