Skip to content

Commit 8d5f099

Browse files
committed
Run lint:fix and replace remaining var by hand
1 parent 4171c62 commit 8d5f099

File tree

260 files changed

+13782
-9620
lines changed

Some content is hidden

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

260 files changed

+13782
-9620
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"es6": true
1313
},
1414
"rules": {
15-
"comma-dangle": ["error", {"arrays": "always-multiline", "objects": "always-multiline", "imports": "always-multiline", "exports": "always-multiline", "functions": "always-multiline"}],
15+
"comma-dangle": ["error", {"arrays": "always-multiline", "objects": "always-multiline", "imports": "always-multiline", "exports": "always-multiline", "functions": "never"}],
1616
"func-names": ["off", "never"],
1717
"global-require": ["off"],
1818
"max-len": ["error", {"code": 160, "ignoreComments": true}],

.prettierignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
build
22
dist
33
out
4-
test
54
spec/manual/public/

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
};

0 commit comments

Comments
 (0)