Skip to content

Commit cee23d4

Browse files
committed
Run lint:fix and replace remaining var by hand
1 parent 4f0d9b6 commit cee23d4

File tree

258 files changed

+13781
-9618
lines changed

Some content is hidden

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

258 files changed

+13781
-9618
lines changed

gruntfile.js

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,41 @@ module.exports = function(grunt) {
1010
grunt.initConfig({
1111
babel: {
1212
options: {
13-
sourceMap: true
13+
sourceMap: true,
1414
},
1515
dist: {
1616
files: [
1717
{
1818
expand: true,
1919
src: ['./lib/**/*.js', './spec/browser/*.js'],
20-
dest: './build/'
21-
}
22-
]
23-
}
20+
dest: './build/',
21+
},
22+
],
23+
},
2424
},
2525
browserify: {
2626
bundle: {
2727
src: ['./build/lib/exceljs.browser.js'],
2828
dest: './dist/exceljs.js',
2929
options: {
3030
browserifyOptions: {
31-
standalone: 'ExcelJS'
32-
}
33-
}
31+
standalone: 'ExcelJS',
32+
},
33+
},
3434
},
3535
spec: {
3636
src: ['./build/spec/browser/exceljs.spec.js'],
37-
dest: './build/web/exceljs.spec.js'
37+
dest: './build/web/exceljs.spec.js',
3838
},
3939
},
4040
uglify: {
4141
options: {
42-
banner: '/*! ExcelJS <%= grunt.template.today("dd-mm-yyyy") %> */\n'
42+
banner: '/*! ExcelJS <%= grunt.template.today("dd-mm-yyyy") %> */\n',
4343
},
4444
dist: {
4545
files: {
46-
'./dist/exceljs.min.js': ['./dist/exceljs.js']
47-
}
46+
'./dist/exceljs.min.js': ['./dist/exceljs.js'],
47+
},
4848
},
4949
// es3: {
5050
// files: [
@@ -64,20 +64,17 @@ module.exports = function(grunt) {
6464

6565
copy: {
6666
dist: {
67-
files: [
68-
{ expand: true, src: ['**'], cwd: './build/lib', dest: './dist/es5' },
69-
{ src: './build/lib/exceljs.nodejs.js', dest: './dist/es5/index.js'},
70-
]
71-
}
67+
files: [{ expand: true, src: ['**'], cwd: './build/lib', dest: './dist/es5' }, { src: './build/lib/exceljs.nodejs.js', dest: './dist/es5/index.js' }],
68+
},
7269
},
7370

7471
jasmine: {
7572
dev: {
7673
src: ['./dist/exceljs.js'],
7774
options: {
78-
specs: './build/web/exceljs.spec.js'
79-
}
80-
}
75+
specs: './build/web/exceljs.spec.js',
76+
},
77+
},
8178
},
8279
});
8380

lib/config/set-value.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
var PromishLib = require('../utils/promish');
3+
const PromishLib = require('../utils/promish');
44

55
function setValue(key, value, overwrite) {
66
if (overwrite === undefined) {

lib/csv/csv.js

Lines changed: 61 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,23 @@
66

77
'use strict';
88

9+
const fs = require('fs');
10+
const csv = require('fast-csv');
11+
const moment = require('moment');
12+
const PromishLib = require('../utils/promish');
13+
const StreamBuf = require('../utils/stream-buf');
914

10-
var fs = require('fs');
11-
var csv = require('fast-csv');
12-
var moment = require('moment');
13-
var PromishLib = require('../utils/promish');
14-
var StreamBuf = require('../utils/stream-buf');
15+
const utils = require('../utils/utils');
1516

16-
var utils = require('../utils/utils');
17-
18-
var CSV = module.exports = function(workbook) {
17+
const CSV = (module.exports = function(workbook) {
1918
this.workbook = workbook;
2019
this.worksheet = null;
21-
};
20+
});
2221

2322
/* eslint-disable quote-props */
24-
var SpecialValues = {
25-
'true': true,
26-
'false': false,
23+
const SpecialValues = {
24+
true: true,
25+
false: false,
2726
'#N/A': { error: '#N/A' },
2827
'#REF!': { error: '#REF!' },
2928
'#NAME?': { error: '#NAME?' },
@@ -34,89 +33,91 @@ var SpecialValues = {
3433
};
3534
/* eslint-ensable quote-props */
3635

37-
3836
CSV.prototype = {
39-
readFile: function(filename, options) {
40-
var self = this;
37+
readFile(filename, options) {
38+
const self = this;
4139
options = options || {};
42-
var stream;
43-
return utils.fs.exists(filename)
44-
.then(function(exists) {
40+
let stream;
41+
return utils.fs
42+
.exists(filename)
43+
.then(exists => {
4544
if (!exists) {
46-
throw new Error('File not found: ' + filename);
45+
throw new Error(`File not found: ${filename}`);
4746
}
4847
stream = fs.createReadStream(filename);
4948
return self.read(stream, options);
5049
})
51-
.then(function(worksheet) {
50+
.then(worksheet => {
5251
stream.close();
5352
return worksheet;
5453
});
5554
},
56-
read: function(stream, options) {
55+
read(stream, options) {
5756
options = options || {};
5857
return new PromishLib.Promish((resolve, reject) => {
59-
var csvStream = this.createInputStream(options)
58+
const csvStream = this.createInputStream(options)
6059
.on('worksheet', resolve)
6160
.on('error', reject);
6261

6362
stream.pipe(csvStream);
6463
});
6564
},
66-
createInputStream: function(options) {
65+
createInputStream(options) {
6766
options = options || {};
68-
var worksheet = this.workbook.addWorksheet(options.sheetName);
69-
70-
var dateFormats = options.dateFormats || [
71-
moment.ISO_8601,
72-
'MM-DD-YYYY',
73-
'YYYY-MM-DD'
74-
];
75-
var map = options.map || function(datum) {
67+
const worksheet = this.workbook.addWorksheet(options.sheetName);
68+
69+
const dateFormats = options.dateFormats || [moment.ISO_8601, 'MM-DD-YYYY', 'YYYY-MM-DD'];
70+
const map =
71+
options.map ||
72+
function(datum) {
7673
if (datum === '') {
7774
return null;
7875
}
7976
if (!isNaN(datum)) {
8077
return parseFloat(datum);
8178
}
82-
var dt = moment(datum, dateFormats, true);
79+
const dt = moment(datum, dateFormats, true);
8380
if (dt.isValid()) {
8481
return new Date(dt.valueOf());
8582
}
86-
var special = SpecialValues[datum];
83+
const special = SpecialValues[datum];
8784
if (special !== undefined) {
8885
return special;
8986
}
9087
return datum;
9188
};
9289

93-
var csvStream = csv(options)
94-
.on('data', function(data) {
90+
const csvStream = csv(options)
91+
.on('data', data => {
9592
worksheet.addRow(data.map(map));
9693
})
97-
.on('end', function() {
94+
.on('end', () => {
9895
csvStream.emit('worksheet', worksheet);
9996
});
10097
return csvStream;
10198
},
10299

103-
write: function(stream, options) {
100+
write(stream, options) {
104101
return new PromishLib.Promish((resolve, reject) => {
105102
options = options || {};
106-
// var encoding = options.encoding || 'utf8';
107-
// var separator = options.separator || ',';
108-
// var quoteChar = options.quoteChar || '\'';
103+
// const encoding = options.encoding || 'utf8';
104+
// const separator = options.separator || ',';
105+
// const quoteChar = options.quoteChar || '\'';
109106

110-
var worksheet = this.workbook.getWorksheet(options.sheetName || options.sheetId);
107+
const worksheet = this.workbook.getWorksheet(options.sheetName || options.sheetId);
111108

112-
var csvStream = csv.createWriteStream(options);
113-
stream.on('finish', () => { resolve(); });
109+
const csvStream = csv.createWriteStream(options);
110+
stream.on('finish', () => {
111+
resolve();
112+
});
114113
csvStream.on('error', reject);
115114
csvStream.pipe(stream);
116115

117-
var dateFormat = options.dateFormat;
118-
var dateUTC = options.dateUTC;
119-
var map = options.map || (value => {
116+
const dateFormat = options.dateFormat;
117+
const dateUTC = options.dateUTC;
118+
const map =
119+
options.map ||
120+
(value => {
120121
if (value) {
121122
if (value.text || value.hyperlink) {
122123
return value.hyperlink || value.text || '';
@@ -128,7 +129,7 @@ CSV.prototype = {
128129
if (dateFormat) {
129130
dateUTC ? moment.utc(value).format(dateFormat) : moment(value).format(dateFormat);
130131
}
131-
return dateUTC ? moment.utc(value).format() : moment(value).format()
132+
return dateUTC ? moment.utc(value).format() : moment(value).format();
132133
}
133134
if (value.error) {
134135
return value.error;
@@ -140,16 +141,16 @@ CSV.prototype = {
140141
return value;
141142
});
142143

143-
var includeEmptyRows = (options.includeEmptyRows === undefined) || options.includeEmptyRows;
144-
var lastRow = 1;
144+
const includeEmptyRows = options.includeEmptyRows === undefined || options.includeEmptyRows;
145+
let lastRow = 1;
145146
if (worksheet) {
146-
worksheet.eachRow(function(row, rowNumber) {
147+
worksheet.eachRow((row, rowNumber) => {
147148
if (includeEmptyRows) {
148149
while (lastRow++ < rowNumber - 1) {
149150
csvStream.write([]);
150151
}
151152
}
152-
var values = row.values;
153+
const values = row.values;
153154
values.shift();
154155
csvStream.write(values.map(map));
155156
lastRow = rowNumber;
@@ -158,22 +159,19 @@ CSV.prototype = {
158159
csvStream.end();
159160
});
160161
},
161-
writeFile: function(filename, options) {
162+
writeFile(filename, options) {
162163
options = options || {};
163164

164-
var streamOptions = {
165-
encoding: options.encoding || 'utf8'
165+
const streamOptions = {
166+
encoding: options.encoding || 'utf8',
166167
};
167-
var stream = fs.createWriteStream(filename, streamOptions);
168+
const stream = fs.createWriteStream(filename, streamOptions);
168169

169170
return this.write(stream, options);
170171
},
171-
writeBuffer: function(options) {
172-
var self = this;
173-
var stream = new StreamBuf();
174-
return self.write(stream, options)
175-
.then(function() {
176-
return stream.read();
177-
});
178-
}
172+
writeBuffer(options) {
173+
const self = this;
174+
const stream = new StreamBuf();
175+
return self.write(stream, options).then(() => stream.read());
176+
},
179177
};

lib/csv/line-buffer.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66

77
'use strict';
88

9-
var events = require('events');
9+
const events = require('events');
1010

11-
var utils = require('../utils/utils');
11+
const utils = require('../utils/utils');
1212

13-
14-
var LineBuffer = module.exports = function(options) {
13+
const LineBuffer = (module.exports = function(options) {
1514
events.EventEmitter.call(this);
1615
this.encoding = options.encoding;
1716

@@ -20,18 +19,18 @@ var LineBuffer = module.exports = function(options) {
2019
// part of cork/uncork
2120
this.corked = false;
2221
this.queue = [];
23-
};
22+
});
2423

2524
utils.inherits(LineBuffer, events.EventEmitter, {
2625
// Events:
2726
// line: here is a line
2827
// done: all lines emitted
2928

30-
write: function(chunk) {
29+
write(chunk) {
3130
// find line or lines in chunk and emit them if not corked
3231
// or queue them if corked
33-
var data = this.buffer ? this.buffer + chunk : chunk;
34-
var lines = data.split(/\r?\n/g);
32+
const data = this.buffer ? this.buffer + chunk : chunk;
33+
const lines = data.split(/\r?\n/g);
3534

3635
// save the last line
3736
this.buffer = lines.pop();
@@ -46,33 +45,33 @@ utils.inherits(LineBuffer, events.EventEmitter, {
4645

4746
return !this.corked;
4847
},
49-
cork: function() {
48+
cork() {
5049
this.corked = true;
5150
},
52-
uncork: function() {
51+
uncork() {
5352
this.corked = false;
5453
this._flush();
5554

5655
// tell the source I'm ready again
5756
this.emit('drain');
5857
},
59-
setDefaultEncoding: function() {
58+
setDefaultEncoding() {
6059
// ?
6160
},
62-
end: function() {
61+
end() {
6362
if (this.buffer) {
6463
this.emit('line', this.buffer);
6564
this.buffer = null;
6665
}
6766
this.emit('done');
6867
},
6968

70-
_flush: function() {
69+
_flush() {
7170
if (!this.corked) {
7271
this.queue.forEach(function(line) {
7372
this.emit('line', line);
7473
});
7574
this.queue = [];
7675
}
77-
}
76+
},
7877
});

0 commit comments

Comments
 (0)