1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-21 23:58:07 +02:00

Enable the mozilla/use-includes-instead-of-indexOf ESLint rule globally

This rule is available from https://www.npmjs.com/package/eslint-plugin-mozilla, and is enforced in mozilla-central. Note that we have the necessary `Array`/`String` polyfills and that most cases have already been fixed, see PRs 9032 and 9434.
This commit is contained in:
Jonas Jenwald 2018-02-10 17:06:03 +01:00
parent 2eb29409bc
commit 1cf116ab88
14 changed files with 21 additions and 17 deletions

View file

@ -1208,7 +1208,7 @@ let PDFViewerApplication = {
];
if (info.Producer) {
KNOWN_GENERATORS.some(function (generator, s, i) {
if (generator.indexOf(s) < 0) {
if (!generator.includes(s)) {
return false;
}
generatorId = i + 1;
@ -1490,7 +1490,7 @@ if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {
}
try {
let viewerOrigin = new URL(window.location.href).origin || 'null';
if (HOSTED_VIEWER_ORIGINS.indexOf(viewerOrigin) >= 0) {
if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
// Hosted or local viewer, allow for any file locations
return;
}

View file

@ -338,7 +338,7 @@ var Stepper = (function StepperClosure() {
line.className = 'line';
line.dataset.idx = i;
chunk.appendChild(line);
var checked = this.breakPoints.indexOf(i) !== -1;
var checked = this.breakPoints.includes(i);
var args = operatorList.argsArray[i] || [];
var breakCell = c('td');
@ -521,7 +521,7 @@ window.PDFBug = (function PDFBugClosure() {
}
for (var i = 0; i < tools.length; ++i) {
var tool = tools[i];
if (all || ids.indexOf(tool.id) !== -1) {
if (all || ids.includes(tool.id)) {
tool.enabled = true;
}
}

View file

@ -49,7 +49,7 @@ function download(blobUrl, filename) {
blobUrl.split('#')[0] === window.location.href.split('#')[0]) {
// If _parent == self, then opening an identical URL with different
// location hash will only cause a navigation, not a download.
let padCharacter = blobUrl.indexOf('?') === -1 ? '?' : '&';
let padCharacter = blobUrl.includes('?') ? '&' : '?';
blobUrl = blobUrl.replace(/#|$/, padCharacter + '$&');
}
window.open(blobUrl, '_parent');

View file

@ -192,7 +192,7 @@ class PDFLinkService {
*/
setHash(hash) {
let pageNumber, dest;
if (hash.indexOf('=') >= 0) {
if (hash.includes('=')) {
let params = parseQueryString(hash);
if ('search' in params) {
this.eventBus.dispatch('findfromurlhash', {
@ -215,7 +215,7 @@ class PDFLinkService {
let zoomArg = zoomArgs[0];
let zoomArgNumber = parseFloat(zoomArg);
if (zoomArg.indexOf('Fit') === -1) {
if (!zoomArg.includes('Fit')) {
// If the zoomArg is a number, it has to get divided by 100. If it's
// a string, it should stay as it is.
dest = [null, { name: 'XYZ', },

View file

@ -420,7 +420,7 @@ function getPDFFileNameFromURL(url, defaultFilename = 'document.pdf') {
reFilename.exec(splitURI[3]);
if (suggestedFilename) {
suggestedFilename = suggestedFilename[0];
if (suggestedFilename.indexOf('%') !== -1) {
if (suggestedFilename.includes('%')) {
// URL-encoded %2Fpath%2Fto%2Ffile.pdf should be file.pdf
try {
suggestedFilename =