Merge pull request #15282 from Snuffleupagus/prefer-spread

Enable the ESLint `prefer-spread` rule
This commit is contained in:
Tim van der Meij 2022-08-06 14:12:25 +02:00 committed by GitHub
commit 70bcaf63ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 37 additions and 34 deletions

View File

@ -139,6 +139,7 @@
"no-useless-escape": "error", "no-useless-escape": "error",
"no-useless-return": "error", "no-useless-return": "error",
"prefer-promise-reject-errors": "error", "prefer-promise-reject-errors": "error",
"prefer-spread": "error",
"wrap-iife": ["error", "any"], "wrap-iife": ["error", "any"],
"yoda": ["error", "never", { "yoda": ["error", "never", {
"exceptRange": true, "exceptRange": true,

View File

@ -3717,7 +3717,7 @@ class PartialEvaluator {
const w2 = (token.charCodeAt(k) << 8) | token.charCodeAt(k + 1); const w2 = (token.charCodeAt(k) << 8) | token.charCodeAt(k + 1);
str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000); str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
} }
map[charCode] = String.fromCodePoint.apply(String, str); map[charCode] = String.fromCodePoint(...str);
}); });
return new ToUnicodeMap(map); return new ToUnicodeMap(map);
}, },

View File

@ -1478,6 +1478,7 @@ function processSegment(segment, visitor) {
} }
const callbackName = "on" + header.typeName; const callbackName = "on" + header.typeName;
if (callbackName in visitor) { if (callbackName in visitor) {
// eslint-disable-next-line prefer-spread
visitor[callbackName].apply(visitor, args); visitor[callbackName].apply(visitor, args);
} }
} }
@ -1636,7 +1637,7 @@ class SimpleSegmentVisitor {
} }
onImmediateLosslessGenericRegion() { onImmediateLosslessGenericRegion() {
this.onImmediateGenericRegion.apply(this, arguments); this.onImmediateGenericRegion(...arguments);
} }
onSymbolDictionary( onSymbolDictionary(
@ -1743,7 +1744,7 @@ class SimpleSegmentVisitor {
} }
onImmediateLosslessTextRegion() { onImmediateLosslessTextRegion() {
this.onImmediateTextRegion.apply(this, arguments); this.onImmediateTextRegion(...arguments);
} }
onPatternDictionary(dictionary, currentSegment, data, start, end) { onPatternDictionary(dictionary, currentSegment, data, start, end) {
@ -1788,7 +1789,7 @@ class SimpleSegmentVisitor {
} }
onImmediateLosslessHalftoneRegion() { onImmediateLosslessHalftoneRegion() {
this.onImmediateHalftoneRegion.apply(this, arguments); this.onImmediateHalftoneRegion(...arguments);
} }
onTables(currentSegment, data, start, end) { onTables(currentSegment, data, start, end) {

View File

@ -351,7 +351,7 @@ const Type1CharString = (function Type1CharStringClosure() {
); );
} }
} }
this.output.push.apply(this.output, command); this.output.push(...command);
if (keepStack) { if (keepStack) {
this.stack.splice(start, howManyArgs); this.stack.splice(start, howManyArgs);
} else { } else {

View File

@ -1359,17 +1359,17 @@ class CanvasGraphics {
this.ctx.save(); this.ctx.save();
// The transform can be applied before rendering, transferring it to // The transform can be applied before rendering, transferring it to
// the new canvas. // the new canvas.
this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform); this.ctx.transform(...this.compositeCtx.mozCurrentTransform);
} }
this.ctx.save(); this.ctx.save();
resetCtxToDefault(this.ctx, this.foregroundColor); resetCtxToDefault(this.ctx, this.foregroundColor);
if (transform) { if (transform) {
this.ctx.transform.apply(this.ctx, transform); this.ctx.transform(...transform);
this.outputScaleX = transform[0]; this.outputScaleX = transform[0];
this.outputScaleY = transform[0]; this.outputScaleY = transform[0];
} }
this.ctx.transform.apply(this.ctx, viewport.transform); this.ctx.transform(...viewport.transform);
this.viewportScale = viewport.scale; this.viewportScale = viewport.scale;
this.baseTransform = this.ctx.mozCurrentTransform.slice(); this.baseTransform = this.ctx.mozCurrentTransform.slice();
@ -1414,6 +1414,7 @@ class CanvasGraphics {
fnId = fnArray[i]; fnId = fnArray[i];
if (fnId !== OPS.dependency) { if (fnId !== OPS.dependency) {
// eslint-disable-next-line prefer-spread
this[fnId].apply(this, argsArray[i]); this[fnId].apply(this, argsArray[i]);
} else { } else {
for (const depObjId of argsArray[i]) { for (const depObjId of argsArray[i]) {
@ -1645,7 +1646,7 @@ class CanvasGraphics {
const offsetX = Math.min(cord1[0], cord2[0]); const offsetX = Math.min(cord1[0], cord2[0]);
const offsetY = Math.min(cord1[1], cord2[1]); const offsetY = Math.min(cord1[1], cord2[1]);
fillCtx.translate(-offsetX, -offsetY); fillCtx.translate(-offsetX, -offsetY);
fillCtx.transform.apply(fillCtx, maskToCanvas); fillCtx.transform(...maskToCanvas);
if (!scaled) { if (!scaled) {
// Pre-scale if needed to improve image smoothing. // Pre-scale if needed to improve image smoothing.
@ -1835,7 +1836,7 @@ class CanvasGraphics {
this.suspendedCtx = this.ctx; this.suspendedCtx = this.ctx;
this.ctx = scratchCanvas.context; this.ctx = scratchCanvas.context;
const ctx = this.ctx; const ctx = this.ctx;
ctx.setTransform.apply(ctx, this.suspendedCtx.mozCurrentTransform); ctx.setTransform(...this.suspendedCtx.mozCurrentTransform);
copyCtxState(this.suspendedCtx, ctx); copyCtxState(this.suspendedCtx, ctx);
mirrorContextOperations(ctx, this.suspendedCtx); mirrorContextOperations(ctx, this.suspendedCtx);
@ -2212,7 +2213,7 @@ class CanvasGraphics {
ctx.save(); ctx.save();
ctx.beginPath(); ctx.beginPath();
for (const path of paths) { for (const path of paths) {
ctx.setTransform.apply(ctx, path.transform); ctx.setTransform(...path.transform);
ctx.translate(path.x, path.y); ctx.translate(path.x, path.y);
path.addToPath(ctx, path.fontSize); path.addToPath(ctx, path.fontSize);
} }
@ -2349,7 +2350,7 @@ class CanvasGraphics {
ctx.beginPath(); ctx.beginPath();
addToPath(ctx, fontSize); addToPath(ctx, fontSize);
if (patternTransform) { if (patternTransform) {
ctx.setTransform.apply(ctx, patternTransform); ctx.setTransform(...patternTransform);
} }
if ( if (
fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL ||
@ -2443,7 +2444,7 @@ class CanvasGraphics {
!current.patternFill; !current.patternFill;
ctx.save(); ctx.save();
ctx.transform.apply(ctx, current.textMatrix); ctx.transform(...current.textMatrix);
ctx.translate(current.x, current.y + current.textRise); ctx.translate(current.x, current.y + current.textRise);
if (fontDirection > 0) { if (fontDirection > 0) {
@ -2606,7 +2607,7 @@ class CanvasGraphics {
this._cachedGetSinglePixelWidth = null; this._cachedGetSinglePixelWidth = null;
ctx.save(); ctx.save();
ctx.transform.apply(ctx, current.textMatrix); ctx.transform(...current.textMatrix);
ctx.translate(current.x, current.y); ctx.translate(current.x, current.y);
ctx.scale(textHScale, fontDirection); ctx.scale(textHScale, fontDirection);
@ -2630,7 +2631,7 @@ class CanvasGraphics {
this.processingType3 = glyph; this.processingType3 = glyph;
this.save(); this.save();
ctx.scale(fontSize, fontSize); ctx.scale(fontSize, fontSize);
ctx.transform.apply(ctx, fontMatrix); ctx.transform(...fontMatrix);
this.executeOperatorList(operatorList); this.executeOperatorList(operatorList);
this.restore(); this.restore();
} }
@ -2786,7 +2787,7 @@ class CanvasGraphics {
this.baseTransformStack.push(this.baseTransform); this.baseTransformStack.push(this.baseTransform);
if (Array.isArray(matrix) && matrix.length === 6) { if (Array.isArray(matrix) && matrix.length === 6) {
this.transform.apply(this, matrix); this.transform(...matrix);
} }
this.baseTransform = this.ctx.mozCurrentTransform; this.baseTransform = this.ctx.mozCurrentTransform;
@ -2848,7 +2849,7 @@ class CanvasGraphics {
const currentTransform = currentCtx.mozCurrentTransform; const currentTransform = currentCtx.mozCurrentTransform;
if (group.matrix) { if (group.matrix) {
currentCtx.transform.apply(currentCtx, group.matrix); currentCtx.transform(...group.matrix);
} }
if (!group.bbox) { if (!group.bbox) {
throw new Error("Bounding box is required."); throw new Error("Bounding box is required.");
@ -2904,7 +2905,7 @@ class CanvasGraphics {
// we have to translate the group ctx. // we have to translate the group ctx.
groupCtx.scale(1 / scaleX, 1 / scaleY); groupCtx.scale(1 / scaleX, 1 / scaleY);
groupCtx.translate(-offsetX, -offsetY); groupCtx.translate(-offsetX, -offsetY);
groupCtx.transform.apply(groupCtx, currentTransform); groupCtx.transform(...currentTransform);
if (group.smask) { if (group.smask) {
// Saving state and cached mask to be used in setGState. // Saving state and cached mask to be used in setGState.
@ -2961,7 +2962,7 @@ class CanvasGraphics {
const currentMtx = this.ctx.mozCurrentTransform; const currentMtx = this.ctx.mozCurrentTransform;
this.restore(); this.restore();
this.ctx.save(); this.ctx.save();
this.ctx.setTransform.apply(this.ctx, currentMtx); this.ctx.setTransform(...currentMtx);
const dirtyBox = Util.getAxialAlignedBoundingBox( const dirtyBox = Util.getAxialAlignedBoundingBox(
[0, 0, groupCtx.canvas.width, groupCtx.canvas.height], [0, 0, groupCtx.canvas.width, groupCtx.canvas.height],
currentMtx currentMtx
@ -2984,7 +2985,7 @@ class CanvasGraphics {
this.save(); this.save();
if (this.baseTransform) { if (this.baseTransform) {
this.ctx.setTransform.apply(this.ctx, this.baseTransform); this.ctx.setTransform(...this.baseTransform);
} }
if (Array.isArray(rect) && rect.length === 4) { if (Array.isArray(rect) && rect.length === 4) {
@ -3038,8 +3039,8 @@ class CanvasGraphics {
this.ctx.canvas.height this.ctx.canvas.height
); );
this.transform.apply(this, transform); this.transform(...transform);
this.transform.apply(this, matrix); this.transform(...matrix);
} }
endAnnotation() { endAnnotation() {
@ -3160,7 +3161,7 @@ class CanvasGraphics {
maskCtx.restore(); maskCtx.restore();
ctx.save(); ctx.save();
ctx.transform.apply(ctx, transform); ctx.transform(...transform);
ctx.scale(1, -1); ctx.scale(1, -1);
drawImageAtIntegerCoords( drawImageAtIntegerCoords(
ctx, ctx,
@ -3298,10 +3299,9 @@ class CanvasGraphics {
const tmpCtx = tmpCanvas.context; const tmpCtx = tmpCanvas.context;
putBinaryImageData(tmpCtx, imgData, this.current.transferMaps); putBinaryImageData(tmpCtx, imgData, this.current.transferMaps);
for (let i = 0, ii = map.length; i < ii; i++) { for (const entry of map) {
const entry = map[i];
ctx.save(); ctx.save();
ctx.transform.apply(ctx, entry.transform); ctx.transform(...entry.transform);
ctx.scale(1, -1); ctx.scale(1, -1);
drawImageAtIntegerCoords( drawImageAtIntegerCoords(
ctx, ctx,

View File

@ -475,6 +475,7 @@ class FontFaceObject {
if (current.cmd === "scale") { if (current.cmd === "scale") {
current.args = [size, -size]; current.args = [size, -size];
} }
// eslint-disable-next-line prefer-spread
c[current.cmd].apply(c, current.args); c[current.cmd].apply(c, current.args);
} }
}); });

View File

@ -128,9 +128,9 @@ class RadialAxialShadingPattern extends BaseShadingPattern {
ownerBBox[1], ownerBBox[1],
]); ]);
tmpCtx.transform.apply(tmpCtx, owner.baseTransform); tmpCtx.transform(...owner.baseTransform);
if (this.matrix) { if (this.matrix) {
tmpCtx.transform.apply(tmpCtx, this.matrix); tmpCtx.transform(...this.matrix);
} }
applyBoundingBox(tmpCtx, this._bbox); applyBoundingBox(tmpCtx, this._bbox);
@ -428,9 +428,9 @@ class MeshShadingPattern extends BaseShadingPattern {
); );
if (pathType !== PathType.SHADING) { if (pathType !== PathType.SHADING) {
ctx.setTransform.apply(ctx, owner.baseTransform); ctx.setTransform(...owner.baseTransform);
if (this.matrix) { if (this.matrix) {
ctx.transform.apply(ctx, this.matrix); ctx.transform(...this.matrix);
} }
} }

View File

@ -104,10 +104,10 @@ async function initializePDFJS(callback) {
return document.body; return document.body;
}, },
createElement() { createElement() {
return document.createElement.apply(document, arguments); return document.createElement(...arguments);
}, },
createTextNode() { createTextNode() {
return document.createTextNode.apply(document, arguments); return document.createTextNode(...arguments);
}, },
timer: new jasmine.Timer(), timer: new jasmine.Timer(),
}); });

View File

@ -167,10 +167,10 @@ async function initializePDFJS(callback) {
return document.body; return document.body;
}, },
createElement() { createElement() {
return document.createElement.apply(document, arguments); return document.createElement(...arguments);
}, },
createTextNode() { createTextNode() {
return document.createTextNode.apply(document, arguments); return document.createTextNode(...arguments);
}, },
timer: new jasmine.Timer(), timer: new jasmine.Timer(),
}); });