Skip to content

Commit

Permalink
eslinting
Browse files Browse the repository at this point in the history
  • Loading branch information
guyonroche committed May 16, 2017
1 parent 22ba773 commit cf17c73
Show file tree
Hide file tree
Showing 155 changed files with 1,009 additions and 975 deletions.
28 changes: 9 additions & 19 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
{
"extends": "airbnb",
"rules": {
"max-len": [1, 160, 2, {"ignoreComments": true}],
"semi": ["error", "always"],
"object-property-newline": ["off", { "allowMultiplePropertiesPerLine": true }],
"func-names": ["off", "never"],
"space-before-function-paren": ["error", "never"],
"no-trailing-spaces": ["error", { "skipBlankLines": true }],
"no-mixed-operators": ["error", {"allowSamePrecedence": true}],
"linebreak-style": ["off"],
"no-use-before-define": ["error", { "variables": false, "classes": false, "functions": false }],

"no-var": ["off"],
"dot-notation": ["off"],
"one-var": ["off"],
"no-mixed-operators": ["error", {"allowSamePrecedence": true}],
"one-var-declaration-per-line": ["off"],
"no-prototype-builtins": ["off"],
"arrow-parens": ["off"],
"quote-props": ["off"],
"no-use-before-define": ["off"],
"no-underscore-dangle": ["off"],
"vars-on-top": ["off"],
"no-param-reassign": ["off"],
Expand All @@ -26,25 +32,9 @@
"object-curly-spacing": ["off"],
"no-plusplus": ["off"],
"no-unused-expressions": ["off"],
"no-trailing-spaces": ["error", { "skipBlankLines": true }],
"global-require": ["off"],
"no-sparse-arrays": ["off"],
"comma-spacing": ["off"],
"brace-style": ["off"],
"space-before-function-paren": ["off"],
"no-unused-vars": ["off"],
"key-spacing": ["off"],
"object-property-newline": ["off"],
"block-spacing": ["off"],
"consistent-return": ["off"],
"keyword-spacing": ["off"],
"semi": ["off"],
"no-path-concat": ["off"],
"prefer-rest-params": ["off"],
"max-len": [1, 160, 2, {"ignoreComments": true}]
},
"globals": {
"describe": true,
"it": true
"prefer-rest-params": ["off"]
}
}
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ npm install exceljs
<ul>
<li>
Switching to transpiled code for distribution.
This will ensure compatability with 4.0.0 and above from here on.
This will ensure compatability with 4.0.0 and above from here on.
And it will also allow use of much more expressive JS code in the lib folder!
</li>
<li>
<a href="#images">Basic Image Support!</a>
Expand All @@ -34,6 +35,7 @@ To be clear, all contributions added to this library will be included in the lib
# Backlog

<ul>
<li>ESLint - slowly turn on (justifyable) rules which should hopefully make contributions easier.</li>
<li>Conditional Formatting.</li>
<li>There are still more print-settings to add; Fixed rows/cols, etc.</li>
<li>XLSX Streaming Reader.</li>
Expand Down
2 changes: 1 addition & 1 deletion lib/csv/csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ CSV.prototype = {
var includeEmptyRows = (options.includeEmptyRows === undefined) || options.includeEmptyRows;
var lastRow = 1;
if (worksheet) {
worksheet.eachRow(function (row, rowNumber) {
worksheet.eachRow(function(row, rowNumber) {
if (includeEmptyRows) {
while (lastRow++ < rowNumber - 1) {
csvStream.write([]);
Expand Down
6 changes: 3 additions & 3 deletions lib/csv/stream-converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Work in Progress - Will complete this at some point
var jconv;

var StreamConverter = module.exports = function (inner, options) {
var StreamConverter = module.exports = function(inner, options) {
this.inner = inner;

options = options || {};
Expand Down Expand Up @@ -50,7 +50,7 @@ StreamConverter.prototype.addListener = function(event, handler) {

StreamConverter.prototype.removeListener = function(event, handler) {
this.inner.removeListener(event, handler);
}
};

StreamConverter.prototype.write = function(data, encoding, callback) {
if (encoding instanceof Function) {
Expand Down Expand Up @@ -96,7 +96,7 @@ StreamConverter.prototype.pipe = function(destination, options) {
outerBOM: this.innerBOM
});

this.inner.pipe(reverseConverter, options)
this.inner.pipe(reverseConverter, options);
};

StreamConverter.prototype.close = function() {
Expand Down
32 changes: 16 additions & 16 deletions lib/doc/cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ Cell.prototype = {
},
get text() {
return this._value.toString();
} ,
},
toString: function() {
return this.text;
},
Expand Down Expand Up @@ -273,7 +273,7 @@ Cell.prototype = {
},

get dataValidation() {
return this._dataValidations.find(this.address)
return this._dataValidations.find(this.address);
},

set dataValidation(value) {
Expand Down Expand Up @@ -858,7 +858,7 @@ JSONValue.prototype = {

// Value is a place to hold common static Value type functions
var Value = {
getType: function(value) {
getType: function(value) {
if ((value === null) || (value === undefined)) {
return Cell.Types.Null;
} else if ((value instanceof String) || (typeof value === 'string')) {
Expand All @@ -885,19 +885,19 @@ var Value = {

// map valueType to constructor
types: [
{t:Cell.Types.Null, f:NullValue},
{t:Cell.Types.Number, f:NumberValue},
{t:Cell.Types.String, f:StringValue},
{t:Cell.Types.Date, f:DateValue},
{t:Cell.Types.Hyperlink, f:HyperlinkValue},
{t:Cell.Types.Formula, f:FormulaValue},
{t:Cell.Types.Merge, f:MergeValue},
{t:Cell.Types.JSON, f:JSONValue},
{t:Cell.Types.SharedString, f:SharedStringValue},
{t:Cell.Types.RichText, f:RichTextValue},
{t:Cell.Types.Boolean, f:BooleanValue},
{t:Cell.Types.Error, f:ErrorValue},
].reduce((p,t) => { p[t.t] = t.f; return p; }, []),
{t: Cell.Types.Null, f: NullValue},
{t: Cell.Types.Number, f: NumberValue},
{t: Cell.Types.String, f: StringValue},
{t: Cell.Types.Date, f: DateValue},
{t: Cell.Types.Hyperlink, f: HyperlinkValue},
{t: Cell.Types.Formula, f: FormulaValue},
{t: Cell.Types.Merge, f: MergeValue},
{t: Cell.Types.JSON, f: JSONValue},
{t: Cell.Types.SharedString, f: SharedStringValue},
{t: Cell.Types.RichText, f: RichTextValue},
{t: Cell.Types.Boolean, f: BooleanValue},
{t: Cell.Types.Error, f: ErrorValue},
].reduce((p, t) => { p[t.t] = t.f; return p; }, []),

create: function(type, cell, value) {
var T = this.types[type];
Expand Down
29 changes: 14 additions & 15 deletions lib/doc/column.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var colCache = require('../utils/col-cache');
// Column defines the column properties for 1 column.
// This includes header rows, widths, key, (style), etc.
// Worksheet will condense the columns as appropriate during serialization
var Column = module.exports = function (worksheet, number, defn) {
var Column = module.exports = function(worksheet, number, defn) {
this._worksheet = worksheet;
this._number = number;
if (defn !== false) {
Expand Down Expand Up @@ -51,9 +51,8 @@ Column.prototype = {
this.outlineLevel = value.outlineLevel;
if (value.style) {
this.style = value.style;
}
else {
this.style = {}
} else {
this.style = {};
}

// headers must be set after style
Expand All @@ -77,7 +76,7 @@ Column.prototype = {
if (value !== undefined) {
var self = this;
this._header = value;
this.headers.forEach(function (text, index) {
this.headers.forEach(function(text, index) {
self._worksheet.getCell(index + 1, self.number).value = text;
});
} else {
Expand Down Expand Up @@ -112,14 +111,14 @@ Column.prototype = {
return !!(this._outlineLevel && (this._outlineLevel >= this._worksheet.properties.outlineLevelCol));
},

toString: function () {
toString: function() {
return JSON.stringify({
key: this.key,
width: this.width,
headers: this.headers.length ? this.headers : undefined
});
},
equivalentTo: function (other) {
equivalentTo: function(other) {
return (this.width === other.width) &&
(this.hidden === other.hidden) &&
(this.outlineLevel === other.outlineLevel) &&
Expand All @@ -145,18 +144,18 @@ Column.prototype = {
return this.headers.length;
},

eachCell: function (options, iteratee) {
eachCell: function(options, iteratee) {
var colNumber = this.number;
if (!iteratee) {
iteratee = options;
options = null;
}
if (options && options.includeEmpty) {
this._worksheet.eachRow(options, function (row, rowNumber) {
this._worksheet.eachRow(options, function(row, rowNumber) {
iteratee(row.getCell(colNumber), rowNumber);
});
} else {
this._worksheet.eachRow(function (row, rowNumber) {
this._worksheet.eachRow(function(row, rowNumber) {
var cell = row.findCell(colNumber);
if (cell) {
iteratee(cell, rowNumber);
Expand All @@ -167,9 +166,9 @@ Column.prototype = {

// =========================================================================
// styles
_applyStyle: function (name, value) {
_applyStyle: function(name, value) {
this.style[name] = value;
this.eachCell(function (cell) {
this.eachCell(function(cell) {
cell[name] = value;
});
return value;
Expand Down Expand Up @@ -210,12 +209,12 @@ Column.prototype = {
// =============================================================================
// static functions

Column.toModel = function (columns) {
Column.toModel = function(columns) {
// Convert array of Column into compressed list cols
var cols = [];
var col = null;
if (columns) {
columns.forEach(function (column, index) {
columns.forEach(function(column, index) {
if (column.isDefault) {
if (col) {
col = null;
Expand All @@ -240,7 +239,7 @@ Column.toModel = function (columns) {
return cols.length ? cols : undefined;
};

Column.fromModel = function (worksheet, cols) {
Column.fromModel = function(worksheet, cols) {
cols = cols || [];
var columns = [];
var count = 1;
Expand Down
13 changes: 6 additions & 7 deletions lib/doc/defined-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var colCache = require('../utils/col-cache');
var CellMatrix = require('../utils/cell-matrix');
var Range = require('./range');

var rangeRegexp = /\$(\w+)\$(\d+)(:\$(\w+)\$(\d+))?/;
var rangeRegexp = /[$](\w+)[$](\d+)(:[$](\w+)[$](\d+))?/;

var DefinedNames = module.exports = function() {
this.matrixMap = {};
Expand Down Expand Up @@ -74,11 +74,10 @@ DefinedNames.prototype = {
return this.getNamesEx(colCache.decodeEx(addressStr));
},
getNamesEx: function(address) {
return _.map(this.matrixMap, function(matrix, name) {
if (matrix.findCellEx(address)) {
return name;
}
}).filter(function(name) { return name; });
return _.map(
this.matrixMap,
(matrix, name) => matrix.findCellEx(address) && name
).filter(Boolean);
},

_explore: function(matrix, cell) {
Expand Down Expand Up @@ -159,7 +158,7 @@ DefinedNames.prototype = {
value.forEach(function(definedName) {
var matrix = matrixMap[definedName.name] = new CellMatrix();
definedName.ranges.forEach(function(rangeStr) {
if(rangeRegexp.test(rangeStr.split('!').pop() || '')) {
if (rangeRegexp.test(rangeStr.split('!').pop() || '')) {
matrix.addCell(rangeStr);
}
});
Expand Down
10 changes: 5 additions & 5 deletions lib/doc/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ var Range = module.exports = function() {
};

Range.prototype = {
_set_tlbr: function(t,l,b,r, s) {
_set_tlbr: function(t, l, b, r, s) {
this.model = {
top: Math.min(t,b),
left: Math.min(l,r),
bottom: Math.max(t,b),
right: Math.max(l,r),
top: Math.min(t, b),
left: Math.min(l, r),
bottom: Math.max(t, b),
right: Math.max(l, r),
sheetName: s
};
},
Expand Down
Loading

0 comments on commit cf17c73

Please sign in to comment.