1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Enable the no-else-return ESLint rule

Using `else` after `return` is not necessary, and can often lead to unnecessarily cluttered code. By using the `no-else-return` rule in ESLint we can avoid this pattern, see http://eslint.org/docs/rules/no-else-return.
This commit is contained in:
Jonas Jenwald 2016-12-16 13:05:33 +01:00
parent 049d7fa277
commit 4046d67fde
19 changed files with 67 additions and 79 deletions

View file

@ -348,10 +348,9 @@ var CFFParser = (function CFFParserClosure() {
return ((value - 247) * 256) + dict[pos++] + 108;
} else if (value >= 251 && value <= 254) {
return -((value - 251) * 256) - dict[pos++] - 108;
} else {
warn('CFFParser_parseDict: "' + value + '" is a reserved command.');
return NaN;
}
warn('CFFParser_parseDict: "' + value + '" is a reserved command.');
return NaN;
}
function parseFloatOperand() {
@ -1363,9 +1362,8 @@ var CFFCompiler = (function CFFCompilerClosure() {
encodeNumber: function CFFCompiler_encodeNumber(value) {
if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) { // isInt
return this.encodeInteger(value);
} else {
return this.encodeFloat(value);
}
return this.encodeFloat(value);
},
encodeFloat: function CFFCompiler_encodeFloat(num) {
var value = num.toString();

View file

@ -1216,11 +1216,13 @@ var LabCS = (function LabCSClosure() {
// Function g(x) from spec
function fn_g(x) {
var result;
if (x >= 6 / 29) {
return x * x * x;
result = x * x * x;
} else {
return (108 / 841) * (x - 4 / 29);
result = (108 / 841) * (x - 4 / 29);
}
return result;
}
function decode(value, high1, low2, high2) {

View file

@ -823,9 +823,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
this.handler);
operatorList.addOp(fn, pattern.getIR());
return Promise.resolve();
} else {
return Promise.reject('Unknown PatternType: ' + typeNum);
}
return Promise.reject('Unknown PatternType: ' + typeNum);
}
// TODO shall we fail here?
operatorList.addOp(fn, args);
@ -2902,18 +2901,17 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
operation.fn = fn;
operation.args = args;
return true;
} else {
if (isEOF(obj)) {
return false; // no more commands
}
// argument
if (obj !== null) {
if (args === null) {
args = [];
}
args.push(obj);
assert(args.length <= 33, 'Too many arguments');
}
if (isEOF(obj)) {
return false; // no more commands
}
// argument
if (obj !== null) {
if (args === null) {
args = [];
}
args.push(obj);
assert(args.length <= 33, 'Too many arguments');
}
}
},

View file

@ -729,9 +729,8 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
[1 / unitsPerEm, 0, 0, 1 / unitsPerEm, 0, 0]);
return new TrueTypeCompiled(
parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
} else {
return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
}
return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
}
};
})();

View file

@ -53,9 +53,8 @@ var PDFImage = (function PDFImageClosure() {
function handleImageData(image, nativeDecoder) {
if (nativeDecoder && nativeDecoder.canDecode(image)) {
return nativeDecoder.decode(image);
} else {
return Promise.resolve(image);
}
return Promise.resolve(image);
}
/**

View file

@ -918,15 +918,15 @@ var JpegImage = (function JpegImageClosure() {
return false;
}
return true;
} else { // `this.numComponents !== 3`
if (!this.adobe && this.colorTransform === 1) {
// If the Adobe transform marker is not present and the image
// dictionary has a 'ColorTransform' entry, explicitly set to `1`,
// then the colours should be transformed.
return true;
}
return false;
}
// `this.numComponents !== 3`
if (!this.adobe && this.colorTransform === 1) {
// If the Adobe transform marker is not present and the image
// dictionary has a 'ColorTransform' entry, explicitly set to `1`,
// then the colours should be transformed.
return true;
}
return false;
},
_convertYccToRgb: function convertYccToRgb(data) {
@ -1072,9 +1072,8 @@ var JpegImage = (function JpegImageClosure() {
if (this._isColorConversionNeeded()) {
if (forceRGBoutput) {
return this._convertYcckToRgb(data);
} else {
return this._convertYcckToCmyk(data);
}
return this._convertYcckToCmyk(data);
} else if (forceRGBoutput) {
return this._convertCmykToRgb(data);
}

View file

@ -1585,9 +1585,8 @@ var FileSpec = (function FileSpecClosure() {
return dict.get('Mac');
} else if (dict.has('DOS')) {
return dict.get('DOS');
} else {
return null;
}
return null;
}
FileSpec.prototype = {

View file

@ -81,9 +81,8 @@ AnnotationElementFactory.prototype =
return new RadioButtonWidgetAnnotationElement(parameters);
} else if (parameters.data.checkBox) {
return new CheckboxWidgetAnnotationElement(parameters);
} else {
warn('Unimplemented button widget annotation: pushbutton');
}
warn('Unimplemented button widget annotation: pushbutton');
break;
case 'Ch':
return new ChoiceWidgetAnnotationElement(parameters);

View file

@ -1945,9 +1945,8 @@ var PDFObjects = (function PDFObjectsClosure() {
if (!objs[objId]) {
return false;
} else {
return objs[objId].resolved;
}
return objs[objId].resolved;
},
hasData: function PDFObjects_hasData(objId) {
@ -1961,9 +1960,8 @@ var PDFObjects = (function PDFObjectsClosure() {
var objs = this.objs;
if (!objs[objId] || !objs[objId].resolved) {
return null;
} else {
return objs[objId].data;
}
return objs[objId].data;
},
clear: function PDFObjects_clear() {

View file

@ -376,7 +376,7 @@ var FontFaceObject = (function FontFaceObjectClosure() {
this.options.fontRegistry.registerFont(this);
}
return nativeFontFace;
} else {
} else { // eslint-disable-line no-else-return
throw new Error('Not implemented: createNativeFontFace');
}
},