Enable the mozilla/avoid-removeChild 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 a polyfill for `ChildNode.remove()` and that most cases have already been fixed, see PRs 8056 and 8138.
This commit is contained in:
Jonas Jenwald
2018-02-10 23:24:50 +01:00
parent 9767b8a9f1
commit 2eb29409bc
5 changed files with 12 additions and 5 deletions
+7
View File
@@ -4,6 +4,10 @@
"sourceType": "module",
},
"plugins": [
"mozilla"
],
"env": {
"browser": true,
"es6": true,
@@ -18,6 +22,9 @@
},
"rules": {
// Plugins
"mozilla/avoid-removeChild": "error",
// Possible errors
"for-direction": "error",
"no-cond-assign": ["error", "except-parens"],
+1
View File
@@ -152,6 +152,7 @@ PDFJS.compatibilityChecked = true;
}
Element.prototype.remove = function () {
if (this.parentNode) {
// eslint-disable-next-line mozilla/avoid-removeChild
this.parentNode.removeChild(this);
}
};
+1 -2
View File
@@ -367,8 +367,7 @@ var Driver = (function DriverClosure() { // eslint-disable-line no-unused-vars
while (styleSheet.cssRules.length > 0) {
styleSheet.deleteRule(0);
}
let ownerNode = styleSheet.ownerNode;
ownerNode.parentNode.removeChild(ownerNode);
styleSheet.ownerNode.remove();
}
let body = document.body;
while (body.lastChild !== this.end) {
+1 -1
View File
@@ -43,7 +43,7 @@ function download(blobUrl, filename) {
// (otherwise .click() is ignored)
(document.body || document.documentElement).appendChild(a);
a.click();
a.parentNode.removeChild(a);
a.remove();
} else {
if (window.top === window &&
blobUrl.split('#')[0] === window.location.href.split('#')[0]) {
+2 -2
View File
@@ -111,8 +111,8 @@ PDFPrintService.prototype = {
return;
}
this.printContainer.textContent = '';
if (this.pageStyleSheet && this.pageStyleSheet.parentNode) {
this.pageStyleSheet.parentNode.removeChild(this.pageStyleSheet);
if (this.pageStyleSheet) {
this.pageStyleSheet.remove();
this.pageStyleSheet = null;
}
this.scratchCanvas.width = this.scratchCanvas.height = 0;