Skip to content

Commit

Permalink
Fix the linting errors, from the Prettier auto-formatting, that ESLin…
Browse files Browse the repository at this point in the history
…t `--fix` couldn't handle

This patch makes the follow changes:
 - Remove no longer necessary inline `// eslint-disable-...` comments.
 - Fix `// eslint-disable-...` comments that Prettier moved down, thus causing new linting errors.
 - Concatenate strings which now fit on just one line.
 - Fix comments that are now too long.
 - Finally, and most importantly, adjust comments that Prettier moved down, since the new positions often is confusing or outright wrong.
  • Loading branch information
Snuffleupagus committed Dec 26, 2019
1 parent de36b2a commit a63f7ad
Show file tree
Hide file tree
Showing 46 changed files with 179 additions and 219 deletions.
4 changes: 1 addition & 3 deletions examples/components/pageviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
"use strict";

if (!pdfjsLib.getDocument || !pdfjsViewer.PDFPageView) {
alert(
"Please build the pdfjs-dist library using\n" + " `gulp dist-install`"
);
alert("Please build the pdfjs-dist library using\n `gulp dist-install`");
}

// The workerSrc property shall be specified.
Expand Down
6 changes: 2 additions & 4 deletions examples/components/simpleviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
"use strict";

if (!pdfjsLib.getDocument || !pdfjsViewer.PDFViewer) {
alert(
"Please build the pdfjs-dist library using\n" + " `gulp dist-install`"
);
alert("Please build the pdfjs-dist library using\n `gulp dist-install`");
}

// The workerSrc property shall be specified.
Expand Down Expand Up @@ -55,8 +53,8 @@ document.addEventListener("pagesinit", function() {
// We can use pdfViewer now, e.g. let's change default scale.
pdfViewer.currentScaleValue = "page-width";

// We can try searching for things.
if (SEARCH_FOR) {
// We can try search for things
pdfFindController.executeCommand("find", { query: SEARCH_FOR });
}
});
Expand Down
6 changes: 2 additions & 4 deletions examples/components/singlepageviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
"use strict";

if (!pdfjsLib.getDocument || !pdfjsViewer.PDFSinglePageViewer) {
alert(
"Please build the pdfjs-dist library using\n" + " `gulp dist-install`"
);
alert("Please build the pdfjs-dist library using\n `gulp dist-install`");
}

// The workerSrc property shall be specified.
Expand Down Expand Up @@ -55,8 +53,8 @@ document.addEventListener("pagesinit", function() {
// We can use pdfSinglePageViewer now, e.g. let's change default scale.
pdfSinglePageViewer.currentScaleValue = "page-width";

// We can try searching for things.
if (SEARCH_FOR) {
// We can try search for things
pdfFindController.executeCommand("find", { query: SEARCH_FOR });
}
});
Expand Down
4 changes: 1 addition & 3 deletions examples/svgviewer/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
"use strict";

if (!pdfjsLib.getDocument || !pdfjsViewer.PDFViewer) {
alert(
"Please build the pdfjs-dist library using\n" + " `gulp dist-install`"
);
alert("Please build the pdfjs-dist library using\n `gulp dist-install`");
}

// The workerSrc property shall be specified.
Expand Down
2 changes: 1 addition & 1 deletion external/builder/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function preprocess(inFilename, outFilename, defines) {
var line;
var state = STATE_NONE;
var stack = [];
var control = /^(?:\/\/|<!--)\s*#(if|elif|else|endif|expand|include|error)\b(?:\s+(.*?)(?:-->)?$)?/; // eslint-disable-next-line max-len
var control = /^(?:\/\/|<!--)\s*#(if|elif|else|endif|expand|include|error)\b(?:\s+(.*?)(?:-->)?$)?/;
var lineNumber = 0;
var loc = function() {
return fs.realpathSync(inFilename) + ":" + lineNumber;
Expand Down
10 changes: 4 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ function createWebpackConfig(defines, output) {
// `web-streams-polyfill` (already using a transpiled file), and
// `src/core/{glyphlist,unicode}.js` (Babel is too slow for those)
// should be excluded from processing.
// eslint-disable-next-line max-len
exclude: /(node_modules[\\\/]core-js|node_modules[\\\/]web-streams-polyfill|src[\\\/]core[\\\/](glyphlist|unicode))/,
options: {
presets: skipBabel ? undefined : ["@babel/preset-env"],
Expand Down Expand Up @@ -425,7 +424,7 @@ function createTestSource(testsName, bot) {
"Browser manifest file test/" + PDF_BROWSERS + " does not exist."
);
console.log(
"Copy and adjust the example in " + "test/resources/browser_manifests."
"Copy and adjust the example in test/resources/browser_manifests."
);
this.emit("error", new Error("Missing manifest file"));
return null;
Expand Down Expand Up @@ -476,7 +475,7 @@ function makeRef(done, bot) {
"Browser manifest file test/" + PDF_BROWSERS + " does not exist."
);
console.log(
"Copy and adjust the example in " + "test/resources/browser_manifests."
"Copy and adjust the example in test/resources/browser_manifests."
);
done(new Error("Missing manifest file"));
return;
Expand Down Expand Up @@ -669,7 +668,7 @@ gulp.task("locale", function() {
gulp.dest(VIEWER_LOCALE_OUTPUT)
),
gulp
.src(L10N_DIR + "/{" + locales.join(",") + "}" + "/viewer.properties", {
.src(L10N_DIR + "/{" + locales.join(",") + "}/viewer.properties", {
base: L10N_DIR,
})
.pipe(gulp.dest(VIEWER_LOCALE_OUTPUT)),
Expand Down Expand Up @@ -1142,7 +1141,6 @@ gulp.task(
babelPluginReplaceNonWebPackRequire,
],
}).code;
// eslint-disable-next-line max-len
var removeCjsSrc = /^(var\s+\w+\s*=\s*(_interopRequireDefault\()?require\(".*?)(?:\/src)(\/[^"]*"\)\)?;)$/gm;
content = content.replace(
removeCjsSrc,
Expand Down Expand Up @@ -1679,7 +1677,7 @@ gulp.task(
console.log();
console.log("Done. Push with");
console.log(
" cd " + DIST_DIR + "; " + "git push --tags " + DIST_REPO_URL + " master"
" cd " + DIST_DIR + "; git push --tags " + DIST_REPO_URL + " master"
);
console.log();
done();
Expand Down
2 changes: 1 addition & 1 deletion src/core/cmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,8 @@ class IdentityCMap extends CMap {
return 0x10000;
}

// eslint-disable-next-line getter-return
get isIdentityCMap() {
// eslint-disable-line getter-return
unreachable("should not access .isIdentityCMap");
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/core/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,7 @@ class PDFDocument {
ch = stream.getByte();
} while (isSpace(ch));
let str = "";
while (ch >= 0x20 && ch <= 0x39) {
// < '9'
while (ch >= /* Space = */ 0x20 && ch <= /* '9' = */ 0x39) {
str += String.fromCharCode(ch);
ch = stream.getByte();
}
Expand Down Expand Up @@ -622,8 +621,7 @@ class PDFDocument {
const MAX_PDF_VERSION_LENGTH = 12;
let version = "",
ch;
while ((ch = stream.getByte()) > 0x20) {
// Space
while ((ch = stream.getByte()) > /* Space = */ 0x20) {
if (version.length >= MAX_PDF_VERSION_LENGTH) {
break;
}
Expand Down
15 changes: 9 additions & 6 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
])
.then(
function() {
// Only add the dependency once we know that the native JPEG decoding
// succeeded, to ensure that rendering will always complete.
// Only add the dependency once we know that the native JPEG
// decoding succeeded, to ensure that rendering will always
// complete.
operatorList.addDependency(objId);
args = [objId, w, h];

Expand Down Expand Up @@ -755,7 +756,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
return translated;
})
.catch(reason => {
// Error in the font data -- sending unsupported feature notification.
// Error in the font data -- sending unsupported feature
// notification.
this.handler.send("UnsupportedFeature", {
featureId: UNSUPPORTED_FEATURES.font,
});
Expand Down Expand Up @@ -2160,9 +2162,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
return;
}

// Use a new `StateManager` to prevent incorrect positioning of
// textItems *after* the Form XObject, since errors in the data
// can otherwise prevent `restore` operators from executing.
// Use a new `StateManager` to prevent incorrect positioning
// of textItems *after* the Form XObject, since errors in the
// data can otherwise prevent `restore` operators from
// executing.
// NOTE: Only an issue when `options.ignoreErrors === true`.
let currentState = stateManager.state.clone();
let xObjStateManager = new StateManager(currentState);
Expand Down
4 changes: 1 addition & 3 deletions src/core/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -929,9 +929,8 @@ var Font = (function FontClosure() {
return true;
}
// ... obviously some fonts violate that part of the specification,
// please refer to the comment in |Type1Font| below.
// please refer to the comment in |Type1Font| below (pfb file header).
if (header[0] === 0x80 && header[1] === 0x01) {
// pfb file header.
return true;
}
return false;
Expand Down Expand Up @@ -1085,7 +1084,6 @@ var Font = (function FontClosure() {
var ranges = [];
var length = codes.length;
for (var n = 0; n < length; ) {
// eslint-disable-line space-in-parens
var start = codes[n].fontCharCode;
var codeIndices = [codes[n].glyphId];
++n;
Expand Down
4 changes: 2 additions & 2 deletions src/core/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ var PDFImage = (function PDFImageClosure() {
}
if (width < 1 || height < 1) {
throw new FormatError(
`Invalid image width: ${width} or ` + `height: ${height}`
`Invalid image width: ${width} or height: ${height}`
);
}
this.width = width;
Expand Down Expand Up @@ -617,11 +617,11 @@ var PDFImage = (function PDFImageClosure() {
var drawWidth = this.drawWidth;
var drawHeight = this.drawHeight;
var imgData = {
// other fields are filled in below
width: drawWidth,
height: drawHeight,
kind: 0,
data: null,
// Other fields are filled in below.
};

var numComps = this.numComps;
Expand Down
2 changes: 1 addition & 1 deletion src/core/jpeg_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ let JpegStream = (function JpegStreamClosure() {
// Note: this seems to mainly affect inline images.
let ch;
while ((ch = stream.getByte()) !== -1) {
// Find the first byte of the SOI marker (0xFFD8).
if (ch === 0xff) {
// Find the first byte of the SOI marker (0xFFD8).
stream.skip(-1); // Reset the stream position to the SOI.
break;
}
Expand Down
13 changes: 4 additions & 9 deletions src/core/jpg.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable no-multi-spaces */

import { assert, BaseException, warn } from "../shared/util";

Expand Down Expand Up @@ -149,7 +148,6 @@ var JpegImage = (function JpegImageClosure() {
var nextByte = data[offset++];
if (nextByte) {
if (nextByte === 0xdc && parseDNLMarker) {
// DNL == 0xFFDC
offset += 2; // Skip data length.
const scanLines = (data[offset++] << 8) | data[offset++];
if (scanLines > 0 && scanLines !== frame.scanLines) {
Expand All @@ -159,7 +157,6 @@ var JpegImage = (function JpegImageClosure() {
);
}
} else if (nextByte === 0xd9) {
// EOI == 0xFFD9
throw new EOIMarkerError(
"Found EOI marker (0xFFD9) while parsing scan data"
);
Expand Down Expand Up @@ -746,14 +743,12 @@ var JpegImage = (function JpegImageClosure() {
var huffmanTablesAC = [],
huffmanTablesDC = [];
var fileMarker = readUint16();
if (fileMarker !== 0xffd8) {
// SOI (Start of Image)
if (fileMarker !== /* SOI (Start of Image) = */ 0xffd8) {
throw new JpegError("SOI not found");
}

fileMarker = readUint16();
markerLoop: while (fileMarker !== 0xffd9) {
// EOI (End of image)
markerLoop: while (fileMarker !== /* EOI (End of Image) = */ 0xffd9) {
var i, j, l;
switch (fileMarker) {
case 0xffe0: // APP0 (Application Specific)
Expand All @@ -776,14 +771,14 @@ var JpegImage = (function JpegImageClosure() {
var appData = readDataBlock();

if (fileMarker === 0xffe0) {
// 'JFIF\x00'
if (
appData[0] === 0x4a &&
appData[1] === 0x46 &&
appData[2] === 0x49 &&
appData[3] === 0x46 &&
appData[4] === 0
) {
// 'JFIF\x00'
jfif = {
version: { major: appData[5], minor: appData[6] },
densityUnits: appData[7],
Expand All @@ -800,14 +795,14 @@ var JpegImage = (function JpegImageClosure() {
}
// TODO APP1 - Exif
if (fileMarker === 0xffee) {
// 'Adobe'
if (
appData[0] === 0x41 &&
appData[1] === 0x64 &&
appData[2] === 0x6f &&
appData[3] === 0x62 &&
appData[4] === 0x65
) {
// 'Adobe'
adobe = {
version: (appData[5] << 8) | appData[6],
flags0: (appData[7] << 8) | appData[8],
Expand Down
2 changes: 1 addition & 1 deletion src/core/jpx.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ var JpxImage = (function JpxImageClosure() {
break;
case 0xff53: // Coding style component (COC)
throw new Error(
"Codestream code 0xFF53 (COC) is " + "not implemented"
"Codestream code 0xFF53 (COC) is not implemented"
);
default:
throw new Error("Unknown codestream code: " + code.toString(16));
Expand Down
Loading

0 comments on commit a63f7ad

Please sign in to comment.