Skip to content

Commit

Permalink
fixing lints
Browse files Browse the repository at this point in the history
  • Loading branch information
guyonroche committed Oct 30, 2019
1 parent e93d162 commit 80eaedb
Show file tree
Hide file tree
Showing 71 changed files with 460 additions and 766 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"no-continue": ["off"],
"default-case": ["off"],
"object-curly-spacing": ["error", "never"],
"node/process-exit-as-throw": ["off"]
"node/process-exit-as-throw": ["off"],
"prefer-object-spread": ["off"]
}
}
43 changes: 18 additions & 25 deletions lib/doc/cell.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';

/* eslint-disable max-classes-per-file */
const colCache = require('../utils/col-cache');
const _ = require('../utils/under-dash');
const Enums = require('./enums');
Expand Down Expand Up @@ -580,35 +579,29 @@ class DateValue {

class HyperlinkValue {
constructor(cell, value) {
this.model = Object.assign(
{
address: cell.address,
type: Cell.Types.Hyperlink,
text: value ? value.text : undefined,
hyperlink: value ? value.hyperlink : undefined,
},
value && value.tooltip ? {tooltip: value.tooltip} : {}
);
this.model = {
address: cell.address,
type: Cell.Types.Hyperlink,
text: value ? value.text : undefined,
hyperlink: value ? value.hyperlink : undefined,
tooltip: value.tooltip,
};
}

get value() {
return Object.assign(
{
text: this.model.text,
hyperlink: this.model.hyperlink,
},
this.model.tooltip ? {tooltip: this.model.tooltip} : {}
);
return {
text: this.model.text,
hyperlink: this.model.hyperlink,
tooltip: this.model.tooltip,
};
}

set value(value) {
this.model = Object.assign(
{
text: value.text,
hyperlink: value.hyperlink,
},
value && value.tooltip ? {tooltip: value.tooltip} : {}
);
this.model = {
text: value.text,
hyperlink: value.hyperlink,
tooltip: value.tooltip,
};
}

get text() {
Expand Down
1 change: 1 addition & 0 deletions lib/doc/table.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable max-classes-per-file */
const colCache = require('./../utils/col-cache');

class Column {
Expand Down
1 change: 1 addition & 0 deletions lib/doc/workbook.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Workbook {
const id = this.nextId;

if (name && (name.length > 31)) {
// eslint-disable-next-line no-console
console.warn(`Worksheet name ${name} exceeds 31 chars. This will be truncated`);
}
name = (name || `sheet${id}`).substring(0, 31);
Expand Down
1 change: 1 addition & 0 deletions lib/exceljs.browser.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies,node/no-unpublished-require */
require('core-js/modules/es.promise');
require('core-js/modules/es.object.assign');
require('core-js/modules/es.object.keys');
Expand Down
1 change: 1 addition & 0 deletions lib/stream/xlsx/sheet-rels-writer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable max-classes-per-file */
const utils = require('../../utils/utils');
const RelType = require('../../xlsx/rel-type');

Expand Down
2 changes: 1 addition & 1 deletion lib/utils/col-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ const colCache = {
}

const address = this.decodeAddress(reference);
return sheetName ? Object.assign({sheetName}, address) : address;
return sheetName ? {sheetName, ...address} : address;
},

// convert row,col into address string
Expand Down
5 changes: 4 additions & 1 deletion lib/utils/flow-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ class FlowControl extends EventEmitter {

createChild() {
// Create a down-stream flow-control
const options = Object.assign({parent: this}, this.options);
const options = {
parent: this,
...this.options,
};
const child = new FlowControl(options);
this.children.push(child);

Expand Down
3 changes: 1 addition & 2 deletions lib/utils/stream-buf.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';

/* eslint-disable max-classes-per-file */
const Stream = require('stream');

const utils = require('./utils');
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ const utils = {
fs: {
exists(path) {
return new Promise(resolve => {
fs.exists(path, exists => {
resolve(exists);
fs.access(path, fs.constants.F_OK, err => {
resolve(!err);
});
});
},
Expand Down
1 change: 1 addition & 0 deletions lib/utils/zip-stream.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable max-classes-per-file */
const events = require('events');
const JSZip = require('jszip');

Expand Down
14 changes: 5 additions & 9 deletions lib/xlsx/xform/sheet/cell-xform.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,11 @@ class CellXform extends BaseXform {
if (options.sharedStrings && model.text !== undefined && model.text !== null) {
model.ssId = options.sharedStrings.add(model.text);
}
options.hyperlinks.push(
Object.assign(
{
address: model.address,
target: model.hyperlink,
},
model.tooltip ? {tooltip: model.tooltip} : {}
)
);
options.hyperlinks.push({
address: model.address,
target: model.hyperlink,
tooltip: model.tooltip,
});
break;

case Enums.ValueType.Merge:
Expand Down
27 changes: 10 additions & 17 deletions lib/xlsx/xform/sheet/hyperlink-xform.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,20 @@ class HyperlinkXform extends BaseXform {
}

render(xmlStream, model) {
xmlStream.leafNode(
'hyperlink',
Object.assign(
{
ref: model.address,
'r:id': model.rId,
},
model.tooltip ? {tooltip: model.tooltip} : {}
)
);
xmlStream.leafNode('hyperlink', {
ref: model.address,
'r:id': model.rId,
tooltip: model.tooltip,
});
}

parseOpen(node) {
if (node.name === 'hyperlink') {
this.model = Object.assign(
{
address: node.attributes.ref,
rId: node.attributes['r:id'],
},
node.attributes.tooltip ? {tooltip: node.attributes.tooltip} : {}
);
this.model = {
address: node.attributes.ref,
rId: node.attributes['r:id'],
tooltip: node.attributes.tooltip,
};
return true;
}
return false;
Expand Down
6 changes: 5 additions & 1 deletion lib/xlsx/xform/style/border-xform.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable max-classes-per-file */
const BaseXform = require('../base-xform');

const ColorXform = require('./color-xform');
Expand Down Expand Up @@ -133,7 +134,10 @@ class BorderXform extends BaseXform {
function add(edgeModel, edgeXform) {
if (edgeModel && !edgeModel.color && model.color) {
// don't mess with incoming models
edgeModel = Object.assign({}, edgeModel, {color: model.color});
edgeModel = {
...edgeModel,
color: model.color,
};
}
edgeXform.render(xmlStream, edgeModel, color);
}
Expand Down
1 change: 1 addition & 0 deletions lib/xlsx/xform/style/fill-xform.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable max-classes-per-file */
const BaseXform = require('../base-xform');

const ColorXform = require('./color-xform');
Expand Down
1 change: 1 addition & 0 deletions lib/xlsx/xform/style/styles-xform.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable max-classes-per-file */
const Enums = require('../../../doc/enums');
const XmlStream = require('../../../utils/xml-stream');

Expand Down
8 changes: 5 additions & 3 deletions lib/xlsx/xlsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,16 +634,18 @@ class XLSX {
writeFile(filename, options) {
const stream = fs.createWriteStream(filename);

return new Promise(async (resolve, reject) => {
return new Promise((resolve, reject) => {
stream.on('finish', () => {
resolve();
});
stream.on('error', error => {
reject(error);
});

await this.write(stream, options);
stream.end();
this.write(stream, options)
.then(() => {
stream.end();
});
});
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"url": "https://github.com/exceljs/exceljs.git"
},
"engines": {
"node": ">=8.0.0"
"node": ">=8.3.0"
},
"main": "./lib/exceljs.nodejs.js",
"browser": "./dist/exceljs.min.js",
Expand Down
1 change: 1 addition & 0 deletions spec/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"array-bracket-spacing": ["off"],
"no-sparse-arrays": ["off"],
"object-property-newline": ["off"],
"prefer-object-spread": ["off"],
"no-underscore-dangle": ["off"]
},
"globals": {
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/xlsx/xform/drawing/data/drawing.1.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ module.exports = {
anchors: [
{
range: {
tl: { nativeRow: 0, nativeRowOff: 0, nativeCol: 0, nativeColOff: 0 },
br: { nativeRow: 7, nativeRowOff: 0, nativeCol: 3, nativeColOff: 0 },
tl: {nativeRow: 0, nativeRowOff: 0, nativeCol: 0, nativeColOff: 0},
br: {nativeRow: 7, nativeRowOff: 0, nativeCol: 3, nativeColOff: 0},
},
picture: {
rId: 'rId1',
Expand All @@ -17,7 +17,7 @@ module.exports = {
nativeCol: 5,
nativeColOff: 320000,
},
ext: { width: 100, height: 200 },
ext: {width: 100, height: 200},
},
picture: {
rId: 'rId2',
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/xlsx/xform/drawing/data/drawing.1.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module.exports = {
{
anchorType: 'xdr:twoCellAnchor',
range: {
tl: { nativeRow: 0, nativeRowOff: 0, nativeCol: 0, nativeColOff: 0 },
br: { nativeRow: 7, nativeRowOff: 0, nativeCol: 3, nativeColOff: 0 },
tl: {nativeRow: 0, nativeRowOff: 0, nativeCol: 0, nativeColOff: 0},
br: {nativeRow: 7, nativeRowOff: 0, nativeCol: 3, nativeColOff: 0},
},
picture: {
index: 1,
Expand All @@ -20,7 +20,7 @@ module.exports = {
nativeCol: 5,
nativeColOff: 320000,
},
ext: { width: 100, height: 200 },
ext: {width: 100, height: 200},
},
picture: {
index: 2,
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/xlsx/xform/drawing/data/drawing.1.3.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ module.exports = {
anchors: [
{
range: {
tl: { nativeRow: 0, nativeRowOff: 0, nativeCol: 0, nativeColOff: 0 },
br: { nativeRow: 7, nativeRowOff: 0, nativeCol: 3, nativeColOff: 0 },
tl: {nativeRow: 0, nativeRowOff: 0, nativeCol: 0, nativeColOff: 0},
br: {nativeRow: 7, nativeRowOff: 0, nativeCol: 3, nativeColOff: 0},
editAs: 'oneCell',
},
picture: {
Expand All @@ -18,7 +18,7 @@ module.exports = {
nativeCol: 5,
nativeColOff: 320000,
},
ext: { width: 100, height: 200 },
ext: {width: 100, height: 200},
editAs: 'oneCell',
},
picture: {
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/xlsx/xform/drawing/data/drawing.1.4.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ module.exports = {
anchors: [
{
range: {
tl: { nativeRow: 0, nativeRowOff: 0, nativeCol: 0, nativeColOff: 0 },
br: { nativeRow: 7, nativeRowOff: 0, nativeCol: 3, nativeColOff: 0 },
tl: {nativeRow: 0, nativeRowOff: 0, nativeCol: 0, nativeColOff: 0},
br: {nativeRow: 7, nativeRowOff: 0, nativeCol: 3, nativeColOff: 0},
editAs: 'oneCell',
},
picture: {
Expand All @@ -18,7 +18,7 @@ module.exports = {
nativeCol: 5,
nativeColOff: 320000,
},
ext: { width: 100, height: 200 },
ext: {width: 100, height: 200},
editAs: 'oneCell',
},
picture: {
Expand Down
4 changes: 3 additions & 1 deletion test/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"rules": {
"no-new": ["off"],
"max-len": ["off"],
"no-console": ["off"]
"no-console": ["off"],
"no-underscore-dangle": ["off"],
"spaced-comment": ["off"]
}
}
Loading

0 comments on commit 80eaedb

Please sign in to comment.