Skip to content
This repository was archived by the owner on Oct 17, 2024. It is now read-only.

Commit 8ec8baa

Browse files
committed
change max-len value, lint:fix
1 parent 51cfe07 commit 8ec8baa

Some content is hidden

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

46 files changed

+585
-149
lines changed

.eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"default-case": ["off"],
2020
"func-names": ["off", "never"],
2121
"global-require": ["off"],
22-
"max-len": ["error", {"code": 160, "ignoreComments": true, "ignoreStrings": true}],
22+
"max-len": ["error", {"code": 100, "ignoreComments": true, "ignoreStrings": true}],
2323
"no-console": ["error", { "allow": ["warn"] }],
2424
"no-continue": ["off"],
2525
"no-mixed-operators": ["error", {"allowSamePrecedence": true}],

.prettier

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"bracketSpacing": false,
3-
"printWidth": 160,
3+
"printWidth": 100,
44
"trailingComma": "all",
55
"bracketSpacing": true,
66
"arrowParens": "avoid"

benchmark.js

+27-7
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

+3-1
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

+9-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ class CSV {
4646
return new Promise((resolve, reject) => {
4747
const worksheet = this.workbook.addWorksheet(options.sheetName);
4848

49-
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+
];
5055
const map =
5156
options.map ||
5257
function(datum) {
@@ -130,7 +135,9 @@ class CSV {
130135
}
131136
if (value instanceof Date) {
132137
if (dateFormat) {
133-
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);
134141
}
135142
return dateUTC ? dayjs.utc(value).format() : dayjs(value).format();
136143
}

lib/csv/stream-converter.js

+5-1
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

+6-2
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

+5-2
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

+9-2
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

+6-2
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) {

lib/doc/range.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,12 @@ class Range {
237237

238238
containsEx(address) {
239239
if (address.sheetName && this.sheetName && address.sheetName !== this.sheetName) return false;
240-
return address.row >= this.top && address.row <= this.bottom && address.col >= this.left && address.col <= this.right;
240+
return (
241+
address.row >= this.top &&
242+
address.row <= this.bottom &&
243+
address.col >= this.left &&
244+
address.col <= this.right
245+
);
241246
}
242247

243248
forEachAddress(cb) {

lib/doc/row.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,9 @@ class Row {
324324
}
325325

326326
get collapsed() {
327-
return !!(this._outlineLevel && this._outlineLevel >= this._worksheet.properties.outlineLevelRow);
327+
return !!(
328+
this._outlineLevel && this._outlineLevel >= this._worksheet.properties.outlineLevelRow
329+
);
328330
}
329331

330332
// =========================================================================

lib/doc/workbook.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,19 @@ class Workbook {
5959
if (options) {
6060
if (typeof options === 'string') {
6161
// eslint-disable-next-line no-console
62-
console.trace('tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { argb: "rbg value" } }');
62+
console.trace(
63+
'tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { argb: "rbg value" } }'
64+
);
6365
options = {
6466
properties: {
6567
tabColor: {argb: options},
6668
},
6769
};
6870
} else if (options.argb || options.theme || options.indexed) {
6971
// eslint-disable-next-line no-console
70-
console.trace('tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { ... } }');
72+
console.trace(
73+
'tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { ... } }'
74+
);
7175
options = {
7276
properties: {
7377
tabColor: options,
@@ -76,7 +80,10 @@ class Workbook {
7680
}
7781
}
7882

79-
const lastOrderNo = this._worksheets.reduce((acc, ws) => ((ws && ws.orderNo) > acc ? ws.orderNo : acc), 0);
83+
const lastOrderNo = this._worksheets.reduce(
84+
(acc, ws) => ((ws && ws.orderNo) > acc ? ws.orderNo : acc),
85+
0
86+
);
8087
const worksheetOptions = Object.assign({}, options, {
8188
id,
8289
name,

lib/doc/worksheet.js

+22-6
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ class Worksheet {
6868
orientation: 'portrait',
6969
horizontalDpi: 4294967295,
7070
verticalDpi: 4294967295,
71-
fitToPage: !!(options.pageSetup && (options.pageSetup.fitToWidth || options.pageSetup.fitToHeight) && !options.pageSetup.scale),
71+
fitToPage: !!(
72+
options.pageSetup &&
73+
(options.pageSetup.fitToWidth || options.pageSetup.fitToHeight) &&
74+
!options.pageSetup.scale
75+
),
7276
pageOrder: 'downThenOver',
7377
blackAndWhite: false,
7478
draft: false,
@@ -693,13 +697,21 @@ class Worksheet {
693697
};
694698
if (options && 'spinCount' in options) {
695699
// force spinCount to be integer >= 0
696-
options.spinCount = Number.isFinite(options.spinCount) ? Math.round(Math.max(0, options.spinCount)) : 100000;
700+
options.spinCount = Number.isFinite(options.spinCount)
701+
? Math.round(Math.max(0, options.spinCount))
702+
: 100000;
697703
}
698704
if (password) {
699705
this.sheetProtection.algorithmName = 'SHA-512';
700706
this.sheetProtection.saltValue = Encryptor.randomBytes(16).toString('base64');
701-
this.sheetProtection.spinCount = options && 'spinCount' in options ? options.spinCount : 100000; // allow user specified spinCount
702-
this.sheetProtection.hashValue = Encryptor.convertPasswordToHash(password, 'SHA512', this.sheetProtection.saltValue, this.sheetProtection.spinCount);
707+
this.sheetProtection.spinCount =
708+
options && 'spinCount' in options ? options.spinCount : 100000; // allow user specified spinCount
709+
this.sheetProtection.hashValue = Encryptor.convertPasswordToHash(
710+
password,
711+
'SHA512',
712+
this.sheetProtection.saltValue,
713+
this.sheetProtection.spinCount
714+
);
703715
}
704716
if (options) {
705717
this.sheetProtection = Object.assign(this.sheetProtection, options);
@@ -755,13 +767,17 @@ class Worksheet {
755767
// Deprecated
756768
get tabColor() {
757769
// eslint-disable-next-line no-console
758-
console.trace('worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor');
770+
console.trace(
771+
'worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor'
772+
);
759773
return this.properties.tabColor;
760774
}
761775

762776
set tabColor(value) {
763777
// eslint-disable-next-line no-console
764-
console.trace('worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor');
778+
console.trace(
779+
'worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor'
780+
);
765781
this.properties.tabColor = value;
766782
}
767783

lib/stream/xlsx/sheet-rels-writer.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ class SheetRelsWriter {
103103
'/>'
104104
);
105105
} else {
106-
this.stream.write(`<Relationship Id="${rId}" Type="${relationship.Type}" Target="${relationship.Target}"/>`);
106+
this.stream.write(
107+
`<Relationship Id="${rId}" Type="${relationship.Type}" Target="${relationship.Target}"/>`
108+
);
107109
}
108110

109111
return rId;

lib/stream/xlsx/workbook-reader.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -280,15 +280,25 @@ class WorkbookReader extends EventEmitter {
280280

281281
*_parseWorksheet(iterator, sheetNo) {
282282
this._emitEntry({type: 'worksheet', id: sheetNo});
283-
const worksheetReader = new WorksheetReader({workbook: this, id: sheetNo, iterator, options: this.options});
283+
const worksheetReader = new WorksheetReader({
284+
workbook: this,
285+
id: sheetNo,
286+
iterator,
287+
options: this.options,
288+
});
284289
if (this.options.worksheets === 'emit') {
285290
yield {eventType: 'worksheet', value: worksheetReader};
286291
}
287292
}
288293

289294
*_parseHyperlinks(iterator, sheetNo) {
290295
this._emitEntry({type: 'hyperlinks', id: sheetNo});
291-
const hyperlinksReader = new HyperlinkReader({workbook: this, id: sheetNo, iterator, options: this.options});
296+
const hyperlinksReader = new HyperlinkReader({
297+
workbook: this,
298+
id: sheetNo,
299+
iterator,
300+
options: this.options,
301+
});
292302
if (this.options.hyperlinks === 'emit') {
293303
yield {eventType: 'hyperlinks', value: hyperlinksReader};
294304
}

0 commit comments

Comments
 (0)