Update eslint to the latest version 🚀 (#86)

This commit is contained in:
greenkeeper[bot] 2019-03-09 13:51:49 +01:00 committed by Luke Page
parent d6bf8d133a
commit 7e160967c9
11 changed files with 2850 additions and 202 deletions

View file

@ -1,183 +1,182 @@
{ {
"ecmaFeatures": {},
"rules": { "rules": {
"no-alert": 2, "no-alert": "error",
"no-array-constructor": 0, "no-array-constructor": "off",
"no-bitwise": 0, "no-bitwise": "off",
"no-caller": 2, "no-caller": "error",
"no-catch-shadow": 2, "no-catch-shadow": "error",
"no-class-assign": 2, "no-class-assign": "error",
"no-cond-assign": 2, "no-cond-assign": "error",
"no-console": 2, "no-console": "error",
"no-const-assign": 2, "no-const-assign": "error",
"no-constant-condition": 2, "no-constant-condition": "error",
"no-continue": 0, "no-continue": "off",
"no-control-regex": 2, "no-control-regex": "error",
"no-debugger": 2, "no-debugger": "error",
"no-delete-var": 2, "no-delete-var": "error",
"no-div-regex": 0, "no-div-regex": "off",
"no-dupe-keys": 2, "no-dupe-keys": "error",
"no-dupe-args": 2, "no-dupe-args": "error",
"no-duplicate-case": 2, "no-duplicate-case": "error",
"no-else-return": 1, "no-else-return": "error",
"no-empty": 2, "no-empty": "error",
"no-empty-character-class": 2, "no-empty-character-class": "error",
"no-eq-null": 0, "no-eq-null": "off",
"no-eval": 2, "no-eval": "error",
"no-ex-assign": 2, "no-ex-assign": "error",
"no-extend-native": 2, "no-extend-native": "error",
"no-extra-bind": 1, "no-extra-bind": "error",
"no-extra-boolean-cast": 2, "no-extra-boolean-cast": "error",
"no-extra-parens": 0, "no-extra-parens": "off",
"no-extra-semi": 2, "no-extra-semi": "error",
"no-fallthrough": 2, "no-fallthrough": "error",
"no-floating-decimal": 1, "no-floating-decimal": "error",
"no-func-assign": 2, "no-func-assign": "error",
"no-implicit-coercion": 1, "no-implicit-coercion": "error",
"no-implied-eval": 1, "no-implied-eval": "error",
"no-inline-comments": 0, "no-inline-comments": "off",
"no-inner-declarations": [2, "functions"], "no-inner-declarations": ["error", "functions"],
"no-invalid-regexp": 2, "no-invalid-regexp": "error",
"no-invalid-this": 1, "no-invalid-this": "error",
"no-irregular-whitespace": 2, "no-irregular-whitespace": "error",
"no-iterator": 1, "no-iterator": "error",
"no-label-var": 1, "no-label-var": "error",
"no-labels": 1, "no-labels": "error",
"no-lone-blocks": 1, "no-lone-blocks": "error",
"no-lonely-if": 1, "no-lonely-if": "error",
"no-loop-func": 1, "no-loop-func": "error",
"no-mixed-requires": [1, false], "no-mixed-requires": ["error", false],
"no-mixed-spaces-and-tabs": [2, false], "no-mixed-spaces-and-tabs": ["error", false],
"linebreak-style": [0, "unix"], "linebreak-style": ["off", "unix"],
"no-multi-spaces": 1, "no-multi-spaces": "error",
"no-multi-str": 0, "no-multi-str": "off",
"no-multiple-empty-lines": [1, {"max": 2}], "no-multiple-empty-lines": ["error", {"max": 2}],
"no-native-reassign": 2, "no-native-reassign": "error",
"no-negated-in-lhs": 2, "no-negated-in-lhs": "error",
"no-nested-ternary": 1, "no-nested-ternary": "error",
"no-new": 1, "no-new": "error",
"no-new-func": 1, "no-new-func": "error",
"no-new-object": 1, "no-new-object": "error",
"no-new-require": 1, "no-new-require": "error",
"no-new-wrappers": 1, "no-new-wrappers": "error",
"no-obj-calls": 2, "no-obj-calls": "error",
"no-octal": 2, "no-octal": "error",
"no-octal-escape": 0, "no-octal-escape": "off",
"no-param-reassign": 1, "no-param-reassign": "off",
"no-path-concat": 0, "no-path-concat": "off",
"no-plusplus": 0, "no-plusplus": "off",
"no-process-env": 0, "no-process-env": "off",
"no-process-exit": 0, "no-process-exit": "off",
"no-proto": 0, "no-proto": "off",
"no-redeclare": 2, "no-redeclare": "error",
"no-regex-spaces": 2, "no-regex-spaces": "error",
"no-restricted-modules": 0, "no-restricted-modules": "off",
"no-return-assign": 1, "no-return-assign": "error",
"no-script-url": 0, "no-script-url": "off",
"no-self-compare": 1, "no-self-compare": "error",
"no-sequences": 1, "no-sequences": "error",
"no-shadow": 1, "no-shadow": "error",
"no-shadow-restricted-names": 1, "no-shadow-restricted-names": "error",
"no-spaced-func": 1, "no-spaced-func": "error",
"no-sparse-arrays": 2, "no-sparse-arrays": "error",
"no-sync": 0, "no-sync": "off",
"no-ternary": 0, "no-ternary": "off",
"no-trailing-spaces": 1, "no-trailing-spaces": "error",
"no-this-before-super": 1, "no-this-before-super": "error",
"no-throw-literal": 1, "no-throw-literal": "error",
"no-undef": 2, "no-undef": "error",
"no-undef-init": 1, "no-undef-init": "error",
"no-undefined": 0, "no-undefined": "off",
"no-unexpected-multiline": 1, "no-unexpected-multiline": "error",
"no-underscore-dangle": 0, "no-underscore-dangle": "off",
"no-unneeded-ternary": 0, "no-unneeded-ternary": "off",
"no-unreachable": 2, "no-unreachable": "error",
"no-unused-expressions": 1, "no-unused-expressions": "error",
"no-unused-vars": [2, {"vars": "all", "args": "after-used"}], "no-unused-vars": ["error", {"vars": "all", "args": "after-used"}],
"no-use-before-define": 2, "no-use-before-define": "error",
"no-useless-call": 2, "no-useless-call": "error",
"no-void": 0, "no-void": "off",
"no-var": 0, "no-var": "off",
"no-warning-comments": [1, { "terms": ["todo", "fixme", "xxx"], "location": "start" }], "no-warning-comments": ["error", { "terms": ["todo", "fixme", "xxx"], "location": "start" }],
"no-with": 1, "no-with": "error",
"array-bracket-spacing": [1, "never"], "array-bracket-spacing": ["error", "never"],
"arrow-parens": 1, "arrow-parens": "error",
"arrow-spacing": 1, "arrow-spacing": "error",
"accessor-pairs": 1, "accessor-pairs": "error",
"block-scoped-var": 0, "block-scoped-var": "off",
"brace-style": [1, "stroustrup"], "brace-style": ["error", "stroustrup"],
"callback-return": [2, ["callback", "cb", "next"]], "callback-return": ["error", ["callback", "cb", "next"]],
"camelcase": [2, {"properties": "always"}], "camelcase": ["error", {"properties": "always"}],
"comma-dangle": [2, "never"], "comma-dangle": ["error", "never"],
"comma-spacing": 2, "comma-spacing": "error",
"comma-style": 1, "comma-style": "error",
"complexity": [1, 10], "complexity": "off",
"computed-property-spacing": [0, "never"], "computed-property-spacing": ["off", "never"],
"consistent-return": 0, "consistent-return": "off",
"consistent-this": [0, "that"], "consistent-this": ["off", "that"],
"constructor-super": 1, "constructor-super": "error",
"curly": [1, "all"], "curly": ["error", "all"],
"default-case": 1, "default-case": "error",
"dot-location": [1, "property"], "dot-location": ["error", "property"],
"dot-notation": [1, { "allowKeywords": true }], "dot-notation": ["error", { "allowKeywords": true }],
"eol-last": 0, "eol-last": "off",
"eqeqeq": 1, "eqeqeq": ["error", "smart"],
"func-names": 0, "func-names": "off",
"func-style": [0, "declaration"], "func-style": ["off", "declaration"],
"generator-star-spacing": 0, "generator-star-spacing": "off",
"guard-for-in": 1, "guard-for-in": "error",
"handle-callback-err": 2, "handle-callback-err": "error",
"id-length": [2, {"min": 3, "max": 25, "exceptions":["x", "y", "i", "j", "ex", "up"]}], "id-length": ["error", {"min": 3, "max": 25, "exceptions":["x", "y", "i", "j", "ex", "up"]}],
"indent": [1, 2, {"SwitchCase": 1}], "indent": ["error", 2, {"SwitchCase": 1}],
"init-declarations": 0, "init-declarations": "off",
"key-spacing": [1, { "beforeColon": false, "afterColon": true }], "key-spacing": ["error", { "beforeColon": false, "afterColon": true }],
"keyword-spacing": 1, "keyword-spacing": "error",
"lines-around-comment": 0, "lines-around-comment": "off",
"max-depth": [1, 4], "max-depth": ["error", 6],
"max-len": [1, 160, 2], "max-len": ["error", { "code": 160 }],
"max-nested-callbacks": [1, 2], "max-nested-callbacks": ["error", 1],
"max-params": [1, 5], "max-params": ["error", 6],
"max-statements": [1, 30], "max-statements": "off",
"new-cap": 1, "new-cap": "error",
"new-parens": 1, "new-parens": "error",
"newline-after-var": 0, "newline-after-var": "off",
"object-curly-spacing": [1, "always"], "object-curly-spacing": ["error", "always"],
"object-shorthand": 0, "object-shorthand": "off",
"one-var": [1, { "one-var": ["error", {
"initialized": "never" "initialized": "never"
}], }],
"operator-assignment": [0, "always"], "operator-assignment": ["off", "always"],
"operator-linebreak": [1, "after"], "operator-linebreak": ["error", "after"],
"padded-blocks": 0, "padded-blocks": "off",
"prefer-const": 0, "prefer-const": "off",
"prefer-spread": 0, "prefer-spread": "off",
"prefer-reflect": 0, "prefer-reflect": "off",
"quote-props": 0, "quote-props": "off",
"quotes": [1, "single"], "quotes": ["error", "single"],
"radix": 0, "radix": "off",
"id-match": 0, "id-match": "off",
"require-yield": 0, "require-yield": "off",
"semi": [1, "always"], "semi": ["error", "always"],
"semi-spacing": [1, {"before": false, "after": true}], "semi-spacing": ["error", {"before": false, "after": true}],
"sort-vars": 0, "sort-vars": "off",
"space-before-blocks": [1, "always"], "space-before-blocks": ["error", "always"],
"space-before-function-paren": [1, "never"], "space-before-function-paren": ["error", "never"],
"space-in-parens": [1, "never"], "space-in-parens": ["error", "never"],
"space-infix-ops": 1, "space-infix-ops": "error",
"space-unary-ops": [1, { "words": true, "nonwords": false }], "space-unary-ops": ["error", { "words": true, "nonwords": false }],
"spaced-comment": 0, "spaced-comment": "off",
"strict": [2, "global"], "strict": ["error", "global"],
"use-isnan": 2, "use-isnan": "error",
"valid-jsdoc": 0, "valid-jsdoc": "off",
"valid-typeof": 2, "valid-typeof": "error",
"vars-on-top": 0, "vars-on-top": "off",
"wrap-iife": 0, "wrap-iife": "off",
"wrap-regex": 0, "wrap-regex": "off",
"yoda": [0, "never"] "yoda": ["off", "never"]
}, },
"env": { "env": {
"node": true, "node": true,
"es6": true "es6": true
} }
} }

View file

@ -12,8 +12,8 @@ module.exports = function(dataIn, width, height, options) {
return new Int16Array(buffer)[0] !== 256; return new Int16Array(buffer)[0] !== 256;
})(); })();
// If no need to convert to grayscale and alpha is present/absent in both, take a fast route // If no need to convert to grayscale and alpha is present/absent in both, take a fast route
if (options.bitDepth === 8 || (options.bitDepth === 16 && bigEndian)){ if (options.bitDepth === 8 || (options.bitDepth === 16 && bigEndian)) {
return dataIn; return dataIn;
} }
} }
@ -22,7 +22,9 @@ module.exports = function(dataIn, width, height, options) {
var maxValue = 255; var maxValue = 255;
var inBpp = constants.COLORTYPE_TO_BPP_MAP[options.inputColorType]; var inBpp = constants.COLORTYPE_TO_BPP_MAP[options.inputColorType];
if (inBpp == 4 && !options.inputHasAlpha) inBpp = 3; if (inBpp === 4 && !options.inputHasAlpha) {
inBpp = 3;
}
var outBpp = constants.COLORTYPE_TO_BPP_MAP[options.colorType]; var outBpp = constants.COLORTYPE_TO_BPP_MAP[options.colorType];
if (options.bitDepth === 16) { if (options.bitDepth === 16) {
maxValue = 65535; maxValue = 65535;
@ -44,19 +46,22 @@ module.exports = function(dataIn, width, height, options) {
bgColor.blue = maxValue; bgColor.blue = maxValue;
} }
function getRGBA(data, inIndex) { function getRGBA() {
var red, green, blue, alpha = maxValue; var red;
var green;
var blue;
var alpha = maxValue;
switch (options.inputColorType) { switch (options.inputColorType) {
case constants.COLORTYPE_COLOR_ALPHA: case constants.COLORTYPE_COLOR_ALPHA:
alpha = data[inIndex + 3]; alpha = data[inIndex + 3];
red = data[inIndex]; red = data[inIndex];
green = data[inIndex+1]; green = data[inIndex + 1];
blue = data[inIndex+2]; blue = data[inIndex + 2];
break; break;
case constants.COLORTYPE_COLOR: case constants.COLORTYPE_COLOR:
red = data[inIndex]; red = data[inIndex];
green = data[inIndex+1]; green = data[inIndex + 1];
blue = data[inIndex+2]; blue = data[inIndex + 2];
break; break;
case constants.COLORTYPE_ALPHA: case constants.COLORTYPE_ALPHA:
alpha = data[inIndex + 1]; alpha = data[inIndex + 1];
@ -81,7 +86,7 @@ module.exports = function(dataIn, width, height, options) {
blue = Math.min(Math.max(Math.round((1 - alpha) * bgColor.blue + alpha * blue), 0), maxValue); blue = Math.min(Math.max(Math.round((1 - alpha) * bgColor.blue + alpha * blue), 0), maxValue);
} }
} }
return {red: red, green: green, blue: blue, alpha: alpha}; return { red: red, green: green, blue: blue, alpha: alpha };
} }
for (var y = 0; y < height; y++) { for (var y = 0; y < height; y++) {
@ -98,7 +103,8 @@ module.exports = function(dataIn, width, height, options) {
if (outHasAlpha) { if (outHasAlpha) {
outData[outIndex + 3] = rgba.alpha; outData[outIndex + 3] = rgba.alpha;
} }
} else { }
else {
outData.writeUInt16BE(rgba.red, outIndex); outData.writeUInt16BE(rgba.red, outIndex);
outData.writeUInt16BE(rgba.green, outIndex + 2); outData.writeUInt16BE(rgba.green, outIndex + 2);
outData.writeUInt16BE(rgba.blue, outIndex + 4); outData.writeUInt16BE(rgba.blue, outIndex + 4);
@ -116,13 +122,16 @@ module.exports = function(dataIn, width, height, options) {
if (outHasAlpha) { if (outHasAlpha) {
outData[outIndex + 1] = rgba.alpha; outData[outIndex + 1] = rgba.alpha;
} }
} else { }
else {
outData.writeUInt16BE(grayscale, outIndex); outData.writeUInt16BE(grayscale, outIndex);
if (outHasAlpha) { if (outHasAlpha) {
outData.writeUInt16BE(rgba.alpha, outIndex + 2); outData.writeUInt16BE(rgba.alpha, outIndex + 2);
} }
} }
break; break;
default:
throw new Error('unrecognised color Type ' + options.colorType);
} }
inIndex += inBpp; inIndex += inBpp;

View file

@ -23,7 +23,7 @@ util.inherits(ChunkStream, Stream);
ChunkStream.prototype.read = function(length, callback) { ChunkStream.prototype.read = function(length, callback) {
this._reads.push({ this._reads.push({
length: Math.abs(length), // if length < 0 then at most this length length: Math.abs(length), // if length < 0 then at most this length
allowLess: length < 0, allowLess: length < 0,
func: callback func: callback
}); });

View file

@ -155,7 +155,9 @@ module.exports = function(pxData, width, height, options, bpp) {
throw new Error('unrecognised filter types'); throw new Error('unrecognised filter types');
} }
if (options.bitDepth === 16) bpp *= 2; if (options.bitDepth === 16) {
bpp *= 2;
}
var byteWidth = width * bpp; var byteWidth = width * bpp;
var rawPos = 0; var rawPos = 0;
var pxPos = 0; var pxPos = 0;

View file

@ -63,7 +63,8 @@ ParserAsync.prototype._inflateData = function(data) {
this._filter.on('complete', this._complete.bind(this)); this._filter.on('complete', this._complete.bind(this));
this._inflate.pipe(this._filter); this._inflate.pipe(this._filter);
} else { }
else {
var rowSize = ((this._bitmapInfo.width * this._bitmapInfo.bpp * this._bitmapInfo.depth + 7) >> 3) + 1; var rowSize = ((this._bitmapInfo.width * this._bitmapInfo.bpp * this._bitmapInfo.depth + 7) >> 3) + 1;
var imageSize = rowSize * this._bitmapInfo.height; var imageSize = rowSize * this._bitmapInfo.height;
var chunkSize = Math.max(imageSize, zlib.Z_MIN_CHUNK); var chunkSize = Math.max(imageSize, zlib.Z_MIN_CHUNK);

View file

@ -78,7 +78,8 @@ module.exports = function(buffer, options) {
var inflatedData; var inflatedData;
if (metaData.interlace) { if (metaData.interlace) {
inflatedData = zlib.inflateSync(inflateData); inflatedData = zlib.inflateSync(inflateData);
} else { }
else {
var rowSize = ((metaData.width * metaData.bpp * metaData.depth + 7) >> 3) + 1; var rowSize = ((metaData.width * metaData.bpp * metaData.depth + 7) >> 3) + 1;
var imageSize = rowSize * metaData.height; var imageSize = rowSize * metaData.height;
inflatedData = inflateSync(inflateData, { chunkSize: imageSize, maxLength: imageSize }); inflatedData = inflateSync(inflateData, { chunkSize: imageSize, maxLength: imageSize });

View file

@ -35,7 +35,7 @@ var Parser = module.exports = function(options, dependencies) {
this.inflateData = dependencies.inflateData; this.inflateData = dependencies.inflateData;
this.finished = dependencies.finished; this.finished = dependencies.finished;
this.simpleTransparency = dependencies.simpleTransparency; this.simpleTransparency = dependencies.simpleTransparency;
this.headersFinished = dependencies.headersFinished || function(){}; this.headersFinished = dependencies.headersFinished || function() {};
}; };
Parser.prototype.start = function() { Parser.prototype.start = function() {
@ -73,8 +73,8 @@ Parser.prototype._parseChunkBegin = function(data) {
// chunk flags // chunk flags
var ancillary = Boolean(data[4] & 0x20); // or critical var ancillary = Boolean(data[4] & 0x20); // or critical
// priv = Boolean(data[5] & 0x20), // or public // priv = Boolean(data[5] & 0x20), // or public
// safeToCopy = Boolean(data[7] & 0x20); // or unsafe // safeToCopy = Boolean(data[7] & 0x20); // or unsafe
if (!this._hasIHDR && type !== constants.TYPE_IHDR) { if (!this._hasIHDR && type !== constants.TYPE_IHDR) {
this.error(new Error('Expected IHDR on beggining')); this.error(new Error('Expected IHDR on beggining'));

View file

@ -108,12 +108,12 @@ Inflate.prototype._processChunk = function(chunk, flushFlag, asyncCb) {
assert(this._handle, 'zlib binding closed'); assert(this._handle, 'zlib binding closed');
do { do {
var res = this._handle.writeSync(flushFlag, var res = this._handle.writeSync(flushFlag,
chunk, // in chunk, // in
inOff, // in_off inOff, // in_off
availInBefore, // in_len availInBefore, // in_len
this._buffer, // out this._buffer, // out
this._offset, //out_off this._offset, //out_off
availOutBefore); // out_len availOutBefore); // out_len
// Node 8 --> 9 compatibility check // Node 8 --> 9 compatibility check
res = res || this._writeState; res = res || this._writeState;
} while (!this._hadError && handleChunk(res[0], res[1])); } while (!this._hadError && handleChunk(res[0], res[1]));

View file

@ -9,7 +9,7 @@ var SyncReader = module.exports = function(buffer) {
SyncReader.prototype.read = function(length, callback) { SyncReader.prototype.read = function(length, callback) {
this._reads.push({ this._reads.push({
length: Math.abs(length), // if length < 0 then at most this length length: Math.abs(length), // if length < 0 then at most this length
allowLess: length < 0, allowLess: length < 0,
func: callback func: callback
}); });

2636
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -60,7 +60,7 @@
"browserify": "^14.5.0", "browserify": "^14.5.0",
"buffer-equal": "1.0.0", "buffer-equal": "1.0.0",
"connect": "^3.4.0", "connect": "^3.4.0",
"eslint": "^3.2.2", "eslint": "^4.1.0",
"istanbul": "^0.4.4", "istanbul": "^0.4.4",
"phantomjs-prebuilt": "^2.1.7", "phantomjs-prebuilt": "^2.1.7",
"serve-static": "^1.10.0", "serve-static": "^1.10.0",