From dcb16af968598d789b078cd33525d1c503401253 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 25 Mar 2020 10:15:50 +0100 Subject: [PATCH] Whitelist closure related cases to address the remaining `no-shadow` linting errors Given the way that "classes" were previously implemented in PDF.js, using regular functions and closures, there's a fair number of false positives when the `no-shadow` ESLint rule was enabled. Note that while *some* of these `eslint-disable` statements can be removed if/when the relevant code is converted to proper `class`es, we'll probably never be able to get rid of all of them given our naming/coding conventions (however I don't really see this being a problem). --- src/core/ccitt.js | 1 + src/core/ccitt_stream.js | 1 + src/core/cff_parser.js | 15 +++++++++++++++ src/core/cmap.js | 1 + src/core/colorspace.js | 4 ++++ src/core/crypto.js | 7 +++++++ src/core/evaluator.js | 6 ++++++ src/core/fonts.js | 8 ++++++++ src/core/function.js | 4 ++++ src/core/image.js | 1 + src/core/jbig2.js | 1 + src/core/jbig2_stream.js | 1 + src/core/jpeg_stream.js | 1 + src/core/jpg.js | 1 + src/core/jpx.js | 8 ++++++++ src/core/jpx_stream.js | 1 + src/core/obj.js | 3 +++ src/core/operator_list.js | 3 +++ src/core/pattern.js | 3 +++ src/core/primitives.js | 6 ++++++ src/core/ps_parser.js | 1 + src/core/stream.js | 12 ++++++++++++ src/core/type1_parser.js | 2 ++ src/core/worker.js | 1 + src/display/api.js | 3 +++ src/display/canvas.js | 3 +++ src/display/pattern_helper.js | 2 ++ src/display/svg.js | 2 ++ src/display/text_layer.js | 1 + src/shared/util.js | 2 ++ test/driver.js | 3 +++ web/debugger.js | 1 + 32 files changed, 109 insertions(+) diff --git a/src/core/ccitt.js b/src/core/ccitt.js index 7ac491089..05e427558 100644 --- a/src/core/ccitt.js +++ b/src/core/ccitt.js @@ -465,6 +465,7 @@ const CCITTFaxDecoder = (function CCITTFaxDecoder() { * @param {CCITTFaxDecoderSource} source - The data which should be decoded. * @param {Object} [options] - Decoding options. */ + // eslint-disable-next-line no-shadow function CCITTFaxDecoder(source, options = {}) { if (!source || typeof source.next !== "function") { throw new Error('CCITTFaxDecoder - invalid "source" parameter.'); diff --git a/src/core/ccitt_stream.js b/src/core/ccitt_stream.js index a82102502..4140a30fd 100644 --- a/src/core/ccitt_stream.js +++ b/src/core/ccitt_stream.js @@ -18,6 +18,7 @@ import { CCITTFaxDecoder } from "./ccitt.js"; import { DecodeStream } from "./stream.js"; var CCITTFaxStream = (function CCITTFaxStreamClosure() { + // eslint-disable-next-line no-shadow function CCITTFaxStream(str, maybeLength, params) { this.str = str; this.dict = str.dict; diff --git a/src/core/cff_parser.js b/src/core/cff_parser.js index fd8299fdf..cf1f1c4bb 100644 --- a/src/core/cff_parser.js +++ b/src/core/cff_parser.js @@ -217,6 +217,7 @@ var CFFParser = (function CFFParserClosure() { { id: "flex1", min: 11, resetStack: true }, ]; + // eslint-disable-next-line no-shadow function CFFParser(file, properties, seacAnalysisEnabled) { this.bytes = file.getBytes(); this.properties = properties; @@ -964,6 +965,7 @@ var CFFParser = (function CFFParserClosure() { // Compact Font Format var CFF = (function CFFClosure() { + // eslint-disable-next-line no-shadow function CFF() { this.header = null; this.names = []; @@ -1009,6 +1011,7 @@ var CFF = (function CFFClosure() { })(); var CFFHeader = (function CFFHeaderClosure() { + // eslint-disable-next-line no-shadow function CFFHeader(major, minor, hdrSize, offSize) { this.major = major; this.minor = minor; @@ -1019,6 +1022,7 @@ var CFFHeader = (function CFFHeaderClosure() { })(); var CFFStrings = (function CFFStringsClosure() { + // eslint-disable-next-line no-shadow function CFFStrings() { this.strings = []; } @@ -1054,6 +1058,7 @@ var CFFStrings = (function CFFStringsClosure() { })(); var CFFIndex = (function CFFIndexClosure() { + // eslint-disable-next-line no-shadow function CFFIndex() { this.objects = []; this.length = 0; @@ -1078,6 +1083,7 @@ var CFFIndex = (function CFFIndexClosure() { })(); var CFFDict = (function CFFDictClosure() { + // eslint-disable-next-line no-shadow function CFFDict(tables, strings) { this.keyToNameMap = tables.keyToNameMap; this.nameToKeyMap = tables.nameToKeyMap; @@ -1205,6 +1211,8 @@ var CFFTopDict = (function CFFTopDictClosure() { [[12, 38], "FontName", "sid", null], ]; var tables = null; + + // eslint-disable-next-line no-shadow function CFFTopDict(strings) { if (tables === null) { tables = CFFDict.createTables(layout); @@ -1238,6 +1246,8 @@ var CFFPrivateDict = (function CFFPrivateDictClosure() { [19, "Subrs", "offset", null], ]; var tables = null; + + // eslint-disable-next-line no-shadow function CFFPrivateDict(strings) { if (tables === null) { tables = CFFDict.createTables(layout); @@ -1255,6 +1265,7 @@ var CFFCharsetPredefinedTypes = { EXPERT_SUBSET: 2, }; var CFFCharset = (function CFFCharsetClosure() { + // eslint-disable-next-line no-shadow function CFFCharset(predefined, format, charset, raw) { this.predefined = predefined; this.format = format; @@ -1265,6 +1276,7 @@ var CFFCharset = (function CFFCharsetClosure() { })(); var CFFEncoding = (function CFFEncodingClosure() { + // eslint-disable-next-line no-shadow function CFFEncoding(predefined, format, encoding, raw) { this.predefined = predefined; this.format = format; @@ -1275,6 +1287,7 @@ var CFFEncoding = (function CFFEncodingClosure() { })(); var CFFFDSelect = (function CFFFDSelectClosure() { + // eslint-disable-next-line no-shadow function CFFFDSelect(format, fdSelect) { this.format = format; this.fdSelect = fdSelect; @@ -1293,6 +1306,7 @@ var CFFFDSelect = (function CFFFDSelectClosure() { // Helper class to keep track of where an offset is within the data and helps // filling in that offset once it's known. var CFFOffsetTracker = (function CFFOffsetTrackerClosure() { + // eslint-disable-next-line no-shadow function CFFOffsetTracker() { this.offsets = Object.create(null); } @@ -1352,6 +1366,7 @@ var CFFOffsetTracker = (function CFFOffsetTrackerClosure() { // Takes a CFF and converts it to the binary representation. var CFFCompiler = (function CFFCompilerClosure() { + // eslint-disable-next-line no-shadow function CFFCompiler(cff) { this.cff = cff; } diff --git a/src/core/cmap.js b/src/core/cmap.js index b43906537..6a663fcc4 100644 --- a/src/core/cmap.js +++ b/src/core/cmap.js @@ -713,6 +713,7 @@ var BinaryCMapReader = (function BinaryCMapReaderClosure() { }); } + // eslint-disable-next-line no-shadow function BinaryCMapReader() {} BinaryCMapReader.prototype = { diff --git a/src/core/colorspace.js b/src/core/colorspace.js index 317731be2..b4f326d57 100644 --- a/src/core/colorspace.js +++ b/src/core/colorspace.js @@ -836,6 +836,7 @@ const DeviceCmykCS = (function DeviceCmykCSClosure() { k * (-22.33816807309886 * k - 180.12613974708367); } + // eslint-disable-next-line no-shadow class DeviceCmykCS extends ColorSpace { constructor() { super("DeviceCMYK", 4); @@ -902,6 +903,7 @@ const CalGrayCS = (function CalGrayCSClosure() { dest[destOffset + 2] = val; } + // eslint-disable-next-line no-shadow class CalGrayCS extends ColorSpace { constructor(whitePoint, blackPoint, gamma) { super("CalGray", 1); @@ -1190,6 +1192,7 @@ const CalRGBCS = (function CalRGBCSClosure() { dest[destOffset + 2] = sRGBTransferFunction(SRGB[2]) * 255; } + // eslint-disable-next-line no-shadow class CalRGBCS extends ColorSpace { constructor(whitePoint, blackPoint, gamma, matrix) { super("CalRGB", 3); @@ -1371,6 +1374,7 @@ const LabCS = (function LabCSClosure() { dest[destOffset + 2] = Math.sqrt(b) * 255; } + // eslint-disable-next-line no-shadow class LabCS extends ColorSpace { constructor(whitePoint, blackPoint, range) { super("Lab", 3); diff --git a/src/core/crypto.js b/src/core/crypto.js index e1af838ab..12d2d2e92 100644 --- a/src/core/crypto.js +++ b/src/core/crypto.js @@ -27,6 +27,7 @@ import { isDict, isName, Name } from "./primitives.js"; import { DecryptStream } from "./stream.js"; var ARCFourCipher = (function ARCFourCipherClosure() { + // eslint-disable-next-line no-shadow function ARCFourCipher(key) { this.a = 0; this.b = 0; @@ -177,6 +178,7 @@ var calculateMD5 = (function calculateMD5Closure() { return hash; })(); var Word64 = (function Word64Closure() { + // eslint-disable-next-line no-shadow function Word64(highInteger, lowInteger) { this.high = highInteger | 0; this.low = lowInteger | 0; @@ -690,6 +692,7 @@ var calculateSHA384 = (function calculateSHA384Closure() { return hash; })(); var NullCipher = (function NullCipherClosure() { + // eslint-disable-next-line no-shadow function NullCipher() {} NullCipher.prototype = { @@ -1265,6 +1268,7 @@ var PDF17 = (function PDF17Closure() { return true; } + // eslint-disable-next-line no-shadow function PDF17() {} PDF17.prototype = { @@ -1372,6 +1376,7 @@ var PDF20 = (function PDF20Closure() { return k.subarray(0, 32); } + // eslint-disable-next-line no-shadow function PDF20() {} function compareByteArrays(array1, array2) { @@ -1446,6 +1451,7 @@ var PDF20 = (function PDF20Closure() { })(); var CipherTransform = (function CipherTransformClosure() { + // eslint-disable-next-line no-shadow function CipherTransform(stringCipherConstructor, streamCipherConstructor) { this.StringCipherConstructor = stringCipherConstructor; this.StreamCipherConstructor = streamCipherConstructor; @@ -1661,6 +1667,7 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() { var identityName = Name.get("Identity"); + // eslint-disable-next-line no-shadow function CipherTransformFactory(dict, fileId, password) { var filter = dict.get("Filter"); if (!isName(filter, "Standard")) { diff --git a/src/core/evaluator.js b/src/core/evaluator.js index 7b4cd114a..b06e8b0a1 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -96,6 +96,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { isEvalSupported: true, }; + // eslint-disable-next-line no-shadow function PartialEvaluator({ xref, handler, @@ -3266,6 +3267,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { })(); var TranslatedFont = (function TranslatedFontClosure() { + // eslint-disable-next-line no-shadow function TranslatedFont(loadedName, font, dict) { this.loadedName = loadedName; this.font = font; @@ -3367,6 +3369,7 @@ var TranslatedFont = (function TranslatedFontClosure() { })(); var StateManager = (function StateManagerClosure() { + // eslint-disable-next-line no-shadow function StateManager(initialState) { this.state = initialState; this.stateStack = []; @@ -3391,6 +3394,7 @@ var StateManager = (function StateManagerClosure() { })(); var TextState = (function TextStateClosure() { + // eslint-disable-next-line no-shadow function TextState() { this.ctm = new Float32Array(IDENTITY_MATRIX); this.fontName = null; @@ -3496,6 +3500,7 @@ var TextState = (function TextStateClosure() { })(); var EvalState = (function EvalStateClosure() { + // eslint-disable-next-line no-shadow function EvalState() { this.ctm = new Float32Array(IDENTITY_MATRIX); this.font = null; @@ -3637,6 +3642,7 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() { const MAX_INVALID_PATH_OPS = 20; + // eslint-disable-next-line no-shadow function EvaluatorPreprocessor(stream, xref, stateManager) { this.opMap = getOPMap(); // TODO(mduan): pass array of knownCommands rather than this.opMap diff --git a/src/core/fonts.js b/src/core/fonts.js index e69ff3970..f8fe21b3d 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -222,6 +222,7 @@ function recoverGlyphName(name, glyphsUnicodeMap) { } var Glyph = (function GlyphClosure() { + // eslint-disable-next-line no-shadow function Glyph( fontChar, unicode, @@ -268,6 +269,7 @@ var Glyph = (function GlyphClosure() { })(); var ToUnicodeMap = (function ToUnicodeMapClosure() { + // eslint-disable-next-line no-shadow function ToUnicodeMap(cmap = []) { // The elements of this._map can be integers or strings, depending on how // `cmap` was created. @@ -319,6 +321,7 @@ var ToUnicodeMap = (function ToUnicodeMapClosure() { })(); var IdentityToUnicodeMap = (function IdentityToUnicodeMapClosure() { + // eslint-disable-next-line no-shadow function IdentityToUnicodeMap(firstChar, lastChar) { this.firstChar = firstChar; this.lastChar = lastChar; @@ -389,6 +392,7 @@ var OpenTypeFileBuilder = (function OpenTypeFileBuilderClosure() { } } + // eslint-disable-next-line no-shadow function OpenTypeFileBuilder(sfnt) { this.sfnt = sfnt; this.tables = Object.create(null); @@ -512,6 +516,7 @@ var OpenTypeFileBuilder = (function OpenTypeFileBuilderClosure() { * type1Font.bind(); */ var Font = (function FontClosure() { + // eslint-disable-next-line no-shadow function Font(name, file, properties) { var charCode; @@ -3305,6 +3310,7 @@ var Font = (function FontClosure() { })(); var ErrorFont = (function ErrorFontClosure() { + // eslint-disable-next-line no-shadow function ErrorFont(error) { this.error = error; this.loadedName = "g_font_error"; @@ -3518,6 +3524,7 @@ var Type1Font = (function Type1FontClosure() { }; } + // eslint-disable-next-line no-shadow function Type1Font(name, file, properties) { // Some bad generators embed pfb file as is, we have to strip 6-byte header. // Also, length1 and length2 might be off by 6 bytes as well. @@ -3784,6 +3791,7 @@ var Type1Font = (function Type1FontClosure() { })(); var CFFFont = (function CFFFontClosure() { + // eslint-disable-next-line no-shadow function CFFFont(file, properties) { this.properties = properties; diff --git a/src/core/function.js b/src/core/function.js index c919d3e31..a54395524 100644 --- a/src/core/function.js +++ b/src/core/function.js @@ -565,6 +565,8 @@ function isPDFFunction(v) { var PostScriptStack = (function PostScriptStackClosure() { var MAX_STACK_SIZE = 100; + + // eslint-disable-next-line no-shadow function PostScriptStack(initialStack) { this.stack = !initialStack ? [] @@ -625,6 +627,7 @@ var PostScriptStack = (function PostScriptStackClosure() { return PostScriptStack; })(); var PostScriptEvaluator = (function PostScriptEvaluatorClosure() { + // eslint-disable-next-line no-shadow function PostScriptEvaluator(operators) { this.operators = operators; } @@ -1084,6 +1087,7 @@ var PostScriptCompiler = (function PostScriptCompilerClosure() { return new AstMin(num1, max); } + // eslint-disable-next-line no-shadow function PostScriptCompiler() {} PostScriptCompiler.prototype = { compile: function PostScriptCompiler_compile(code, domain, range) { diff --git a/src/core/image.js b/src/core/image.js index d8e3398f4..6e87e7bf0 100644 --- a/src/core/image.js +++ b/src/core/image.js @@ -96,6 +96,7 @@ var PDFImage = (function PDFImageClosure() { return dest; } + // eslint-disable-next-line no-shadow function PDFImage({ xref, res, diff --git a/src/core/jbig2.js b/src/core/jbig2.js index b5b8f6179..aeaed334d 100644 --- a/src/core/jbig2.js +++ b/src/core/jbig2.js @@ -2567,6 +2567,7 @@ var Jbig2Image = (function Jbig2ImageClosure() { return bitmap; } + // eslint-disable-next-line no-shadow function Jbig2Image() {} Jbig2Image.prototype = { diff --git a/src/core/jbig2_stream.js b/src/core/jbig2_stream.js index a53ced2ec..ac0490bc3 100644 --- a/src/core/jbig2_stream.js +++ b/src/core/jbig2_stream.js @@ -23,6 +23,7 @@ import { shadow } from "../shared/util.js"; * the stream behaves like all the other DecodeStreams. */ const Jbig2Stream = (function Jbig2StreamClosure() { + // eslint-disable-next-line no-shadow function Jbig2Stream(stream, maybeLength, dict, params) { this.stream = stream; this.maybeLength = maybeLength; diff --git a/src/core/jpeg_stream.js b/src/core/jpeg_stream.js index c4cb56920..66638ea13 100644 --- a/src/core/jpeg_stream.js +++ b/src/core/jpeg_stream.js @@ -26,6 +26,7 @@ import { JpegImage } from "./jpg.js"; * DecodeStreams. */ const JpegStream = (function JpegStreamClosure() { + // eslint-disable-next-line no-shadow function JpegStream(stream, maybeLength, dict, params) { // Some images may contain 'junk' before the SOI (start-of-image) marker. // Note: this seems to mainly affect inline images. diff --git a/src/core/jpg.js b/src/core/jpg.js index 7214abe96..3433dadce 100644 --- a/src/core/jpg.js +++ b/src/core/jpg.js @@ -73,6 +73,7 @@ var JpegImage = (function JpegImageClosure() { var dctSqrt2 = 5793; // sqrt(2) var dctSqrt1d2 = 2896; // sqrt(2) / 2 + // eslint-disable-next-line no-shadow function JpegImage({ decodeTransform = null, colorTransform = -1 } = {}) { this._decodeTransform = decodeTransform; this._colorTransform = colorTransform; diff --git a/src/core/jpx.js b/src/core/jpx.js index a8206360c..c7a3a6ec0 100644 --- a/src/core/jpx.js +++ b/src/core/jpx.js @@ -31,6 +31,8 @@ var JpxImage = (function JpxImageClosure() { HL: 1, HH: 2, }; + + // eslint-disable-next-line no-shadow function JpxImage() { this.failOnCorruptedImage = false; } @@ -1585,6 +1587,7 @@ var JpxImage = (function JpxImageClosure() { // Section B.10.2 Tag trees var TagTree = (function TagTreeClosure() { + // eslint-disable-next-line no-shadow function TagTree(width, height) { var levelsLength = log2(Math.max(width, height)) + 1; this.levels = []; @@ -1646,6 +1649,7 @@ var JpxImage = (function JpxImageClosure() { })(); var InclusionTree = (function InclusionTreeClosure() { + // eslint-disable-next-line no-shadow function InclusionTree(width, height, defaultValue) { var levelsLength = log2(Math.max(width, height)) + 1; this.levels = []; @@ -1752,6 +1756,7 @@ var JpxImage = (function JpxImageClosure() { 8, 0, 8, 8, 8, 0, 8, 8, 8, 0, 0, 0, 0, 0, 8, 8, 8, 0, 8, 8, 8, 0, 8, 8, 8 ]); + // eslint-disable-next-line no-shadow function BitModel(width, height, subband, zeroBitPlanes, mb) { this.width = width; this.height = height; @@ -2107,6 +2112,7 @@ var JpxImage = (function JpxImageClosure() { // Section F, Discrete wavelet transformation var Transform = (function TransformClosure() { + // eslint-disable-next-line no-shadow function Transform() {} Transform.prototype.calculate = function transformCalculate( @@ -2248,6 +2254,7 @@ var JpxImage = (function JpxImageClosure() { // Section 3.8.2 Irreversible 9-7 filter var IrreversibleTransform = (function IrreversibleTransformClosure() { + // eslint-disable-next-line no-shadow function IrreversibleTransform() { Transform.call(this); } @@ -2345,6 +2352,7 @@ var JpxImage = (function JpxImageClosure() { // Section 3.8.1 Reversible 5-3 filter var ReversibleTransform = (function ReversibleTransformClosure() { + // eslint-disable-next-line no-shadow function ReversibleTransform() { Transform.call(this); } diff --git a/src/core/jpx_stream.js b/src/core/jpx_stream.js index 04ec03ac8..0c2c04fc2 100644 --- a/src/core/jpx_stream.js +++ b/src/core/jpx_stream.js @@ -22,6 +22,7 @@ import { shadow } from "../shared/util.js"; * the stream behaves like all the other DecodeStreams. */ const JpxStream = (function JpxStreamClosure() { + // eslint-disable-next-line no-shadow function JpxStream(stream, maybeLength, dict, params) { this.stream = stream; this.maybeLength = maybeLength; diff --git a/src/core/obj.js b/src/core/obj.js index b5ceccd61..f8a820b62 100644 --- a/src/core/obj.js +++ b/src/core/obj.js @@ -1116,6 +1116,7 @@ class Catalog { } var XRef = (function XRefClosure() { + // eslint-disable-next-line no-shadow function XRef(stream, pdfManager) { this.stream = stream; this.pdfManager = pdfManager; @@ -2089,6 +2090,7 @@ class NumberTree extends NameOrNumberTree { * collections attributes and related files (/RF) */ var FileSpec = (function FileSpecClosure() { + // eslint-disable-next-line no-shadow function FileSpec(root, xref) { if (!root || !isDict(root)) { return; @@ -2214,6 +2216,7 @@ const ObjectLoader = (function() { } } + // eslint-disable-next-line no-shadow function ObjectLoader(dict, keys, xref) { this.dict = dict; this.keys = keys; diff --git a/src/core/operator_list.js b/src/core/operator_list.js index eef990f09..385e35190 100644 --- a/src/core/operator_list.js +++ b/src/core/operator_list.js @@ -490,6 +490,7 @@ var QueueOptimizer = (function QueueOptimizerClosure() { } ); + // eslint-disable-next-line no-shadow function QueueOptimizer(queue) { this.queue = queue; this.state = null; @@ -584,6 +585,7 @@ var QueueOptimizer = (function QueueOptimizerClosure() { })(); var NullOptimizer = (function NullOptimizerClosure() { + // eslint-disable-next-line no-shadow function NullOptimizer(queue) { this.queue = queue; } @@ -606,6 +608,7 @@ var OperatorList = (function OperatorListClosure() { var CHUNK_SIZE = 1000; var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5; // close to chunk size + // eslint-disable-next-line no-shadow function OperatorList(intent, streamSink, pageIndex) { this._streamSink = streamSink; this.fnArray = []; diff --git a/src/core/pattern.js b/src/core/pattern.js index 4e0907837..a2d752f5c 100644 --- a/src/core/pattern.js +++ b/src/core/pattern.js @@ -38,6 +38,7 @@ var ShadingType = { var Pattern = (function PatternClosure() { // Constructor should define this.getPattern + // eslint-disable-next-line no-shadow function Pattern() { unreachable("should not call Pattern constructor"); } @@ -450,6 +451,8 @@ Shadings.Mesh = (function MeshClosure() { return lut; } var cache = []; + + // eslint-disable-next-line no-shadow return function getB(count) { if (!cache[count]) { cache[count] = buildB(count); diff --git a/src/core/primitives.js b/src/core/primitives.js index b3c597124..a0e8d62c3 100644 --- a/src/core/primitives.js +++ b/src/core/primitives.js @@ -21,6 +21,7 @@ var EOF = {}; var Name = (function NameClosure() { let nameCache = Object.create(null); + // eslint-disable-next-line no-shadow function Name(name) { this.name = name; } @@ -43,6 +44,7 @@ var Name = (function NameClosure() { var Cmd = (function CmdClosure() { let cmdCache = Object.create(null); + // eslint-disable-next-line no-shadow function Cmd(cmd) { this.cmd = cmd; } @@ -68,6 +70,7 @@ var Dict = (function DictClosure() { }; // xref is optional + // eslint-disable-next-line no-shadow function Dict(xref) { // Map should only be used internally, use functions below to access. this._map = Object.create(null); @@ -185,6 +188,7 @@ var Dict = (function DictClosure() { var Ref = (function RefClosure() { let refCache = Object.create(null); + // eslint-disable-next-line no-shadow function Ref(num, gen) { this.num = num; this.gen = gen; @@ -218,6 +222,7 @@ var Ref = (function RefClosure() { // The reference is identified by number and generation. // This structure stores only one instance of the reference. var RefSet = (function RefSetClosure() { + // eslint-disable-next-line no-shadow function RefSet() { this.dict = Object.create(null); } @@ -240,6 +245,7 @@ var RefSet = (function RefSetClosure() { })(); var RefSetCache = (function RefSetCacheClosure() { + // eslint-disable-next-line no-shadow function RefSetCache() { this.dict = Object.create(null); } diff --git a/src/core/ps_parser.js b/src/core/ps_parser.js index 34d70e981..fc97b057f 100644 --- a/src/core/ps_parser.js +++ b/src/core/ps_parser.js @@ -113,6 +113,7 @@ const PostScriptTokenTypes = { const PostScriptToken = (function PostScriptTokenClosure() { const opCache = Object.create(null); + // eslint-disable-next-line no-shadow class PostScriptToken { constructor(type, value) { this.type = type; diff --git a/src/core/stream.js b/src/core/stream.js index 072c78cdc..0b5d5e1f6 100644 --- a/src/core/stream.js +++ b/src/core/stream.js @@ -24,6 +24,7 @@ import { isDict } from "./primitives.js"; import { isWhiteSpace } from "./core_utils.js"; var Stream = (function StreamClosure() { + // eslint-disable-next-line no-shadow function Stream(arrayBuffer, start, length, dict) { this.bytes = arrayBuffer instanceof Uint8Array @@ -129,6 +130,7 @@ var Stream = (function StreamClosure() { })(); var StringStream = (function StringStreamClosure() { + // eslint-disable-next-line no-shadow function StringStream(str) { const bytes = stringToBytes(str); Stream.call(this, bytes); @@ -147,6 +149,7 @@ var DecodeStream = (function DecodeStreamClosure() { // buffer. var emptyBuffer = new Uint8Array(0); + // eslint-disable-next-line no-shadow function DecodeStream(maybeMinBufferLength) { this._rawMinBufferLength = maybeMinBufferLength || 0; @@ -282,6 +285,7 @@ var DecodeStream = (function DecodeStreamClosure() { })(); var StreamsSequenceStream = (function StreamsSequenceStreamClosure() { + // eslint-disable-next-line no-shadow function StreamsSequenceStream(streams) { this.streams = streams; @@ -426,6 +430,7 @@ var FlateStream = (function FlateStreamClosure() { 0x50003, 0x50013, 0x5000b, 0x5001b, 0x50007, 0x50017, 0x5000f, 0x00000 ]), 5]; + // eslint-disable-next-line no-shadow function FlateStream(str, maybeLength) { this.str = str; this.dict = str.dict; @@ -711,6 +716,7 @@ var FlateStream = (function FlateStreamClosure() { })(); var PredictorStream = (function PredictorStreamClosure() { + // eslint-disable-next-line no-shadow function PredictorStream(str, maybeLength, params) { if (!isDict(params)) { return str; // no prediction @@ -932,6 +938,7 @@ var PredictorStream = (function PredictorStreamClosure() { })(); var DecryptStream = (function DecryptStreamClosure() { + // eslint-disable-next-line no-shadow function DecryptStream(str, maybeLength, decrypt) { this.str = str; this.dict = str.dict; @@ -978,6 +985,7 @@ var DecryptStream = (function DecryptStreamClosure() { })(); var Ascii85Stream = (function Ascii85StreamClosure() { + // eslint-disable-next-line no-shadow function Ascii85Stream(str, maybeLength) { this.str = str; this.dict = str.dict; @@ -1062,6 +1070,7 @@ var Ascii85Stream = (function Ascii85StreamClosure() { })(); var AsciiHexStream = (function AsciiHexStreamClosure() { + // eslint-disable-next-line no-shadow function AsciiHexStream(str, maybeLength) { this.str = str; this.dict = str.dict; @@ -1128,6 +1137,7 @@ var AsciiHexStream = (function AsciiHexStreamClosure() { })(); var RunLengthStream = (function RunLengthStreamClosure() { + // eslint-disable-next-line no-shadow function RunLengthStream(str, maybeLength) { this.str = str; this.dict = str.dict; @@ -1175,6 +1185,7 @@ var RunLengthStream = (function RunLengthStreamClosure() { })(); var LZWStream = (function LZWStreamClosure() { + // eslint-disable-next-line no-shadow function LZWStream(str, maybeLength, earlyChange) { this.str = str; this.dict = str.dict; @@ -1311,6 +1322,7 @@ var LZWStream = (function LZWStreamClosure() { })(); var NullStream = (function NullStreamClosure() { + // eslint-disable-next-line no-shadow function NullStream() { Stream.call(this, new Uint8Array(0)); } diff --git a/src/core/type1_parser.js b/src/core/type1_parser.js index 80428e4a8..76f5c3d2f 100644 --- a/src/core/type1_parser.js +++ b/src/core/type1_parser.js @@ -79,6 +79,7 @@ var Type1CharString = (function Type1CharStringClosure() { hvcurveto: [31], }; + // eslint-disable-next-line no-shadow function Type1CharString() { this.width = 0; this.lsb = 0; @@ -451,6 +452,7 @@ var Type1Parser = (function Type1ParserClosure() { ); } + // eslint-disable-next-line no-shadow function Type1Parser(stream, encrypted, seacAnalysisEnabled) { if (encrypted) { var data = stream.getBytes(); diff --git a/src/core/worker.js b/src/core/worker.js index c92ac1958..34e5a824c 100644 --- a/src/core/worker.js +++ b/src/core/worker.js @@ -38,6 +38,7 @@ import { PDFWorkerStream } from "./worker_stream.js"; import { XRefParseException } from "./core_utils.js"; var WorkerTask = (function WorkerTaskClosure() { + // eslint-disable-next-line no-shadow function WorkerTask(name) { this.name = name; this.terminated = false; diff --git a/src/display/api.js b/src/display/api.js index 4e50d987c..4f5749f35 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -420,6 +420,7 @@ const PDFDocumentLoadingTask = (function PDFDocumentLoadingTaskClosure() { * (such as network requests) and provides a way to listen for completion, * after which individual pages can be rendered. */ + // eslint-disable-next-line no-shadow class PDFDocumentLoadingTask { constructor() { this._capability = createPromiseCapability(); @@ -1679,6 +1680,7 @@ const PDFWorker = (function PDFWorkerClosure() { * thread to the worker thread and vice versa. If the creation of a web * worker is not possible, a "fake" worker will be used instead. */ + // eslint-disable-next-line no-shadow class PDFWorker { /** * @param {PDFWorkerParameters} params - Worker initialization parameters. @@ -2700,6 +2702,7 @@ class RenderTask { const InternalRenderTask = (function InternalRenderTaskClosure() { const canvasInRendering = new WeakSet(); + // eslint-disable-next-line no-shadow class InternalRenderTask { constructor({ callback, diff --git a/src/display/canvas.js b/src/display/canvas.js index de0147aaf..89345ae58 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -168,6 +168,7 @@ function addContextCurrentTransform(ctx) { } var CachedCanvases = (function CachedCanvasesClosure() { + // eslint-disable-next-line no-shadow function CachedCanvases(canvasFactory) { this.canvasFactory = canvasFactory; this.cache = Object.create(null); @@ -383,6 +384,7 @@ function compileType3Glyph(imgData) { } var CanvasExtraState = (function CanvasExtraStateClosure() { + // eslint-disable-next-line no-shadow function CanvasExtraState() { // Are soft masks and alpha values shapes or opacities? this.alphaIsShape = false; @@ -435,6 +437,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { // Defines the number of steps before checking the execution time var EXECUTION_STEPS = 10; + // eslint-disable-next-line no-shadow function CanvasGraphics( canvasCtx, commonObjs, diff --git a/src/display/pattern_helper.js b/src/display/pattern_helper.js index 190cbd389..9b0fb08e9 100644 --- a/src/display/pattern_helper.js +++ b/src/display/pattern_helper.js @@ -226,6 +226,7 @@ var createMeshCanvas = (function createMeshCanvasClosure() { } } + // eslint-disable-next-line no-shadow function createMeshCanvas( bounds, combinesScale, @@ -413,6 +414,7 @@ var TilingPattern = (function TilingPatternClosure() { var MAX_PATTERN_SIZE = 3000; // 10in @ 300dpi shall be enough + // eslint-disable-next-line no-shadow function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) { this.operatorList = IR[2]; this.matrix = IR[3] || [1, 0, 0, 1, 0, 0]; diff --git a/src/display/svg.js b/src/display/svg.js index 882972eb6..e605d7054 100644 --- a/src/display/svg.js +++ b/src/display/svg.js @@ -286,6 +286,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { return createObjectURL(data, "image/png", forceDataSchema); } + // eslint-disable-next-line no-shadow return function convertImgDataToPng(imgData, forceDataSchema, isMask) { const kind = imgData.kind === undefined ? ImageKind.GRAYSCALE_1BPP : imgData.kind; @@ -437,6 +438,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { let maskCount = 0; let shadingCount = 0; + // eslint-disable-next-line no-shadow SVGGraphics = class SVGGraphics { constructor(commonObjs, objs, forceDataSchema) { this.svgFactory = new DOMSVGFactory(); diff --git a/src/display/text_layer.js b/src/display/text_layer.js index e668bead3..6db45eac2 100644 --- a/src/display/text_layer.js +++ b/src/display/text_layer.js @@ -719,6 +719,7 @@ var renderTextLayer = (function renderTextLayerClosure() { * @param {TextLayerRenderParameters} renderParameters * @returns {TextLayerRenderTask} */ + // eslint-disable-next-line no-shadow function renderTextLayer(renderParameters) { var task = new TextLayerRenderTask({ textContent: renderParameters.textContent, diff --git a/src/shared/util.js b/src/shared/util.js index a2a4bfc59..dc4a4a2d8 100644 --- a/src/shared/util.js +++ b/src/shared/util.js @@ -405,6 +405,7 @@ function shadow(obj, prop, value) { } const BaseException = (function BaseExceptionClosure() { + // eslint-disable-next-line no-shadow function BaseException(message) { if (this.constructor === BaseException) { unreachable("Cannot initialize BaseException."); @@ -859,6 +860,7 @@ const createObjectURL = (function createObjectURLClosure() { const digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + // eslint-disable-next-line no-shadow return function createObjectURL(data, contentType, forceDataSchema = false) { if (!forceDataSchema && URL.createObjectURL) { const blob = new Blob([data], { type: contentType }); diff --git a/test/driver.js b/test/driver.js index 5458f3b2b..15f44a4a5 100644 --- a/test/driver.js +++ b/test/driver.js @@ -45,6 +45,7 @@ var rasterizeTextLayer = (function rasterizeTextLayerClosure() { return textLayerStylePromise; } + // eslint-disable-next-line no-shadow function rasterizeTextLayer( ctx, viewport, @@ -178,6 +179,7 @@ var rasterizeAnnotationLayer = (function rasterizeAnnotationLayerClosure() { return imagePromises; } + // eslint-disable-next-line no-shadow function rasterizeAnnotationLayer( ctx, viewport, @@ -283,6 +285,7 @@ var Driver = (function DriverClosure() { * @constructs Driver * @param {DriverOptions} options */ + // eslint-disable-next-line no-shadow function Driver(options) { // Configure the global worker options. pdfjsLib.GlobalWorkerOptions.workerSrc = WORKER_SRC; diff --git a/web/debugger.js b/web/debugger.js index 39b1e0020..ed7ee5a54 100644 --- a/web/debugger.js +++ b/web/debugger.js @@ -285,6 +285,7 @@ var Stepper = (function StepperClosure() { return simpleObj; } + // eslint-disable-next-line no-shadow function Stepper(panel, pageIndex, initialBreakPoints) { this.panel = panel; this.breakPoint = 0;