Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable ESLint rules that no longer need to be disabled on a directory/file-basis #12890

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions examples/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,9 @@
"../.eslintrc"
],

"parserOptions": {
"ecmaVersion": 6,
},

"env": {
"es6": false,
},

"globals": {
"pdfjsImageDecoders": false,
"pdfjsLib": false,
"pdfjsViewer": false,
"Uint8Array": false,
},

"rules": {
"no-alert": "off",
"object-shorthand": ["error", "never"]
}
}
4 changes: 2 additions & 2 deletions examples/acroforms/acroforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ loadingTask.promise.then(function (doc) {
return doc.getPage(pageNum).then(function (pdfPage) {
// Create the page view.
var pdfPageView = new pdfjsViewer.PDFPageView({
container: container,
container,
id: pageNum,
scale: DEFAULT_SCALE,
defaultViewport: pdfPage.getViewport({ scale: DEFAULT_SCALE }),
eventBus: eventBus,
eventBus,
annotationLayerFactory: new pdfjsViewer.DefaultAnnotationLayerFactory(),
renderInteractiveForms: true,
});
Expand Down
2 changes: 1 addition & 1 deletion examples/browserify/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ loadingTask.promise
var ctx = canvas.getContext("2d");
var renderTask = pdfPage.render({
canvasContext: ctx,
viewport: viewport,
viewport,
});
return renderTask.promise;
});
Expand Down
5 changes: 3 additions & 2 deletions examples/components/pageviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"use strict";

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

Expand Down Expand Up @@ -48,11 +49,11 @@ loadingTask.promise.then(function (pdfDocument) {
return pdfDocument.getPage(PAGE_TO_VIEW).then(function (pdfPage) {
// Creating the page view with default parameters.
var pdfPageView = new pdfjsViewer.PDFPageView({
container: container,
container,
id: PAGE_TO_VIEW,
scale: SCALE,
defaultViewport: pdfPage.getViewport({ scale: SCALE }),
eventBus: eventBus,
eventBus,
// We can enable text/annotations layers, if needed
textLayerFactory: new pdfjsViewer.DefaultTextLayerFactory(),
annotationLayerFactory: new pdfjsViewer.DefaultAnnotationLayerFactory(),
Expand Down
9 changes: 5 additions & 4 deletions examples/components/simpleviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"use strict";

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

Expand All @@ -38,18 +39,18 @@ var eventBus = new pdfjsViewer.EventBus();

// (Optionally) enable hyperlinks within PDF files.
var pdfLinkService = new pdfjsViewer.PDFLinkService({
eventBus: eventBus,
eventBus,
});

// (Optionally) enable find controller.
var pdfFindController = new pdfjsViewer.PDFFindController({
eventBus: eventBus,
eventBus,
linkService: pdfLinkService,
});

var pdfViewer = new pdfjsViewer.PDFViewer({
container: container,
eventBus: eventBus,
container,
eventBus,
linkService: pdfLinkService,
findController: pdfFindController,
});
Expand Down
9 changes: 5 additions & 4 deletions examples/components/singlepageviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"use strict";

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

Expand All @@ -38,18 +39,18 @@ var eventBus = new pdfjsViewer.EventBus();

// (Optionally) enable hyperlinks within PDF files.
var pdfLinkService = new pdfjsViewer.PDFLinkService({
eventBus: eventBus,
eventBus,
});

// (Optionally) enable find controller.
var pdfFindController = new pdfjsViewer.PDFFindController({
eventBus: eventBus,
eventBus,
linkService: pdfLinkService,
});

var pdfSinglePageViewer = new pdfjsViewer.PDFSinglePageViewer({
container: container,
eventBus: eventBus,
container,
eventBus,
linkService: pdfLinkService,
findController: pdfFindController,
});
Expand Down
5 changes: 3 additions & 2 deletions examples/image_decoders/jpeg_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"use strict";

if (!pdfjsImageDecoders.JpegImage) {
// eslint-disable-next-line no-alert
alert("Please build the pdfjs-dist library using `gulp dist-install`");
}

Expand Down Expand Up @@ -61,8 +62,8 @@ jpegImage.parse(typedArrayImage);
var width = jpegImage.width,
height = jpegImage.height;
var jpegData = jpegImage.getData({
width: width,
height: height,
width,
height,
forceRGB: true,
});

Expand Down
23 changes: 12 additions & 11 deletions examples/mobile-viewer/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"use strict";

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

Expand Down Expand Up @@ -47,7 +48,7 @@ var PDFViewerApplication = {
* @returns {Promise} - Returns the promise, which is resolved when document
* is opened.
*/
open: function (params) {
open(params) {
if (this.pdfLoadingTask) {
// We need to destroy already opened document
return this.close().then(
Expand All @@ -64,7 +65,7 @@ var PDFViewerApplication = {

// Loading document.
var loadingTask = pdfjsLib.getDocument({
url: url,
url,
maxImageSize: MAX_IMAGE_SIZE,
cMapUrl: CMAP_URL,
cMapPacked: CMAP_PACKED,
Expand Down Expand Up @@ -120,7 +121,7 @@ var PDFViewerApplication = {
}

loadingErrorMessage.then(function (msg) {
self.error(msg, { message: message });
self.error(msg, { message });
});
self.loadingBar.hide();
}
Expand All @@ -132,7 +133,7 @@ var PDFViewerApplication = {
* @returns {Promise} - Returns the promise, which is resolved when all
* destruction is completed.
*/
close: function () {
close() {
var errorWrapper = document.getElementById("errorWrapper");
errorWrapper.setAttribute("hidden", "true");

Expand Down Expand Up @@ -175,7 +176,7 @@ var PDFViewerApplication = {
this.setTitle(title);
},

setTitleUsingMetadata: function (pdfDocument) {
setTitleUsingMetadata(pdfDocument) {
var self = this;
pdfDocument.getMetadata().then(function (data) {
var info = data.info,
Expand Down Expand Up @@ -345,17 +346,17 @@ var PDFViewerApplication = {
this.eventBus = eventBus;

var linkService = new pdfjsViewer.PDFLinkService({
eventBus: eventBus,
eventBus,
});
this.pdfLinkService = linkService;

this.l10n = pdfjsViewer.NullL10n;

var container = document.getElementById("viewerContainer");
var pdfViewer = new pdfjsViewer.PDFViewer({
container: container,
eventBus: eventBus,
linkService: linkService,
container,
eventBus,
linkService,
l10n: this.l10n,
useOnlyCssZoom: USE_ONLY_CSS_ZOOM,
textLayerMode: TEXT_LAYER_MODE,
Expand All @@ -364,8 +365,8 @@ var PDFViewerApplication = {
linkService.setViewer(pdfViewer);

this.pdfHistory = new pdfjsViewer.PDFHistory({
eventBus: eventBus,
linkService: linkService,
eventBus,
linkService,
});
linkService.setHistory(this.pdfHistory);

Expand Down
8 changes: 4 additions & 4 deletions examples/node/domstubs.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function DOMElement(name) {
if (name === "style") {
this.sheet = {
cssRules: [],
insertRule: function (rule) {
insertRule(rule) {
this.cssRules.push(rule);
},
};
Expand Down Expand Up @@ -226,16 +226,16 @@ const document = {
return this;
},

createElementNS: function (NS, element) {
createElementNS(NS, element) {
var elObject = new DOMElement(element);
return elObject;
},

createElement: function (element) {
createElement(element) {
return this.createElementNS("", element);
},

getElementsByTagName: function (element) {
getElementsByTagName(element) {
if (element === "head") {
return [this.head || (this.head = new DOMElement("head"))];
}
Expand Down
10 changes: 5 additions & 5 deletions examples/node/pdf2png/pdf2png.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ NodeCanvasFactory.prototype = {
var canvas = Canvas.createCanvas(width, height);
var context = canvas.getContext("2d");
return {
canvas: canvas,
context: context,
canvas,
context,
};
},

Expand Down Expand Up @@ -61,7 +61,7 @@ var data = new Uint8Array(fs.readFileSync(pdfPath));

// Load the PDF file.
var loadingTask = pdfjsLib.getDocument({
data: data,
data,
cMapUrl: CMAP_URL,
cMapPacked: CMAP_PACKED,
});
Expand All @@ -80,8 +80,8 @@ loadingTask.promise
);
var renderContext = {
canvasContext: canvasAndContext.context,
viewport: viewport,
canvasFactory: canvasFactory,
viewport,
canvasFactory,
};

var renderTask = page.render(renderContext);
Expand Down
4 changes: 2 additions & 2 deletions examples/node/pdf2svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ ReadableSVGStream.prototype._read = function () {
// Streams the SVG element to the given file path.
function writeSvgToFile(svgElement, filePath) {
var readableSvgStream = new ReadableSVGStream({
svgElement: svgElement,
svgElement,
});
var writableStream = fs.createWriteStream(filePath);
return new Promise(function (resolve, reject) {
Expand All @@ -89,7 +89,7 @@ function writeSvgToFile(svgElement, filePath) {
// Will be using promises to load document, pages and misc data instead of
// callback.
var loadingTask = pdfjsLib.getDocument({
data: data,
data,
cMapUrl: CMAP_URL,
cMapPacked: CMAP_PACKED,
fontExtraProperties: true,
Expand Down
7 changes: 4 additions & 3 deletions examples/svgviewer/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"use strict";

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

Expand All @@ -37,12 +38,12 @@ var eventBus = new pdfjsViewer.EventBus();

// (Optionally) enable hyperlinks within PDF files.
var pdfLinkService = new pdfjsViewer.PDFLinkService({
eventBus: eventBus,
eventBus,
});

var pdfViewer = new pdfjsViewer.PDFViewer({
container: container,
eventBus: eventBus,
container,
eventBus,
linkService: pdfLinkService,
renderer: "svg",
textLayerMode: 0,
Expand Down
6 changes: 2 additions & 4 deletions examples/text-only/pdf2svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,8 @@ function pageLoaded() {

document.addEventListener("DOMContentLoaded", function () {
if (typeof pdfjsLib === "undefined") {
alert(
"Built version of PDF.js was not found.\n" +
"Please run `gulp dist-install`."
);
// eslint-disable-next-line no-alert
alert("Please build the pdfjs-dist library using\n `gulp dist-install`");
return;
}
pageLoaded();
Expand Down
2 changes: 1 addition & 1 deletion examples/webpack/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ loadingTask.promise
var ctx = canvas.getContext("2d");
var renderTask = pdfPage.render({
canvasContext: ctx,
viewport: viewport,
viewport,
});
return renderTask.promise;
});
Expand Down
9 changes: 0 additions & 9 deletions extensions/.eslintrc

This file was deleted.

6 changes: 0 additions & 6 deletions external/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,4 @@
"env": {
"node": true,
},

"rules": {
"mozilla/use-includes-instead-of-indexOf": "off",
"object-shorthand": "off",
"no-restricted-globals": "off",
},
}
Loading