diff --git a/.eslintrc.js b/.eslintrc.js index fe823eb..752a3cb 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -47,7 +47,7 @@ module.exports = { { "endOfLine": "auto", "arrowParens": "avoid", - "printWidth": 100, + "printWidth": 80, "tabWidth": 2, "trailingComma": "es5", "quoteProps": "preserve", @@ -57,8 +57,6 @@ module.exports = { ignorePatterns: ["node_modules", "utils/boot.jsm"], // Ignore eslint configurations in parent directories. root: true, - // New rules and configurations should generally be added in - // tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js to // allow external repositories that use the plugin to pick them up as well. extends: ["plugin:mozilla/recommended"], plugins: ["mozilla", "import"], diff --git a/JS/findbarMods.uc.js b/JS/findbarMods.uc.js index 91247a0..e22f506 100644 --- a/JS/findbarMods.uc.js +++ b/JS/findbarMods.uc.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Findbar Mods -// @version 1.3.3 +// @version 1.3.4 // @author aminomancer // @homepage https://github.com/aminomancer // @description 1) Make a custom context menu for the findbar that lets you @@ -104,7 +104,9 @@ class FindbarMods { if (this.forceMiniFindbar) return true; let file = Cc["@mozilla.org/chrome/chrome-registry;1"] .getService(Ci.nsIChromeRegistry) - .convertChromeURL(Services.io.newURI("chrome://userchrome/content/material/")) + .convertChromeURL( + Services.io.newURI("chrome://userchrome/content/material/") + ) ?.QueryInterface(Ci.nsIFileURL)?.file; return file?.exists() && file?.isDirectory(); }); @@ -309,7 +311,9 @@ class FindbarMods { if (node == wrapper || node == foundMatches) continue; node.hidden = showMinimalUI; } - this.getElement("find-next").hidden = this.getElement("find-previous").hidden = showMinimalUI; + this.getElement("find-next").hidden = this.getElement( + "find-previous" + ).hidden = showMinimalUI; foundMatches.hidden = showMinimalUI || !foundMatches.value; tinyIndicator.style.display = showMinimalUI ? "none" : "inline-block"; if (showMinimalUI) this._findField.classList.add("minimal"); @@ -364,9 +368,17 @@ class FindbarMods { if (!node) return; let findbar = node.tagName === "findbar" ? node : node.closest("findbar"); if (!findbar) return; - if (e.currentTarget !== this.contextMenu) return this.onSubmenuShowing(e, findbar); - this.contextMenu._menuitemHighlightAll.setAttribute("checked", !!findbar._highlightAll); - this.contextMenu._menuitemEntireWord.setAttribute("checked", !!findbar._entireWord); + if (e.currentTarget !== this.contextMenu) { + return this.onSubmenuShowing(e, findbar); + } + this.contextMenu._menuitemHighlightAll.setAttribute( + "checked", + !!findbar._highlightAll + ); + this.contextMenu._menuitemEntireWord.setAttribute( + "checked", + !!findbar._entireWord + ); if (findbar._quickFindTimeout) { clearTimeout(findbar._quickFindTimeout); findbar._quickFindTimeout = null; @@ -387,15 +399,22 @@ class FindbarMods { onSubmenuShowing(e, findbar) { if (e.target === this.contextMenu._menuMatchDiacriticsPopup) { let diacriticsStatus = - Services.prefs.getIntPref("findbar.matchdiacritics", 0) || findbar._matchDiacritics; - let activeItem = this.contextMenu._menuMatchDiacriticsPopup.children[diacriticsStatus]; + Services.prefs.getIntPref("findbar.matchdiacritics", 0) || + findbar._matchDiacritics; + let activeItem = this.contextMenu._menuMatchDiacriticsPopup.children[ + diacriticsStatus + ]; activeItem.setAttribute("checked", true); } if (e.target === this.contextMenu._menuMatchCasePopup) { let caseStatus = - Services.prefs.getIntPref("accessibility.typeaheadfind.casesensitive", 0) || - findbar._typeAheadCaseSensitive; - let activeItem = this.contextMenu._menuMatchCasePopup.children[caseStatus]; + Services.prefs.getIntPref( + "accessibility.typeaheadfind.casesensitive", + 0 + ) || findbar._typeAheadCaseSensitive; + let activeItem = this.contextMenu._menuMatchCasePopup.children[ + caseStatus + ]; activeItem.setAttribute("checked", true); } } @@ -412,9 +431,11 @@ class FindbarMods { if ( e.keyCode == KeyEvent.DOM_VK_UP || (e.keyCode == KeyEvent.DOM_VK_LEFT && - document.defaultView.getComputedStyle(this.parentNode).direction == "ltr") || + document.defaultView.getComputedStyle(this.parentNode).direction == + "ltr") || (e.keyCode == KeyEvent.DOM_VK_RIGHT && - document.defaultView.getComputedStyle(this.parentNode).direction == "rtl") + document.defaultView.getComputedStyle(this.parentNode).direction == + "rtl") ) { e.preventDefault(); window.document.commandDispatcher.rewindFocus(); @@ -423,16 +444,26 @@ class FindbarMods { if ( e.keyCode == KeyEvent.DOM_VK_DOWN || (e.keyCode == KeyEvent.DOM_VK_RIGHT && - document.defaultView.getComputedStyle(this.parentNode).direction == "ltr") || + document.defaultView.getComputedStyle(this.parentNode).direction == + "ltr") || (e.keyCode == KeyEvent.DOM_VK_LEFT && - document.defaultView.getComputedStyle(this.parentNode).direction == "rtl") + document.defaultView.getComputedStyle(this.parentNode).direction == + "rtl") ) { e.preventDefault(); window.document.commandDispatcher.advanceFocus(); return; } // handle access keys - if (!e.charCode || e.charCode <= 32 || e.altKey || e.ctrlKey || e.metaKey) return; + if ( + !e.charCode || + e.charCode <= 32 || + e.altKey || + e.ctrlKey || + e.metaKey + ) { + return; + } const charLower = String.fromCharCode(e.charCode).toLowerCase(); if (this.accessKey.toLowerCase() == charLower) { this.click(); @@ -471,7 +502,9 @@ class FindbarMods { // rules similar to those in uc-findbar.css. findbar._findField.style.width = "20em"; // we want the close button to be on the far right end of the findbar. - findbar._findField.parentNode.after(findbar.querySelector(".findbar-closebutton")); + findbar._findField.parentNode.after( + findbar.querySelector(".findbar-closebutton") + ); // put it after the input box so we can use the ~ squiggly combinator findbar._findField.after(findbar._tinyIndicator); // move the match-case and entire-word buttons into the text field. @@ -485,10 +518,10 @@ class FindbarMods { entireWordButton.addEventListener("keypress", onKey); } // for a given findbar, move its label into the proper position. - setLabelPosition(findbar) { - let getBounds = window.windowUtils.getBoundsWithoutFlushing; + updateLabelPosition(findbar) { let distanceFromEdge = - getBounds(findbar).right - getBounds(findbar.querySelector(".findbar-textbox")).right; + findbar.getBoundingClientRect().right - + findbar.querySelector(".findbar-textbox").getBoundingClientRect().right; findbar._tinyIndicator.style.right = `${distanceFromEdge + 1}px`; } // when a new tab is opened and the findbar somehow activated, a new findbar @@ -543,7 +576,7 @@ class FindbarMods { } onFindbarOpen(e) { if (e.target.findMode == e.target.FIND_NORMAL) { - setTimeout(() => e.target.ucFindbarMods.setLabelPosition(e.target), 1); + requestAnimationFrame(() => this.updateLabelPosition(e.target)); } } } diff --git a/JS/miscMods.uc.js b/JS/miscMods.uc.js index 01a0132..25b6533 100644 --- a/JS/miscMods.uc.js +++ b/JS/miscMods.uc.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Misc. Mods -// @version 2.0.5 +// @version 2.0.6 // @author aminomancer // @homepage https://github.com/aminomancer/uc.css.js // @description Various tiny mods not worth making separate scripts for. Read the comments inside the script for details. @@ -50,6 +50,12 @@ // the 200 with another number, it will wait that long in milliseconds instead. "Reduce ctrl+tab delay": 200, + // By default, Shift+Ctrl+Tab will open the all-tabs panel. But if you hit + // Ctrl+Tab to open the ctrlTab panel, then Shift+Ctrl+Tab will cycle + // backwards through recently used tabs. To make this more consistent with + // OS-level Alt/Cmd+Tab, this setting disables the all-tabs panel shortcut. + "Use Shift+Ctrl+Tab to switch": true, + // normally, firefox only animates the stop/reload button when it's in the main customizable // navbar. if you enter customize mode and move the button to the tabs toolbar, menu bar, or // personal/bookmarks toolbar, the animated transition between the stop icon to the reload @@ -161,17 +167,25 @@ if (config["Disable bookmarks toolbar auto show"]) { gEditItemOverlay._autoshowBookmarksToolbar = function() {}; } - if (config["Moving tabs with arrow keys can wrap"]) gBrowser.arrowKeysShouldWrap = true; + if (config["Moving tabs with arrow keys can wrap"]) { + gBrowser.arrowKeysShouldWrap = true; + } if (config["Stop downloads panel auto-focusing the footer button"]) { this.stopDownloadsPanelFocus(); } - if (config["Move all selected tabs with hotkeys"]) this.moveTabKeysMoveSelectedTabs(); - if (config["Anchor bookmarks menu tooltip to bookmark"]) this.anchorBookmarksTooltip(); - this.reduceCtrlTabDelay(config["Reduce ctrl+tab delay"]); + if (config["Move all selected tabs with hotkeys"]) { + this.moveTabKeysMoveSelectedTabs(); + } + if (config["Anchor bookmarks menu tooltip to bookmark"]) { + this.anchorBookmarksTooltip(); + } + this.modCtrlTabMethods(); if (config["Allow stop/reload button to animate in other toolbars"]) { this.stopReloadAnimations(); } - if (config["Give the private browsing indicator a tooltip"]) this.addPrivateBrowsingTooltip(); + if (config["Give the private browsing indicator a tooltip"]) { + this.addPrivateBrowsingTooltip(); + } if (config["Preserve your default bookmarks folder"]) { this.makeDefaultBookmarkFolderPermanent(); } @@ -181,22 +195,30 @@ if (config["Don't exit DOM fullscreen when opening permissions popup"]) { this.permsPopupInFullscreen(); } - if (config["Customize tab drag preview background color"]) this.tabDragPreview(); + if (config["Customize tab drag preview background color"]) { + this.tabDragPreview(); + } if (config["Show container icons on multiselected tabs"]) { this.containerIconsOnMultiselectedTabs(); } - if (config["Disable loading status for status panel"]) this.disableLoadingStatus(); + if (config["Disable loading status for status panel"]) { + this.disableLoadingStatus(); + } this.randomTinyStuff(); } stopDownloadsPanelFocus() { eval( `DownloadsPanel._focusPanel = function ` + - DownloadsPanel._focusPanel.toSource().replace(/DownloadsFooter\.focus\(\)\;/, ``) + DownloadsPanel._focusPanel + .toSource() + .replace(/DownloadsFooter\.focus\(\)\;/, ``) ); } moveTabKeysMoveSelectedTabs() { gBrowser.moveTabsBackward = function() { - let tabs = this.selectedTab.multiselected ? this.selectedTabs : [this.selectedTab]; + let tabs = this.selectedTab.multiselected + ? this.selectedTabs + : [this.selectedTab]; let previousTab = this.tabContainer.findNextTab(tabs[0], { direction: -1, filter: tab => !tab.hidden, @@ -204,21 +226,29 @@ for (let tab of tabs) { if (previousTab) { this.moveTabTo(tab, previousTab._tPos); - } else if (this.arrowKeysShouldWrap && tab._tPos < this.browsers.length - 1) { + } else if ( + this.arrowKeysShouldWrap && + tab._tPos < this.browsers.length - 1 + ) { this.moveTabTo(tab, this.browsers.length - 1); } } }; gBrowser.moveTabsForward = function() { - let tabs = this.selectedTab.multiselected ? this.selectedTabs : [this.selectedTab]; + let tabs = this.selectedTab.multiselected + ? this.selectedTabs + : [this.selectedTab]; let nextTab = this.tabContainer.findNextTab(tabs[tabs.length - 1], { direction: 1, filter: tab => !tab.hidden, }); for (let i = tabs.length - 1; i >= 0; i--) { let tab = tabs[i]; - if (nextTab) this.moveTabTo(tab, nextTab._tPos); - else if (this.arrowKeysShouldWrap && tab._tPos > 0) this.moveTabTo(tab, 0); + if (nextTab) { + this.moveTabTo(tab, nextTab._tPos); + } else if (this.arrowKeysShouldWrap && tab._tPos > 0) { + this.moveTabTo(tab, 0); + } } }; eval( @@ -242,7 +272,11 @@ node = tree.view.nodeForTreeIndex(cell.row); cropped = tree.isCellCropped(cell.row, cell.col); // get coordinates for the cell in a tree. - var cellCoords = tree.getCoordsForCellItem(cell.row, cell.col, "cell"); + var cellCoords = tree.getCoordsForCellItem( + cell.row, + cell.col, + "cell" + ); } else { var tooltipNode = tooltip.triggerNode; if (tooltipNode._placesNode) node = tooltipNode._placesNode; @@ -251,14 +285,19 @@ if (!node && !targetURI) return false; var title = node ? node.title : tooltipNode.label; var url; - if (targetURI || PlacesUtils.nodeIsURI(node)) url = targetURI || node.uri; + if (targetURI || PlacesUtils.nodeIsURI(node)) { + url = targetURI || node.uri; + } if (!cropped && !url) return false; aEvent.target.setAttribute("position", "after_start"); if (tooltipNode) { aEvent.target.moveToAnchor(tooltipNode, "after_start"); } else if (tree && cellCoords) { // anchor the tooltip to the tree cell - aEvent.target.moveTo(cellCoords.left + tree.screenX, cellCoords.bottom + tree.screenY); + aEvent.target.moveTo( + cellCoords.left + tree.screenX, + cellCoords.bottom + tree.screenY + ); } let tooltipTitle = aEvent.target.querySelector(".places-tooltip-title"); tooltipTitle.hidden = !title || title == url; @@ -269,15 +308,58 @@ return true; }; } - reduceCtrlTabDelay(delay) { - if (delay === 200) return; - ctrlTab.open = function() { + modCtrlTabMethods() { + const delay = config["Reduce ctrl+tab delay"]; + const shiftCtrlTabBehavior = config["Use Shift+Ctrl+Tab to switch"]; + ctrlTab.onKeyDown = function(event) { + let action = ShortcutUtils.getSystemActionForEvent(event); + if (action != ShortcutUtils.CYCLE_TABS) { + return; + } + + event.preventDefault(); + event.stopPropagation(); + + if (this.isOpen) { + this.advanceFocus(!event.shiftKey); + return; + } + + Services.els.addSystemEventListener(document, "keyup", this, false); + + let tabs = gBrowser.visibleTabs; + if (tabs.length > 2) { + let reverse = event.shiftKey && shiftCtrlTabBehavior; + this.open(!reverse); + } else if (tabs.length == 2) { + let index = tabs[0].selected ? 1 : 0; + gBrowser.selectedTab = tabs[index]; + } + }; + ctrlTab.open = function(forward = true) { if (this.isOpen) return; - this.canvasWidth = Math.ceil((screen.availWidth * 0.85) / this.maxTabPreviews); - this.canvasHeight = Math.round(this.canvasWidth * tabPreviews.aspectRatio); + this.canvasWidth = Math.ceil( + (screen.availWidth * 0.85) / this.maxTabPreviews + ); + this.canvasHeight = Math.round( + this.canvasWidth * tabPreviews.aspectRatio + ); this.updatePreviews(); - this._selectedIndex = 1; - gBrowser.warmupTab(this.selected._tab); + + let selectedIndex = 0; + do { + selectedIndex += forward ? 1 : -1; + if (selectedIndex < 0) { + selectedIndex = this.previews.length - 1; + } else if (selectedIndex >= this.previews.length) { + selectedIndex = 0; + } + } while (this.previews[selectedIndex].hidden); + this._selectedIndex = selectedIndex; + + if (this.selected._tab) { + gBrowser.warmupTab(this.selected._tab); + } this._timer = setTimeout(() => { this._timer = null; this._openPanel(); @@ -301,7 +383,10 @@ ); } async addPrivateBrowsingTooltip() { - this.privateL10n = await new Localization(["browser/aboutPrivateBrowsing.ftl"], true); + this.privateL10n = await new Localization( + ["browser/aboutPrivateBrowsing.ftl"], + true + ); let l10nId = PrivateBrowsingUtils.isWindowPrivate(window) ? "about-private-browsing-info-title" : "about-private-browsing-not-private"; @@ -311,16 +396,18 @@ } makeDefaultBookmarkFolderPermanent() { let { panel } = StarUI; - let checkbox = panel.querySelector("#editBMPanel_newFolderBox").appendChild( - _ucUtils.createElement(document, "checkbox", { - id: "editBookmarkPanel_persistLastLocation", - label: "Remember last location", - accesskey: "R", - tooltiptext: - "Update the default bookmark folder when you change it. If unchecked, the folder chosen when this was checked will remain the default folder indefinitely.", - oncommand: `Services.prefs.setBoolPref("userChrome.bookmarks.editDialog.persistLastLocation", this.checked)`, - }) - ); + let checkbox = panel + .querySelector("#editBMPanel_newFolderBox") + .appendChild( + _ucUtils.createElement(document, "checkbox", { + id: "editBookmarkPanel_persistLastLocation", + label: "Remember last location", + accesskey: "R", + tooltiptext: + "Update the default bookmark folder when you change it. If unchecked, the folder chosen when this was checked will remain the default folder indefinitely.", + oncommand: `Services.prefs.setBoolPref("userChrome.bookmarks.editDialog.persistLastLocation", this.checked)`, + }) + ); panel.addEventListener("popupshowing", e => { if (e.target !== panel) return; let pref = Services.prefs.getBoolPref( @@ -375,7 +462,8 @@ containerIconsOnMultiselectedTabs() { const lazy = {}; XPCOMUtils.defineLazyModuleGetters(lazy, { - ContextualIdentityService: "resource://gre/modules/ContextualIdentityService.jsm", + ContextualIdentityService: + "resource://gre/modules/ContextualIdentityService.jsm", }); if (lazy.ContextualIdentityService.hasOwnProperty("setTabStyle")) return; lazy.ContextualIdentityService.setTabStyle = function(tab) { @@ -390,7 +478,10 @@ let iconPrefix = "identity-icon-"; /* Remove the existing container color highlight if it exists */ for (let className of tab.classList) { - if (className.startsWith(colorPrefix) || className.startsWith(iconPrefix)) { + if ( + className.startsWith(colorPrefix) || + className.startsWith(iconPrefix) + ) { tab.classList.remove(className); } } @@ -425,7 +516,9 @@ .getElementById("template-protections-popup") ?.content.querySelector("#protections-popup"); let setEtpPopupInfoTooltip = e => { - let infoButton = e.target.querySelector("#protections-popup-info-button"); + let infoButton = e.target.querySelector( + "#protections-popup-info-button" + ); let ariaLabel = infoButton.getAttribute("aria-label"); if (ariaLabel) { infoButton.removeAttribute("data-l10n-id"); @@ -435,7 +528,9 @@ } etpPanel.removeEventListener("popupshowing", setEtpPopupInfoTooltip); }; - if (etpPanel) etpPanel.addEventListener("popupshowing", setEtpPopupInfoTooltip); + if (etpPanel) { + etpPanel.addEventListener("popupshowing", setEtpPopupInfoTooltip); + } // support icons for the "move sidebar to left" and "move sidebar to right" buttons in // the sidebar switcher dropdown menu that appear when you click the sidebar switcher: @@ -457,7 +552,10 @@ ? gNavigatorBundle.getString("sidebar.moveToLeft") : gNavigatorBundle.getString("sidebar.moveToRight"); this._reversePositionButton.setAttribute("label", label); - this._reversePositionButton.setAttribute("to-position", onRight ? "left" : "right"); + this._reversePositionButton.setAttribute( + "to-position", + onRight ? "left" : "right" + ); this._switcherPanel.hidden = false; this._switcherPanel.openPopup(this._icon); this._switcherTarget.classList.add("active"); @@ -493,6 +591,9 @@ new UCMiscMods(); } }; - Services.obs.addObserver(delayedListener, "browser-delayed-startup-finished"); + Services.obs.addObserver( + delayedListener, + "browser-delayed-startup-finished" + ); } })(); diff --git a/package.json b/package.json index 429e6d0..d6cae37 100644 --- a/package.json +++ b/package.json @@ -4,26 +4,25 @@ "repository": {}, "license": "CC BY-NC-SA 4.0", "devDependencies": { - "@babel/core": "7.19.1", - "@babel/eslint-parser": "7.19.1", - "@babel/eslint-plugin": "7.19.1", - "@babel/plugin-syntax-jsx": "7.18.6", - "eslint": "8.24.0", - "eslint-config-prettier": "8.5.0", - "eslint-plugin-fetch-options": "0.0.5", - "eslint-plugin-file-header": "0.0.1", - "eslint-plugin-html": "7.1.0", - "eslint-plugin-import": "2.26.0", - "eslint-plugin-jest": "23.20.0", - "eslint-plugin-jsdoc": "39.3.6", - "eslint-plugin-jsx-a11y": "6.6.1", - "eslint-plugin-mozilla": "file:tools/lint/eslint/eslint-plugin-mozilla", - "eslint-plugin-no-unsanitized": "4.0.1", - "eslint-plugin-prettier": "3.4.0", - "eslint-plugin-react": "7.29.4", - "eslint-plugin-react-hooks": "4.6.0", + "@babel/core": "~7.19.1", + "@babel/eslint-parser": "~7.19.1", + "@babel/eslint-plugin": "~7.19.1", + "@babel/plugin-syntax-jsx": "~7.18.6", + "eslint": "~8.24.0", + "eslint-config-prettier": "~8.5.0", + "eslint-plugin-fetch-options": "~0.0.5", + "eslint-plugin-file-header": "~0.0.1", + "eslint-plugin-html": "", + "eslint-plugin-import": "~2.26.0", + "eslint-plugin-jest": "~23.20.0", + "eslint-plugin-jsdoc": "~39.3.6", + "eslint-plugin-jsx-a11y": "~6.6.1", + "eslint-plugin-mozilla": "^2.12.5", + "eslint-plugin-no-unsanitized": "~4.0.1", + "eslint-plugin-prettier": "~3.4.0", + "eslint-plugin-react": "~7.29.4", + "eslint-plugin-react-hooks": "~4.6.0", "jsdoc": "3.6.11", - "prettier": "1.19.1", - "yarn": "1.22.19" + "prettier": "~1.19.1" } } diff --git a/resources/in-content/root.css b/resources/in-content/root.css index 30d3eba..83550c2 100644 --- a/resources/in-content/root.css +++ b/resources/in-content/root.css @@ -6,6 +6,23 @@ /* fundamental content styles, e.g. plaintext pages. */ +@namespace html url("http://www.w3.org/1999/xhtml"); +@namespace xul url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); + +html|tt, +html|code, +html|kbd, +html|samp, +html|xmp, +html|pre, +html|plaintext, +html|listing, +html|textarea, +html|input:is([type=date], [type=time], [type=datetime-local]) { + font-family: Fira Code UC, Fira Code, SF Mono, -moz-fixed, monospace; + font-weight: 300; +} + @media (prefers-color-scheme: dark) { ::selection { background-color: var(--global-selection-bgcolor) !important; diff --git a/resources/layout/contentaccessible/viewsource.css b/resources/layout/contentaccessible/viewsource.css index e8712d8..ebe6828 100644 --- a/resources/layout/contentaccessible/viewsource.css +++ b/resources/layout/contentaccessible/viewsource.css @@ -11,8 +11,7 @@ font-family: "Fira Code UC"; font-style: normal; src: local("Fira Code"), local("Fira Code Light"), url(../fonts/FiraCode-VF.woff); - font-feature-settings: "ss01", "ss02", "cv19", "ss05", "ss07", "ss08", "cv14", "cv25", "cv28", - "cv32"; + font-feature-settings: "cv14", "cv19", "cv30", "ss01", "ss02", "ss05", "ss07", "ss09"; } *|*:root { diff --git a/tools/lint/eslint/.eslintrc.js b/tools/lint/eslint/.eslintrc.js deleted file mode 100644 index ff0ef23..0000000 --- a/tools/lint/eslint/.eslintrc.js +++ /dev/null @@ -1,27 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -"use strict"; - -module.exports = { - // eslint-plugin-mozilla runs under node, so we need a more restrictive - // environment / parser setup here than the rest of mozilla-central. - env: { - browser: false, - node: true, - }, - parser: "espree", - parserOptions: { - ecmaVersion: 12, - }, - - rules: { - camelcase: ["error", { properties: "never" }], - "handle-callback-err": ["error", "er"], - "no-shadow": "error", - "no-undef-init": "error", - "one-var": ["error", "never"], - strict: ["error", "global"], - }, -}; diff --git a/tools/lint/eslint/eslint-plugin-mozilla/.npmignore b/tools/lint/eslint/eslint-plugin-mozilla/.npmignore deleted file mode 100644 index 3713448..0000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -.eslintrc.js -.npmignore -node_modules -reporters -scripts -tests -package-lock.json -update.sh diff --git a/tools/lint/eslint/eslint-plugin-mozilla/LICENSE b/tools/lint/eslint/eslint-plugin-mozilla/LICENSE deleted file mode 100644 index e87a115..0000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/LICENSE +++ /dev/null @@ -1,363 +0,0 @@ -Mozilla Public License, version 2.0 - -1. Definitions - -1.1. "Contributor" - - means each individual or legal entity that creates, contributes to the - creation of, or owns Covered Software. - -1.2. "Contributor Version" - - means the combination of the Contributions of others (if any) used by a - Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - - means Source Code Form to which the initial Contributor has attached the - notice in Exhibit A, the Executable Form of such Source Code Form, and - Modifications of such Source Code Form, in each case including portions - thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - a. that the initial Contributor has attached the notice described in - Exhibit B to the Covered Software; or - - b. that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the terms of - a Secondary License. - -1.6. "Executable Form" - - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - - means a work that combines Covered Software with other material, in a - separate file or files, that is not Covered Software. - -1.8. "License" - - means this document. - -1.9. "Licensable" - - means having the right to grant, to the maximum extent possible, whether - at the time of the initial grant or subsequently, any and all of the - rights conveyed by this License. - -1.10. "Modifications" - - means any of the following: - - a. any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered Software; or - - b. any new file in Source Code Form that contains any Covered Software. - -1.11. "Patent Claims" of a Contributor - - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the License, - by the making, using, selling, offering for sale, having made, import, - or transfer of either its Contributions or its Contributor Version. - -1.12. "Secondary License" - - means either the GNU General Public License, Version 2.0, the GNU Lesser - General Public License, Version 2.1, the GNU Affero General Public - License, Version 3.0, or any later versions of those licenses. - -1.13. "Source Code Form" - - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that controls, is - controlled by, or is under common control with You. For purposes of this - definition, "control" means (a) the power, direct or indirect, to cause - the direction or management of such entity, whether by contract or - otherwise, or (b) ownership of more than fifty percent (50%) of the - outstanding shares or beneficial ownership of such entity. - - -2. License Grants and Conditions - -2.1. Grants - - Each Contributor hereby grants You a world-wide, royalty-free, - non-exclusive license: - - a. under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - - b. under Patent Claims of such Contributor to make, use, sell, offer for - sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - - The licenses granted in Section 2.1 with respect to any Contribution - become effective for each Contribution on the date the Contributor first - distributes such Contribution. - -2.3. Limitations on Grant Scope - - The licenses granted in this Section 2 are the only rights granted under - this License. No additional rights or licenses will be implied from the - distribution or licensing of Covered Software under this License. - Notwithstanding Section 2.1(b) above, no patent license is granted by a - Contributor: - - a. for any code that a Contributor has removed from Covered Software; or - - b. for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - - c. under Patent Claims infringed by Covered Software in the absence of - its Contributions. - - This License does not grant any rights in the trademarks, service marks, - or logos of any Contributor (except as may be necessary to comply with - the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - - No Contributor makes additional grants as a result of Your choice to - distribute the Covered Software under a subsequent version of this - License (see Section 10.2) or under the terms of a Secondary License (if - permitted under the terms of Section 3.3). - -2.5. Representation - - Each Contributor represents that the Contributor believes its - Contributions are its original creation(s) or it has sufficient rights to - grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - - This License is not intended to limit any rights You have under - applicable copyright doctrines of fair use, fair dealing, or other - equivalents. - -2.7. Conditions - - Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in - Section 2.1. - - -3. Responsibilities - -3.1. Distribution of Source Form - - All distribution of Covered Software in Source Code Form, including any - Modifications that You create or to which You contribute, must be under - the terms of this License. You must inform recipients that the Source - Code Form of the Covered Software is governed by the terms of this - License, and how they can obtain a copy of this License. You may not - attempt to alter or restrict the recipients' rights in the Source Code - Form. - -3.2. Distribution of Executable Form - - If You distribute Covered Software in Executable Form then: - - a. such Covered Software must also be made available in Source Code Form, - as described in Section 3.1, and You must inform recipients of the - Executable Form how they can obtain a copy of such Source Code Form by - reasonable means in a timely manner, at a charge no more than the cost - of distribution to the recipient; and - - b. You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter the - recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - - You may create and distribute a Larger Work under terms of Your choice, - provided that You also comply with the requirements of this License for - the Covered Software. If the Larger Work is a combination of Covered - Software with a work governed by one or more Secondary Licenses, and the - Covered Software is not Incompatible With Secondary Licenses, this - License permits You to additionally distribute such Covered Software - under the terms of such Secondary License(s), so that the recipient of - the Larger Work may, at their option, further distribute the Covered - Software under the terms of either this License or such Secondary - License(s). - -3.4. Notices - - You may not remove or alter the substance of any license notices - (including copyright notices, patent notices, disclaimers of warranty, or - limitations of liability) contained within the Source Code Form of the - Covered Software, except that You may alter any license notices to the - extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - - You may choose to offer, and to charge a fee for, warranty, support, - indemnity or liability obligations to one or more recipients of Covered - Software. However, You may do so only on Your own behalf, and not on - behalf of any Contributor. You must make it absolutely clear that any - such warranty, support, indemnity, or liability obligation is offered by - You alone, and You hereby agree to indemnify every Contributor for any - liability incurred by such Contributor as a result of warranty, support, - indemnity or liability terms You offer. You may include additional - disclaimers of warranty and limitations of liability specific to any - jurisdiction. - -4. Inability to Comply Due to Statute or Regulation - - If it is impossible for You to comply with any of the terms of this License - with respect to some or all of the Covered Software due to statute, - judicial order, or regulation then You must: (a) comply with the terms of - this License to the maximum extent possible; and (b) describe the - limitations and the code they affect. Such description must be placed in a - text file included with all distributions of the Covered Software under - this License. Except to the extent prohibited by statute or regulation, - such description must be sufficiently detailed for a recipient of ordinary - skill to be able to understand it. - -5. Termination - -5.1. The rights granted under this License will terminate automatically if You - fail to comply with any of its terms. However, if You become compliant, - then the rights granted under this License from a particular Contributor - are reinstated (a) provisionally, unless and until such Contributor - explicitly and finally terminates Your grants, and (b) on an ongoing - basis, if such Contributor fails to notify You of the non-compliance by - some reasonable means prior to 60 days after You have come back into - compliance. Moreover, Your grants from a particular Contributor are - reinstated on an ongoing basis if such Contributor notifies You of the - non-compliance by some reasonable means, this is the first time You have - received notice of non-compliance with this License from such - Contributor, and You become compliant prior to 30 days after Your receipt - of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent - infringement claim (excluding declaratory judgment actions, - counter-claims, and cross-claims) alleging that a Contributor Version - directly or indirectly infringes any patent, then the rights granted to - You by any and all Contributors for the Covered Software under Section - 2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user - license agreements (excluding distributors and resellers) which have been - validly granted by You or Your distributors under this License prior to - termination shall survive termination. - -6. Disclaimer of Warranty - - Covered Software is provided under this License on an "as is" basis, - without warranty of any kind, either expressed, implied, or statutory, - including, without limitation, warranties that the Covered Software is free - of defects, merchantable, fit for a particular purpose or non-infringing. - The entire risk as to the quality and performance of the Covered Software - is with You. Should any Covered Software prove defective in any respect, - You (not any Contributor) assume the cost of any necessary servicing, - repair, or correction. This disclaimer of warranty constitutes an essential - part of this License. No use of any Covered Software is authorized under - this License except under this disclaimer. - -7. Limitation of Liability - - Under no circumstances and under no legal theory, whether tort (including - negligence), contract, or otherwise, shall any Contributor, or anyone who - distributes Covered Software as permitted above, be liable to You for any - direct, indirect, special, incidental, or consequential damages of any - character including, without limitation, damages for lost profits, loss of - goodwill, work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses, even if such party shall have been - informed of the possibility of such damages. This limitation of liability - shall not apply to liability for death or personal injury resulting from - such party's negligence to the extent applicable law prohibits such - limitation. Some jurisdictions do not allow the exclusion or limitation of - incidental or consequential damages, so this exclusion and limitation may - not apply to You. - -8. Litigation - - Any litigation relating to this License may be brought only in the courts - of a jurisdiction where the defendant maintains its principal place of - business and such litigation shall be governed by laws of that - jurisdiction, without reference to its conflict-of-law provisions. Nothing - in this Section shall prevent a party's ability to bring cross-claims or - counter-claims. - -9. Miscellaneous - - This License represents the complete agreement concerning the subject - matter hereof. If any provision of this License is held to be - unenforceable, such provision shall be reformed only to the extent - necessary to make it enforceable. Any law or regulation which provides that - the language of a contract shall be construed against the drafter shall not - be used to construe this License against a Contributor. - - -10. Versions of the License - -10.1. New Versions - - Mozilla Foundation is the license steward. Except as provided in Section - 10.3, no one other than the license steward has the right to modify or - publish new versions of this License. Each version will be given a - distinguishing version number. - -10.2. Effect of New Versions - - You may distribute the Covered Software under the terms of the version - of the License under which You originally received the Covered Software, - or under the terms of any subsequent version published by the license - steward. - -10.3. Modified Versions - - If you create software not governed by this License, and you want to - create a new license for such software, you may create and use a - modified version of this License if you rename the license and remove - any references to the name of the license steward (except to note that - such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary - Licenses If You choose to distribute Source Code Form that is - Incompatible With Secondary Licenses under the terms of this version of - the License, the notice described in Exhibit B of this License must be - attached. - -Exhibit A - Source Code Form License Notice - - This Source Code Form is subject to the - terms of the Mozilla Public License, v. - 2.0. If a copy of the MPL was not - distributed with this file, You can - obtain one at - http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular file, -then You may include the notice in a location (such as a LICENSE file in a -relevant directory) where a recipient would be likely to look for such a -notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice - - This Source Code Form is "Incompatible - With Secondary Licenses", as defined by - the Mozilla Public License, v. 2.0. - diff --git a/tools/lint/eslint/eslint-plugin-mozilla/README.md b/tools/lint/eslint/eslint-plugin-mozilla/README.md deleted file mode 100644 index 6505077..0000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# eslint-plugin-mozilla - -A collection of rules that help enforce JavaScript coding standard in the Mozilla project. - -These are primarily developed and used within the Firefox build system ([mozilla-central](https://hg.mozilla.org/mozilla-central/)), but are made available for other -related projects to use as well. - -## Installation - -### Within mozilla-central: - -``` -$ ./mach eslint --setup -``` - -### Outside mozilla-central: - -Install ESLint [ESLint](http://eslint.org): - -``` -$ npm i eslint --save-dev -``` - -Next, install `eslint-plugin-mozilla`: - -``` -$ npm install eslint-plugin-mozilla --save-dev -``` - -## Documentation - -For details about the rules, please see the [firefox documentation page](http://firefox-source-docs.mozilla.org/tools/lint/linters/eslint-plugin-mozilla.html). - -## Source Code - -The sources can be found at: - -* Code: https://searchfox.org/mozilla-central/source/tools/lint/eslint/eslint-plugin-mozilla -* Documentation: https://searchfox.org/mozilla-central/source/docs/code-quality/lint/linters - -## Bugs - -Please file bugs in Bugzilla in the Lint component of the Testing product. - -* [Existing bugs](https://bugzilla.mozilla.org/buglist.cgi?resolution=---&query_format=advanced&component=Lint&product=Testing) -* [New bugs](https://bugzilla.mozilla.org/enter_bug.cgi?product=Testing&component=Lint) - -## Tests - -The tests can only be run from within mozilla-central. To run the tests: - -``` -./mach eslint --setup -cd tools/lint/eslint/eslint-plugin-mozilla -npm run test -``` diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/.eslintrc.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/.eslintrc.js deleted file mode 100644 index 76df413..0000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/.eslintrc.js +++ /dev/null @@ -1,8 +0,0 @@ -"use strict"; - -module.exports = { - rules: { - // Require object keys to be sorted. - "sort-keys": "error", - }, -}; diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/browser-test.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/browser-test.js deleted file mode 100644 index 5c54d4b..0000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/browser-test.js +++ /dev/null @@ -1,88 +0,0 @@ -// Parent config file for all browser-chrome files. -"use strict"; - -module.exports = { - env: { - browser: true, - "mozilla/browser-window": true, - "mozilla/simpletest": true, - // "node": true - }, - - // All globals made available in the test environment. - globals: { - // `$` is defined in SimpleTest.js - $: false, - Assert: false, - BrowserTestUtils: false, - ContentTask: false, - ContentTaskUtils: false, - EventUtils: false, - IOUtils: false, - PathUtils: false, - PromiseDebugging: false, - SpecialPowers: false, - TestUtils: false, - XPCNativeWrapper: false, - addLoadEvent: false, - add_setup: false, - add_task: false, - content: false, - executeSoon: false, - expectUncaughtException: false, - export_assertions: false, - extractJarToTmp: false, - finish: false, - gTestPath: false, - getChromeDir: false, - getJar: false, - getResolvedURI: false, - getRootDirectory: false, - getTestFilePath: false, - ignoreAllUncaughtExceptions: false, - info: false, - is: false, - isnot: false, - ok: false, - record: false, - registerCleanupFunction: false, - requestLongerTimeout: false, - setExpectedFailuresForSelfTest: false, - stringContains: false, - stringMatches: false, - todo: false, - todo_is: false, - todo_isnot: false, - waitForClipboard: false, - waitForExplicitFinish: false, - waitForFocus: false, - }, - - plugins: ["mozilla", "@microsoft/sdl"], - - rules: { - // No using of insecure url, so no http urls - "@microsoft/sdl/no-insecure-url": [ - "error", - { - exceptions: [ - "^http:\\/\\/mochi\\.test?.*", - "^http:\\/\\/localhost?.*", - "^http:\\/\\/127\\.0\\.0\\.1?.*", - // Exempt xmlns urls - "^http:\\/\\/www\\.w3\\.org?.*", - "^http:\\/\\/www\\.mozilla\\.org\\/keymaster\\/gatekeeper?.*", - // Exempt urls that start with ftp or ws. - "^ws:?.*", - "^ftp:?.*", - ], - varExceptions: ["insecure?.*"], - }, - ], - "mozilla/import-content-task-globals": "error", - "mozilla/import-headjs-globals": "error", - "mozilla/mark-test-function-used": "error", - "mozilla/no-addtask-setup": "error", - "mozilla/no-arbitrary-setTimeout": "error", - }, -}; diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/chrome-test.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/chrome-test.js deleted file mode 100644 index 1aa8dc6..0000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/chrome-test.js +++ /dev/null @@ -1,58 +0,0 @@ -// Parent config file for all mochitest files. -"use strict"; - -module.exports = { - env: { - browser: true, - "mozilla/browser-window": true, - }, - - // All globals made available in the test environment. - globals: { - // SpecialPowers is injected into the window object via SimpleTest.js - SpecialPowers: false, - extractJarToTmp: false, - getChromeDir: false, - getJar: false, - getResolvedURI: false, - getRootDirectory: false, - }, - - overrides: [ - { - env: { - // Ideally we wouldn't be using the simpletest env here, but our uses of - // js files mean we pick up everything from the global scope, which could - // be any one of a number of html files. So we just allow the basics... - "mozilla/simpletest": true, - }, - files: ["*.js"], - }, - ], - - plugins: ["mozilla", "@microsoft/sdl"], - - rules: { - // No using of insecure url, so no http urls - "@microsoft/sdl/no-insecure-url": [ - "error", - { - exceptions: [ - "^http:\\/\\/mochi\\.test?.*", - "^http:\\/\\/localhost?.*", - "^http:\\/\\/127\\.0\\.0\\.1?.*", - // Exempt xmlns urls - "^http:\\/\\/www\\.w3\\.org?.*", - "^http:\\/\\/www\\.mozilla\\.org\\/keymaster\\/gatekeeper?.*", - // Exempt urls that start with ftp or ws. - "^ws:?.*", - "^ftp:?.*", - ], - varExceptions: ["insecure?.*"], - }, - ], - "mozilla/import-content-task-globals": "error", - "mozilla/import-headjs-globals": "error", - "mozilla/mark-test-function-used": "error", - }, -}; diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/mochitest-test.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/mochitest-test.js deleted file mode 100644 index c08a6db..0000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/mochitest-test.js +++ /dev/null @@ -1,57 +0,0 @@ -// Parent config file for all mochitest files. -"use strict"; - -module.exports = { - env: { - browser: true, - }, - - // All globals made available in the test environment. - globals: { - // SpecialPowers is injected into the window object via SimpleTest.js - SpecialPowers: false, - XPCNativeWrapper: false, - }, - - overrides: [ - { - env: { - // Ideally we wouldn't be using the simpletest env here, but our uses of - // js files mean we pick up everything from the global scope, which could - // be any one of a number of html files. So we just allow the basics... - "mozilla/simpletest": true, - }, - files: ["*.js"], - }, - ], - plugins: ["mozilla", "@microsoft/sdl"], - - rules: { - // No using of insecure url, so no http urls - "@microsoft/sdl/no-insecure-url": [ - "error", - { - exceptions: [ - "^http:\\/\\/mochi\\.test?.*", - "^http:\\/\\/mochi\\.xorigin-test?.*", - "^http:\\/\\/localhost?.*", - "^http:\\/\\/127\\.0\\.0\\.1?.*", - // Exempt xmlns urls - "^http:\\/\\/www\\.w3\\.org?.*", - "^http:\\/\\/www\\.mozilla\\.org\\/keymaster\\/gatekeeper?.*", - // Exempt urls that start with ftp or ws. - "^ws:?.*", - "^ftp:?.*", - ], - varExceptions: ["insecure?.*"], - }, - ], - "mozilla/import-content-task-globals": "error", - "mozilla/import-headjs-globals": "error", - "mozilla/mark-test-function-used": "error", - // Turn off no-define-cc-etc for mochitests as these don't have Cc etc defined in the - // global scope. - "mozilla/no-define-cc-etc": "off", - "no-shadow": "error", - }, -}; diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js deleted file mode 100644 index 5f05c8a..0000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js +++ /dev/null @@ -1,340 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -"use strict"; - -/** - * The configuration is based on eslint:recommended config. The details for all - * the ESLint rules, and which ones are in the recommended configuration can - * be found here: - * - * https://eslint.org/docs/rules/ - */ -module.exports = { - env: { - browser: true, - es2021: true, - "mozilla/privileged": true, - "mozilla/specific": true, - }, - - extends: ["eslint:recommended", "plugin:prettier/recommended"], - - overrides: [ - { - // System mjs files and jsm files are not loaded in the browser scope, - // so we turn that off for those. Though we do have our own special - // environment for them. - env: { - browser: false, - "mozilla/jsm": true, - }, - files: ["**/*.sys.mjs", "**/*.jsm", "**/*.jsm.js"], - rules: { - "mozilla/lazy-getter-object-name": "error", - "mozilla/reject-eager-module-in-lazy-getter": "error", - "mozilla/reject-global-this": "error", - "mozilla/reject-globalThis-modification": "error", - // For all system modules, we expect no properties to need importing, - // hence reject everything. - "mozilla/reject-importGlobalProperties": ["error", "everything"], - "mozilla/reject-mixing-eager-and-lazy": "error", - "mozilla/reject-top-level-await": "error", - // TODO: Bug 1575506 turn `builtinGlobals` on here. - // We can enable builtinGlobals for jsms due to their scopes. - "no-redeclare": ["error", { builtinGlobals: false }], - }, - }, - { - files: ["**/*.mjs", "**/*.jsm"], - rules: { - // Modules are far easier to check for no-unused-vars on a global scope, - // than our content files. Hence we turn that on here. - "no-unused-vars": [ - "error", - { - args: "none", - vars: "all", - }, - ], - }, - }, - { - excludedFiles: ["**/*.sys.mjs"], - files: ["**/*.mjs"], - rules: { - "mozilla/reject-import-system-module-from-non-system": "error", - "mozilla/reject-lazy-imports-into-globals": "error", - }, - }, - { - files: ["**/*.mjs"], - rules: { - // This rule defaults to not allowing "use strict" in module files since - // they are always loaded in strict mode. - strict: "error", - }, - }, - { - files: ["**/*.jsm", "**/*.jsm.js"], - rules: { - "mozilla/mark-exported-symbols-as-used": "error", - }, - }, - { - env: { - browser: false, - "mozilla/privileged": false, - "mozilla/sjs": true, - }, - files: ["**/*.sjs"], - rules: { - // TODO Bug 1501127: sjs files have their own sandbox, and do not inherit - // the Window backstage pass directly. Turn this rule off for sjs files for - // now until we develop a solution. - "mozilla/reject-importGlobalProperties": "off", - }, - }, - ], - - parserOptions: { - ecmaVersion: 12, - }, - - // When adding items to this file please check for effects on sub-directories. - plugins: ["html", "fetch-options", "no-unsanitized"], - - // When adding items to this file please check for effects on all of toolkit - // and browser - rules: { - // Warn about cyclomatic complexity in functions. - // XXX Get this down to 20? - complexity: ["error", 34], - - // Functions must always return something or nothing - "consistent-return": "error", - - // XXX This rule line should be removed to enable it. See bug 1487642. - // Require super() calls in constructors - "constructor-super": "off", - - // Require braces around blocks that start a new line - curly: ["error", "all"], - - // Encourage the use of dot notation whenever possible. - "dot-notation": "error", - - // XXX This rule should be enabled, see Bug 1557040 - // No credentials submitted with fetch calls - "fetch-options/no-fetch-credentials": "off", - - // XXX This rule line should be removed to enable it. See bug 1487642. - // Enforce return statements in getters - "getter-return": "off", - - // Don't enforce the maximum depth that blocks can be nested. The complexity - // rule is a better rule to check this. - "max-depth": "off", - - // Maximum depth callbacks can be nested. - "max-nested-callbacks": ["error", 10], - - "mozilla/avoid-removeChild": "error", - "mozilla/consistent-if-bracing": "error", - "mozilla/import-browser-window-globals": "error", - "mozilla/import-globals": "error", - "mozilla/no-compare-against-boolean-literals": "error", - "mozilla/no-define-cc-etc": "error", - "mozilla/no-throw-cr-literal": "error", - "mozilla/no-useless-parameters": "error", - "mozilla/no-useless-removeEventListener": "error", - "mozilla/prefer-boolean-length-check": "error", - "mozilla/prefer-formatValues": "error", - "mozilla/reject-addtask-only": "error", - "mozilla/reject-chromeutils-import-params": "error", - "mozilla/reject-importGlobalProperties": ["error", "allownonwebidl"], - "mozilla/reject-multiple-getters-calls": "error", - "mozilla/reject-osfile": "warn", - "mozilla/reject-scriptableunicodeconverter": "warn", - "mozilla/rejects-requires-await": "error", - "mozilla/use-cc-etc": "error", - "mozilla/use-chromeutils-generateqi": "error", - "mozilla/use-chromeutils-import": "error", - "mozilla/use-default-preference-values": "error", - "mozilla/use-includes-instead-of-indexOf": "error", - "mozilla/use-isInstance": "error", - "mozilla/use-ownerGlobal": "error", - "mozilla/use-returnValue": "error", - "mozilla/use-services": "error", - "mozilla/valid-lazy": "error", - "mozilla/valid-services": "error", - - // Use [] instead of Array() - "no-array-constructor": "error", - - // Disallow use of arguments.caller or arguments.callee. - "no-caller": "error", - - // XXX Bug 1487642 - decide if we want to enable this or not. - // Disallow lexical declarations in case clauses - "no-case-declarations": "off", - - // XXX Bug 1487642 - decide if we want to enable this or not. - // Disallow the use of console - "no-console": "off", - - // Disallows expressions where the operation doesn't affect the value. - "no-constant-binary-expression": "error", - - // XXX Bug 1487642 - decide if we want to enable this or not. - // Disallow constant expressions in conditions - "no-constant-condition": "off", - - // No duplicate keys in object declarations - "no-dupe-keys": "error", - - // If an if block ends with a return no need for an else block - "no-else-return": "error", - - // No empty statements - "no-empty": ["error", { allowEmptyCatch: true }], - - // Disallow eval and setInteral/setTimeout with strings - "no-eval": "error", - - // Disallow unnecessary calls to .bind() - "no-extra-bind": "error", - - // Disallow fallthrough of case statements - "no-fallthrough": [ - "error", - { - // The eslint rule doesn't allow for case-insensitive regex option. - // The following pattern allows for a dash between "fall through" as - // well as alternate spelling of "fall thru". The pattern also allows - // for an optional "s" at the end of "fall" ("falls through"). - commentPattern: - "[Ff][Aa][Ll][Ll][Ss]?[\\s-]?([Tt][Hh][Rr][Oo][Uu][Gg][Hh]|[Tt][Hh][Rr][Uu])", - }, - ], - - // Disallow assignments to native objects or read-only global variables - "no-global-assign": "error", - - // Disallow eval and setInteral/setTimeout with strings - "no-implied-eval": "error", - - // This has been superseded since we're using ES6. - // Disallow variable or function declarations in nested blocks - "no-inner-declarations": "off", - - // Disallow the use of the __iterator__ property - "no-iterator": "error", - - // No labels - "no-labels": "error", - - // Disallow unnecessary nested blocks - "no-lone-blocks": "error", - - // No single if block inside an else block - "no-lonely-if": "error", - - // Disallow the use of number literals that immediately lose precision at runtime when converted to JS Number - "no-loss-of-precision": "error", - - // Nested ternary statements are confusing - "no-nested-ternary": "error", - - // Use {} instead of new Object() - "no-new-object": "error", - - // Disallow use of new wrappers - "no-new-wrappers": "error", - - // We don't want this, see bug 1551829 - "no-prototype-builtins": "off", - - // Disable builtinGlobals for no-redeclare as this conflicts with our - // globals declarations especially for browser window. - "no-redeclare": ["error", { builtinGlobals: false }], - - // Disallow use of event global. - "no-restricted-globals": ["error", "event"], - - // Disallows unnecessary `return await ...`. - "no-return-await": "error", - - // No unnecessary comparisons - "no-self-compare": "error", - - // No comma sequenced statements - "no-sequences": "error", - - // No declaring variables from an outer scope - // "no-shadow": "error", - - // No declaring variables that hide things like arguments - "no-shadow-restricted-names": "error", - - // Disallow throwing literals (eg. throw "error" instead of - // throw new Error("error")). - "no-throw-literal": "error", - - // Disallow the use of Boolean literals in conditional expressions. - "no-unneeded-ternary": "error", - - // No unsanitized use of innerHTML=, document.write() etc. - // cf. https://github.com/mozilla/eslint-plugin-no-unsanitized#rule-details - "no-unsanitized/method": "error", - "no-unsanitized/property": "error", - - // No declaring variables that are never used - "no-unused-vars": [ - "error", - { - args: "none", - vars: "local", - }, - ], - - // No using variables before defined - // "no-use-before-define": ["error", "nofunc"], - - // Disallow unnecessary .call() and .apply() - "no-useless-call": "error", - - // Don't concatenate string literals together (unless they span multiple - // lines) - "no-useless-concat": "error", - - // XXX Bug 1487642 - decide if we want to enable this or not. - // Disallow unnecessary escape characters - "no-useless-escape": "off", - - // Disallow redundant return statements - "no-useless-return": "error", - - // No using with - "no-with": "error", - - // Require object-literal shorthand with ES6 method syntax - "object-shorthand": ["error", "always", { avoidQuotes: true }], - - // This generates too many false positives that are not easy to work around, - // and false positives seem to be inherent in the rule. - "require-atomic-updates": "off", - - // XXX Bug 1487642 - decide if we want to enable this or not. - // Require generator functions to contain yield - "require-yield": "off", - }, - - // To avoid bad interactions of the html plugin with the xml preprocessor in - // eslint-plugin-mozilla, we turn off processing of the html plugin for .xml - // files. - settings: { - "html/xml-extensions": [".xhtml"], - }, -}; diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/xpcshell-test.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/xpcshell-test.js deleted file mode 100644 index 492ecc1..0000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/xpcshell-test.js +++ /dev/null @@ -1,50 +0,0 @@ -// Parent config file for all xpcshell files. -"use strict"; - -module.exports = { - env: { - browser: false, - "mozilla/privileged": true, - "mozilla/xpcshell": true, - }, - - overrides: [ - { - // If it is a head file, we turn off global unused variable checks, as it - // would require searching the other test files to know if they are used or not. - // This would be expensive and slow, and it isn't worth it for head files. - // We could get developers to declare as exported, but that doesn't seem worth it. - files: "head*.js", - rules: { - "no-unused-vars": [ - "error", - { - args: "none", - vars: "local", - }, - ], - }, - }, - { - // No declaring variables that are never used - files: "test*.js", - rules: { - "no-unused-vars": [ - "error", - { - args: "none", - vars: "all", - }, - ], - }, - }, - ], - - rules: { - "mozilla/import-headjs-globals": "error", - "mozilla/mark-test-function-used": "error", - "mozilla/no-arbitrary-setTimeout": "error", - "mozilla/no-useless-run-test": "error", - "no-shadow": "error", - }, -}; diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/browser-window.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/browser-window.js deleted file mode 100644 index c24943e..0000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/browser-window.js +++ /dev/null @@ -1,116 +0,0 @@ -/** - * @fileoverview Defines the environment when in the browser.xhtml window. - * Imports many globals from various files. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -"use strict"; - -// ----------------------------------------------------------------------------- -// Rule Definition -// ----------------------------------------------------------------------------- - -var fs = require("fs"); -var helpers = require("../helpers"); -var { getScriptGlobals } = require("./utils"); - -// When updating EXTRA_SCRIPTS or MAPPINGS, be sure to also update the -// 'support-files' config in `tools/lint/eslint.yml`. - -// These are scripts not loaded from browser.xhtml or global-scripts.inc -// but via other includes. -const EXTRA_SCRIPTS = [ - "browser/base/content/nsContextMenu.js", - "browser/components/downloads/content/downloads.js", - "browser/components/downloads/content/indicator.js", - "toolkit/content/customElements.js", - "toolkit/content/editMenuOverlay.js", -]; - -const extraDefinitions = [ - // Via Components.utils, defineModuleGetter, defineLazyModuleGetters or - // defineLazyScriptGetter (and map to - // single) variable. - { name: "XPCOMUtils", writable: false }, - { name: "Task", writable: false }, - { name: "windowGlobalChild", writable: false }, - // structuredClone is a new global that would be defined for the `browser` - // environment in ESLint, but only Firefox has implemented it currently and so - // it isn't in ESLint's globals yet. - // https://developer.mozilla.org/docs/Web/API/structuredClone - { name: "structuredClone", writable: false }, -]; - -// Some files in global-scripts.inc need mapping to specific locations. -const MAPPINGS = { - "printUtils.js": "toolkit/components/printing/content/printUtils.js", - "panelUI.js": "browser/components/customizableui/content/panelUI.js", - "viewSourceUtils.js": - "toolkit/components/viewsource/content/viewSourceUtils.js", - "places-tree.js": "browser/components/places/content/places-tree.js", - "places-menupopup.js": - "browser/components/places/content/places-menupopup.js", -}; - -const globalScriptsRegExp = /^\s*Services.scriptloader.loadSubScript\(\"(.*?)\", this\);$/; - -function getGlobalScriptIncludes(scriptPath) { - let fileData; - try { - fileData = fs.readFileSync(scriptPath, { encoding: "utf8" }); - } catch (ex) { - // The file isn't present, so this isn't an m-c repository. - return null; - } - - fileData = fileData.split("\n"); - - let result = []; - - for (let line of fileData) { - let match = line.match(globalScriptsRegExp); - if (match) { - let sourceFile = match[1] - .replace( - "chrome://browser/content/search/", - "browser/components/search/content/" - ) - .replace( - "chrome://browser/content/screenshots/", - "browser/components/screenshots/content/" - ) - .replace("chrome://browser/content/", "browser/base/content/") - .replace("chrome://global/content/", "toolkit/content/"); - - for (let mapping of Object.getOwnPropertyNames(MAPPINGS)) { - if (sourceFile.includes(mapping)) { - sourceFile = MAPPINGS[mapping]; - } - } - - result.push(sourceFile); - } - } - - return result; -} - -function getGlobalScripts() { - let results = []; - for (let scriptPath of helpers.globalScriptPaths) { - results = results.concat(getGlobalScriptIncludes(scriptPath)); - } - return results; -} - -module.exports = getScriptGlobals( - "browser-window", - getGlobalScripts().concat(EXTRA_SCRIPTS), - extraDefinitions, - { - browserjsScripts: getGlobalScripts().concat(EXTRA_SCRIPTS), - } -); diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/chrome-script.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/chrome-script.js deleted file mode 100644 index e92db62..0000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/chrome-script.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @fileoverview Defines the environment for SpecialPowers chrome script. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -"use strict"; - -var { globals } = require("./special-powers-sandbox"); -var util = require("util"); - -module.exports = { - globals: util._extend( - { - // testing/specialpowers/content/SpecialPowersParent.jsm - - // SPLoadChromeScript block - createWindowlessBrowser: false, - sendAsyncMessage: false, - addMessageListener: false, - removeMessageListener: false, - actorParent: false, - }, - globals - ), -}; diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/chrome-worker.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/chrome-worker.js deleted file mode 100644 index db5759b..0000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/chrome-worker.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @fileoverview Defines the environment for chrome workers. This differs - * from normal workers by the fact that `ctypes` can be accessed - * as well. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -"use strict"; - -var globals = require("globals"); -var util = require("util"); - -var workerGlobals = util._extend( - { - ctypes: false, - }, - globals.worker -); - -module.exports = { - globals: workerGlobals, -}; diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/frame-script.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/frame-script.js deleted file mode 100644 index 7ac5c94..0000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/frame-script.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @fileoverview Defines the environment for frame scripts. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -"use strict"; - -module.exports = { - globals: { - // dom/chrome-webidl/MessageManager.webidl - - // MessageManagerGlobal - dump: false, - atob: false, - btoa: false, - - // MessageListenerManagerMixin - addMessageListener: false, - removeMessageListener: false, - addWeakMessageListener: false, - removeWeakMessageListener: false, - - // MessageSenderMixin - sendAsyncMessage: false, - processMessageManager: false, - remoteType: false, - - // SyncMessageSenderMixin - sendSyncMessage: false, - - // ContentFrameMessageManager - content: false, - docShell: false, - tabEventTarget: false, - }, -}; diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/jsm.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/jsm.js deleted file mode 100644 index 1ff73c0..0000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/jsm.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @fileoverview Defines the environment for jsm files. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -"use strict"; - -module.exports = { - globals: { - // These globals are hard-coded and available in .jsm scopes. - // https://searchfox.org/mozilla-central/rev/dcb0cfb66e4ed3b9c7fbef1e80572426ff5f3c3a/js/xpconnect/loader/mozJSModuleLoader.cpp#222-223 - // Although `debug` is allowed for jsm files, this is non-standard and something - // we don't want to allow in mjs files. Hence it is not included here. - atob: false, - btoa: false, - dump: false, - // The WebAssembly global is available in most (if not all) contexts where - // JS can run. It's definitely available in JSMs. So even if this is not - // the perfect place to add it, it's not wrong, and we can move it later. - WebAssembly: false, - // These are hard-coded and available in .jsm scopes. - // See BackstagePass::Resolve. - fetch: false, - crypto: false, - indexedDB: false, - structuredClone: false, - }, -}; diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/privileged.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/privileged.js deleted file mode 100644 index c35e727..0000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/privileged.js +++ /dev/null @@ -1,804 +0,0 @@ -/** - * @fileoverview Defines the environment for privileges JS files. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -"use strict"; - -module.exports = { - globals: { - // Intl and WebAssembly are available everywhere but are not webIDL definitions. - Intl: false, - WebAssembly: false, - // This list of items is currently obtained manually from the list of - // mozilla::dom::constructor::id::ID enumerations in an object directory - // generated dom/bindings/RegisterBindings.cpp - APZHitResultFlags: false, - AbortController: false, - AbortSignal: false, - AccessibleNode: false, - Addon: false, - AddonEvent: false, - AddonInstall: false, - AddonManager: true, - AddonManagerPermissions: false, - AnalyserNode: false, - Animation: false, - AnimationEffect: false, - AnimationEvent: false, - AnimationPlaybackEvent: false, - AnimationTimeline: false, - AnonymousContent: false, - Attr: false, - AudioBuffer: false, - AudioBufferSourceNode: false, - AudioContext: false, - AudioDestinationNode: false, - AudioListener: false, - AudioNode: false, - AudioParam: false, - AudioParamMap: false, - AudioProcessingEvent: false, - AudioScheduledSourceNode: false, - AudioTrack: false, - AudioTrackList: false, - AudioWorklet: false, - AudioWorkletNode: false, - AuthenticatorAssertionResponse: false, - AuthenticatorAttestationResponse: false, - AuthenticatorResponse: false, - BarProp: false, - BaseAudioContext: false, - BatteryManager: false, - BeforeUnloadEvent: false, - BiquadFilterNode: false, - Blob: false, - BlobEvent: false, - BoxObject: false, - BroadcastChannel: false, - BrowsingContext: false, - ByteLengthQueuingStrategy: false, - CanonicalBrowsingContext: false, - CDATASection: false, - CSS: false, - CSS2Properties: false, - CSSAnimation: false, - CSSConditionRule: false, - CSSCounterStyleRule: false, - CSSFontFaceRule: false, - CSSFontFeatureValuesRule: false, - CSSGroupingRule: false, - CSSImportRule: false, - CSSKeyframeRule: false, - CSSKeyframesRule: false, - CSSMediaRule: false, - CSSMozDocumentRule: false, - CSSNamespaceRule: false, - CSSPageRule: false, - CSSPseudoElement: false, - CSSRule: false, - CSSRuleList: false, - CSSStyleDeclaration: false, - CSSStyleRule: false, - CSSStyleSheet: false, - CSSSupportsRule: false, - CSSTransition: false, - Cache: false, - CacheStorage: false, - CanvasCaptureMediaStream: false, - CanvasGradient: false, - CanvasPattern: false, - CanvasRenderingContext2D: false, - CaretPosition: false, - CaretStateChangedEvent: false, - ChannelMergerNode: false, - ChannelSplitterNode: false, - ChannelWrapper: false, - CharacterData: false, - CheckerboardReportService: false, - ChildProcessMessageManager: false, - ChildSHistory: false, - ChromeMessageBroadcaster: false, - ChromeMessageSender: false, - ChromeNodeList: false, - ChromeUtils: false, - ChromeWorker: false, - Clipboard: false, - ClipboardEvent: false, - ClonedErrorHolder: false, - CloseEvent: false, - CommandEvent: false, - Comment: false, - CompositionEvent: false, - ConsoleInstance: false, - ConstantSourceNode: false, - ContentFrameMessageManager: false, - ContentProcessMessageManager: false, - ConvolverNode: false, - CountQueuingStrategy: false, - CreateOfferRequest: false, - Credential: false, - CredentialsContainer: false, - Crypto: false, - CryptoKey: false, - CustomElementRegistry: false, - CustomEvent: false, - DOMError: false, - DOMException: false, - DOMImplementation: false, - DOMLocalization: false, - DOMMatrix: false, - DOMMatrixReadOnly: false, - DOMParser: false, - DOMPoint: false, - DOMPointReadOnly: false, - DOMQuad: false, - DOMRect: false, - DOMRectList: false, - DOMRectReadOnly: false, - DOMRequest: false, - DOMStringList: false, - DOMStringMap: false, - DOMTokenList: false, - DataTransfer: false, - DataTransferItem: false, - DataTransferItemList: false, - DelayNode: false, - DeprecationReportBody: false, - DeviceLightEvent: false, - DeviceMotionEvent: false, - DeviceOrientationEvent: false, - DeviceProximityEvent: false, - Directory: false, - Document: false, - DocumentFragment: false, - DocumentTimeline: false, - DocumentType: false, - DominatorTree: false, - DragEvent: false, - DynamicsCompressorNode: false, - Element: false, - ErrorEvent: false, - Event: false, - EventSource: false, - EventTarget: false, - FeaturePolicyViolationReportBody: false, - FetchObserver: false, - File: false, - FileList: false, - FileReader: false, - FileSystem: false, - FileSystemDirectoryEntry: false, - FileSystemDirectoryReader: false, - FileSystemEntry: false, - FileSystemFileEntry: false, - Flex: false, - FlexItemValues: false, - FlexLineValues: false, - FluentBundle: false, - FluentResource: false, - FocusEvent: false, - FontFace: false, - FontFaceSet: false, - FontFaceSetLoadEvent: false, - FormData: false, - FrameCrashedEvent: false, - FrameLoader: false, - GainNode: false, - Gamepad: false, - GamepadAxisMoveEvent: false, - GamepadButton: false, - GamepadButtonEvent: false, - GamepadEvent: false, - GamepadHapticActuator: false, - GamepadPose: false, - GamepadServiceTest: false, - Glean: false, - GleanPings: false, - Grid: false, - GridArea: false, - GridDimension: false, - GridLine: false, - GridLines: false, - GridTrack: false, - GridTracks: false, - HTMLAllCollection: false, - HTMLAnchorElement: false, - HTMLAreaElement: false, - HTMLAudioElement: false, - Audio: false, - HTMLBRElement: false, - HTMLBaseElement: false, - HTMLBodyElement: false, - HTMLButtonElement: false, - HTMLCanvasElement: false, - HTMLCollection: false, - HTMLDListElement: false, - HTMLDataElement: false, - HTMLDataListElement: false, - HTMLDetailsElement: false, - HTMLDialogElement: false, - HTMLDirectoryElement: false, - HTMLDivElement: false, - HTMLDocument: false, - HTMLElement: false, - HTMLEmbedElement: false, - HTMLFieldSetElement: false, - HTMLFontElement: false, - HTMLFormControlsCollection: false, - HTMLFormElement: false, - HTMLFrameElement: false, - HTMLFrameSetElement: false, - HTMLHRElement: false, - HTMLHeadElement: false, - HTMLHeadingElement: false, - HTMLHtmlElement: false, - HTMLIFrameElement: false, - HTMLImageElement: false, - Image: false, - HTMLInputElement: false, - HTMLLIElement: false, - HTMLLabelElement: false, - HTMLLegendElement: false, - HTMLLinkElement: false, - HTMLMapElement: false, - HTMLMarqueeElement: false, - HTMLMediaElement: false, - HTMLMenuElement: false, - HTMLMenuItemElement: false, - HTMLMetaElement: false, - HTMLMeterElement: false, - HTMLModElement: false, - HTMLOListElement: false, - HTMLObjectElement: false, - HTMLOptGroupElement: false, - HTMLOptionElement: false, - Option: false, - HTMLOptionsCollection: false, - HTMLOutputElement: false, - HTMLParagraphElement: false, - HTMLParamElement: false, - HTMLPictureElement: false, - HTMLPreElement: false, - HTMLProgressElement: false, - HTMLQuoteElement: false, - HTMLScriptElement: false, - HTMLSelectElement: false, - HTMLSlotElement: false, - HTMLSourceElement: false, - HTMLSpanElement: false, - HTMLStyleElement: false, - HTMLTableCaptionElement: false, - HTMLTableCellElement: false, - HTMLTableColElement: false, - HTMLTableElement: false, - HTMLTableRowElement: false, - HTMLTableSectionElement: false, - HTMLTemplateElement: false, - HTMLTextAreaElement: false, - HTMLTimeElement: false, - HTMLTitleElement: false, - HTMLTrackElement: false, - HTMLUListElement: false, - HTMLUnknownElement: false, - HTMLVideoElement: false, - HashChangeEvent: false, - Headers: false, - HeapSnapshot: false, - History: false, - IDBCursor: false, - IDBCursorWithValue: false, - IDBDatabase: false, - IDBFactory: false, - IDBFileHandle: false, - IDBFileRequest: false, - IDBIndex: false, - IDBKeyRange: false, - IDBLocaleAwareKeyRange: false, - IDBMutableFile: false, - IDBObjectStore: false, - IDBOpenDBRequest: false, - IDBRequest: false, - IDBTransaction: false, - IDBVersionChangeEvent: false, - IIRFilterNode: false, - IdleDeadline: false, - ImageBitmap: false, - ImageBitmapRenderingContext: false, - ImageCapture: false, - ImageCaptureErrorEvent: false, - ImageData: false, - ImageDocument: false, - InputEvent: false, - InspectorFontFace: false, - InspectorUtils: false, - InstallTriggerImpl: false, - IntersectionObserver: false, - IntersectionObserverEntry: false, - IOUtils: false, - JSProcessActorChild: false, - JSProcessActorParent: false, - JSWindowActorChild: false, - JSWindowActorParent: false, - KeyEvent: false, - KeyboardEvent: false, - KeyframeEffect: false, - L10nFileSource: false, - L10nRegistry: false, - Localization: false, - Location: false, - MIDIAccess: false, - MIDIConnectionEvent: false, - MIDIInput: false, - MIDIInputMap: false, - MIDIMessageEvent: false, - MIDIOutput: false, - MIDIOutputMap: false, - MIDIPort: false, - MatchGlob: false, - MatchPattern: false, - MatchPatternSet: false, - MediaCapabilities: false, - MediaCapabilitiesInfo: false, - MediaControlService: false, - MediaDeviceInfo: false, - MediaDevices: false, - MediaElementAudioSourceNode: false, - MediaEncryptedEvent: false, - MediaError: false, - MediaKeyError: false, - MediaKeyMessageEvent: false, - MediaKeySession: false, - MediaKeyStatusMap: false, - MediaKeySystemAccess: false, - MediaKeys: false, - MediaList: false, - MediaQueryList: false, - MediaQueryListEvent: false, - MediaRecorder: false, - MediaRecorderErrorEvent: false, - MediaSource: false, - MediaStream: false, - MediaStreamAudioDestinationNode: false, - MediaStreamAudioSourceNode: false, - MediaStreamEvent: false, - MediaStreamTrack: false, - MediaStreamTrackEvent: false, - MerchantValidationEvent: false, - MessageBroadcaster: false, - MessageChannel: false, - MessageEvent: false, - MessageListenerManager: false, - MessagePort: false, - MessageSender: false, - MimeType: false, - MimeTypeArray: false, - MouseEvent: false, - MouseScrollEvent: false, - MozCanvasPrintState: false, - MozDocumentMatcher: false, - MozDocumentObserver: false, - MozQueryInterface: false, - MozSharedMap: false, - MozSharedMapChangeEvent: false, - MozStorageAsyncStatementParams: false, - MozStorageStatementParams: false, - MozStorageStatementRow: false, - MozWritableSharedMap: false, - MutationEvent: false, - MutationObserver: false, - MutationRecord: false, - NamedNodeMap: false, - Navigator: false, - NetworkInformation: false, - Node: false, - NodeFilter: false, - NodeIterator: false, - NodeList: false, - Notification: false, - NotifyPaintEvent: false, - OfflineAudioCompletionEvent: false, - OfflineAudioContext: false, - OfflineResourceList: false, - OffscreenCanvas: false, - OscillatorNode: false, - PageTransitionEvent: false, - PaintRequest: false, - PaintRequestList: false, - PannerNode: false, - ParentProcessMessageManager: false, - Path2D: false, - PathUtils: false, - PaymentAddress: false, - PaymentMethodChangeEvent: false, - PaymentRequest: false, - PaymentRequestUpdateEvent: false, - PaymentResponse: false, - PeerConnectionImpl: false, - PeerConnectionObserver: false, - Performance: false, - PerformanceEntry: false, - PerformanceEntryEvent: false, - PerformanceMark: false, - PerformanceMeasure: false, - PerformanceNavigation: false, - PerformanceNavigationTiming: false, - PerformanceObserver: false, - PerformanceObserverEntryList: false, - PerformanceResourceTiming: false, - PerformanceServerTiming: false, - PerformanceTiming: false, - PeriodicWave: false, - PermissionStatus: false, - Permissions: false, - PlacesBookmark: false, - PlacesBookmarkAddition: false, - PlacesBookmarkGuid: false, - PlacesBookmarkMoved: false, - PlacesBookmarkRemoved: false, - PlacesBookmarkTags: false, - PlacesBookmarkTime: false, - PlacesBookmarkTitle: false, - PlacesBookmarkUrl: false, - PlacesEvent: false, - PlacesHistoryCleared: false, - PlacesObservers: false, - PlacesPurgeCaches: false, - PlacesRanking: false, - PlacesVisit: false, - PlacesVisitRemoved: false, - PlacesVisitTitle: false, - PlacesWeakCallbackWrapper: false, - Plugin: false, - PluginArray: false, - PluginCrashedEvent: false, - PointerEvent: false, - PopStateEvent: false, - PopupBlockedEvent: false, - PrecompiledScript: false, - Presentation: false, - PresentationAvailability: false, - PresentationConnection: false, - PresentationConnectionAvailableEvent: false, - PresentationConnectionCloseEvent: false, - PresentationConnectionList: false, - PresentationReceiver: false, - PresentationRequest: false, - PrioEncoder: false, - ProcessMessageManager: false, - ProcessingInstruction: false, - ProgressEvent: false, - PromiseDebugging: false, - PromiseRejectionEvent: false, - PublicKeyCredential: false, - PushManager: false, - PushManagerImpl: false, - PushSubscription: false, - PushSubscriptionOptions: false, - RTCCertificate: false, - RTCDTMFSender: false, - RTCDTMFToneChangeEvent: false, - RTCDataChannel: false, - RTCDataChannelEvent: false, - RTCIceCandidate: false, - RTCPeerConnection: false, - RTCPeerConnectionIceEvent: false, - RTCPeerConnectionStatic: false, - RTCRtpReceiver: false, - RTCRtpSender: false, - RTCRtpTransceiver: false, - RTCSessionDescription: false, - RTCStatsReport: false, - RTCTrackEvent: false, - RadioNodeList: false, - Range: false, - ReadableStreamBYOBReader: false, - ReadableStreamBYOBRequest: false, - ReadableByteStreamController: false, - ReadableStream: false, - ReadableStreamDefaultController: false, - ReadableStreamDefaultReader: false, - Report: false, - ReportBody: false, - ReportingObserver: false, - Request: false, - Response: false, - SessionStoreUtils: false, - SVGAElement: false, - SVGAngle: false, - SVGAnimateElement: false, - SVGAnimateMotionElement: false, - SVGAnimateTransformElement: false, - SVGAnimatedAngle: false, - SVGAnimatedBoolean: false, - SVGAnimatedEnumeration: false, - SVGAnimatedInteger: false, - SVGAnimatedLength: false, - SVGAnimatedLengthList: false, - SVGAnimatedNumber: false, - SVGAnimatedNumberList: false, - SVGAnimatedPreserveAspectRatio: false, - SVGAnimatedRect: false, - SVGAnimatedString: false, - SVGAnimatedTransformList: false, - SVGAnimationElement: false, - SVGCircleElement: false, - SVGClipPathElement: false, - SVGComponentTransferFunctionElement: false, - SVGDefsElement: false, - SVGDescElement: false, - SVGElement: false, - SVGEllipseElement: false, - SVGFEBlendElement: false, - SVGFEColorMatrixElement: false, - SVGFEComponentTransferElement: false, - SVGFECompositeElement: false, - SVGFEConvolveMatrixElement: false, - SVGFEDiffuseLightingElement: false, - SVGFEDisplacementMapElement: false, - SVGFEDistantLightElement: false, - SVGFEDropShadowElement: false, - SVGFEFloodElement: false, - SVGFEFuncAElement: false, - SVGFEFuncBElement: false, - SVGFEFuncGElement: false, - SVGFEFuncRElement: false, - SVGFEGaussianBlurElement: false, - SVGFEImageElement: false, - SVGFEMergeElement: false, - SVGFEMergeNodeElement: false, - SVGFEMorphologyElement: false, - SVGFEOffsetElement: false, - SVGFEPointLightElement: false, - SVGFESpecularLightingElement: false, - SVGFESpotLightElement: false, - SVGFETileElement: false, - SVGFETurbulenceElement: false, - SVGFilterElement: false, - SVGForeignObjectElement: false, - SVGGElement: false, - SVGGeometryElement: false, - SVGGradientElement: false, - SVGGraphicsElement: false, - SVGImageElement: false, - SVGLength: false, - SVGLengthList: false, - SVGLineElement: false, - SVGLinearGradientElement: false, - SVGMPathElement: false, - SVGMarkerElement: false, - SVGMaskElement: false, - SVGMatrix: false, - SVGMetadataElement: false, - SVGNumber: false, - SVGNumberList: false, - SVGPathElement: false, - SVGPathSegList: false, - SVGPatternElement: false, - SVGPoint: false, - SVGPointList: false, - SVGPolygonElement: false, - SVGPolylineElement: false, - SVGPreserveAspectRatio: false, - SVGRadialGradientElement: false, - SVGRect: false, - SVGRectElement: false, - SVGSVGElement: false, - SVGScriptElement: false, - SVGSetElement: false, - SVGStopElement: false, - SVGStringList: false, - SVGStyleElement: false, - SVGSwitchElement: false, - SVGSymbolElement: false, - SVGTSpanElement: false, - SVGTextContentElement: false, - SVGTextElement: false, - SVGTextPathElement: false, - SVGTextPositioningElement: false, - SVGTitleElement: false, - SVGTransform: false, - SVGTransformList: false, - SVGUnitTypes: false, - SVGUseElement: false, - SVGViewElement: false, - SVGZoomAndPan: false, - Screen: false, - ScreenLuminance: false, - ScreenOrientation: false, - ScriptProcessorNode: false, - ScrollAreaEvent: false, - ScrollViewChangeEvent: false, - SecurityPolicyViolationEvent: false, - Selection: false, - ServiceWorker: false, - ServiceWorkerContainer: false, - ServiceWorkerRegistration: false, - ShadowRoot: false, - SharedWorker: false, - SimpleGestureEvent: false, - SourceBuffer: false, - SourceBufferList: false, - SpeechGrammar: false, - SpeechGrammarList: false, - SpeechRecognition: false, - SpeechRecognitionAlternative: false, - SpeechRecognitionError: false, - SpeechRecognitionEvent: false, - SpeechRecognitionResult: false, - SpeechRecognitionResultList: false, - SpeechSynthesis: false, - SpeechSynthesisErrorEvent: false, - SpeechSynthesisEvent: false, - SpeechSynthesisUtterance: false, - SpeechSynthesisVoice: false, - StereoPannerNode: false, - Storage: false, - StorageEvent: false, - StorageManager: false, - StreamFilter: false, - StreamFilterDataEvent: false, - StructuredCloneHolder: false, - StructuredCloneTester: false, - StyleSheet: false, - StyleSheetApplicableStateChangeEvent: false, - StyleSheetList: false, - SubtleCrypto: false, - SyncMessageSender: false, - TCPServerSocket: false, - TCPServerSocketEvent: false, - TCPSocket: false, - TCPSocketErrorEvent: false, - TCPSocketEvent: false, - TelemetryStopwatch: false, - TestingDeprecatedInterface: false, - Text: false, - TextClause: false, - TextDecoder: false, - TextEncoder: false, - TextMetrics: false, - TextTrack: false, - TextTrackCue: false, - TextTrackCueList: false, - TextTrackList: false, - TimeEvent: false, - TimeRanges: false, - Touch: false, - TouchEvent: false, - TouchList: false, - TrackEvent: false, - TransceiverImpl: false, - TransformStream: false, - TransformStreamDefaultController: false, - TransitionEvent: false, - TreeColumn: false, - TreeColumns: false, - TreeContentView: false, - TreeWalker: false, - U2F: false, - UDPMessageEvent: false, - UDPSocket: false, - UIEvent: false, - URL: false, - URLSearchParams: false, - UserInteraction: false, - UserProximityEvent: false, - VRDisplay: false, - VRDisplayCapabilities: false, - VRDisplayEvent: false, - VREyeParameters: false, - VRFieldOfView: false, - VRFrameData: false, - VRMockController: false, - VRMockDisplay: false, - VRPose: false, - VRServiceTest: false, - VRStageParameters: false, - VRSubmitFrameResult: false, - VTTCue: false, - VTTRegion: false, - ValidityState: false, - VideoPlaybackQuality: false, - VideoTrack: false, - VideoTrackList: false, - VisualViewport: false, - WaveShaperNode: false, - WebExtensionContentScript: false, - WebExtensionPolicy: false, - WebGL2RenderingContext: false, - WebGLActiveInfo: false, - WebGLBuffer: false, - WebGLContextEvent: false, - WebGLFramebuffer: false, - WebGLProgram: false, - WebGLQuery: false, - WebGLRenderbuffer: false, - WebGLRenderingContext: false, - WebGLSampler: false, - WebGLShader: false, - WebGLShaderPrecisionFormat: false, - WebGLSync: false, - WebGLTexture: false, - WebGLTransformFeedback: false, - WebGLUniformLocation: false, - WebGLVertexArrayObject: false, - WebGPU: false, - WebGPUAdapter: false, - WebGPUAttachmentState: false, - WebGPUBindGroup: false, - WebGPUBindGroupLayout: false, - WebGPUBindingType: false, - WebGPUBlendFactor: false, - WebGPUBlendOperation: false, - WebGPUBlendState: false, - WebGPUBuffer: false, - WebGPUBufferUsage: false, - WebGPUColorWriteBits: false, - WebGPUCommandBuffer: false, - WebGPUCommandEncoder: false, - WebGPUCompareFunction: false, - WebGPUComputePipeline: false, - WebGPUDepthStencilState: false, - WebGPUDevice: false, - WebGPUFence: false, - WebGPUFilterMode: false, - WebGPUIndexFormat: false, - WebGPUInputState: false, - WebGPUInputStepMode: false, - WebGPULoadOp: false, - WebGPULogEntry: false, - WebGPUPipelineLayout: false, - WebGPUPrimitiveTopology: false, - WebGPUQueue: false, - WebGPURenderPipeline: false, - WebGPUSampler: false, - WebGPUShaderModule: false, - WebGPUShaderStage: false, - WebGPUShaderStageBit: false, - WebGPUStencilOperation: false, - WebGPUStoreOp: false, - WebGPUSwapChain: false, - WebGPUTexture: false, - WebGPUTextureDimension: false, - WebGPUTextureFormat: false, - WebGPUTextureUsage: false, - WebGPUTextureView: false, - WebGPUVertexFormat: false, - WebKitCSSMatrix: false, - WebSocket: false, - WebrtcGlobalInformation: false, - WheelEvent: false, - Window: false, - WindowGlobalChild: false, - WindowGlobalParent: false, - WindowRoot: false, - Worker: false, - Worklet: false, - WritableStream: false, - WritableStreamDefaultController: false, - WritableStreamDefaultWriter: false, - XMLDocument: false, - XMLHttpRequest: false, - XMLHttpRequestEventTarget: false, - XMLHttpRequestUpload: false, - XMLSerializer: false, - XPathEvaluator: false, - XPathExpression: false, - XPathResult: false, - XSLTProcessor: false, - XULCommandEvent: false, - XULElement: false, - XULFrameElement: false, - XULMenuElement: false, - XULPopupElement: false, - XULScrollElement: false, - XULTextElement: false, - console: false, - mozRTCIceCandidate: false, - mozRTCPeerConnection: false, - mozRTCSessionDescription: false, - }, -}; diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/process-script.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/process-script.js deleted file mode 100644 index f329a66..0000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/process-script.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @fileoverview Defines the environment for process scripts. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -"use strict"; - -module.exports = { - globals: { - // dom/chrome-webidl/MessageManager.webidl - - // MessageManagerGlobal - dump: false, - atob: false, - btoa: false, - - // MessageListenerManagerMixin - addMessageListener: false, - removeMessageListener: false, - addWeakMessageListener: false, - removeWeakMessageListener: false, - - // MessageSenderMixin - sendAsyncMessage: false, - processMessageManager: false, - remoteType: false, - - // SyncMessageSenderMixin - sendSyncMessage: false, - - // ContentProcessMessageManager - initialProcessData: false, - sharedData: false, - }, -}; diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/remote-page.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/remote-page.js deleted file mode 100644 index 22abb70..0000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/remote-page.js +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @fileoverview Defines the environment for remote page. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -"use strict"; - -module.exports = { - globals: { - atob: false, - btoa: false, - RPMGetAppBuildID: false, - RPMGetInnerMostURI: false, - RPMGetIntPref: false, - RPMGetStringPref: false, - RPMGetBoolPref: false, - RPMSetBoolPref: false, - RPMGetFormatURLPref: false, - RPMIsWindowPrivate: false, - RPMSendAsyncMessage: false, - RPMSendQuery: false, - RPMAddMessageListener: false, - RPMRecordTelemetryEvent: false, - RPMCheckAlternateHostAvailable: false, - RPMAddToHistogram: false, - RPMRemoveMessageListener: false, - RPMGetHttpResponseHeader: false, - RPMTryPingSecureWWWLink: false, - RPMOpenSecureWWWLink: false, - }, -}; diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/simpletest.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/simpletest.js deleted file mode 100644 index 2f5dd5c..0000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/simpletest.js +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @fileoverview Defines the environment for scripts that use the SimpleTest - * mochitest harness. Imports the globals from the relevant files. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -"use strict"; - -// ----------------------------------------------------------------------------- -// Rule Definition -// ----------------------------------------------------------------------------- - -var path = require("path"); -var { getScriptGlobals } = require("./utils"); - -// When updating this list, be sure to also update the 'support-files' config -// in `tools/lint/eslint.yml`. -const simpleTestFiles = [ - "AccessibilityUtils.js", - "ExtensionTestUtils.js", - "EventUtils.js", - "MockObjects.js", - "SimpleTest.js", - "WindowSnapshot.js", - "paint_listener.js", -]; -const simpleTestPath = "testing/mochitest/tests/SimpleTest"; - -module.exports = getScriptGlobals( - "simpletest", - simpleTestFiles.map(file => path.join(simpleTestPath, file)) -); diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/sjs.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/sjs.js deleted file mode 100644 index 995c317..0000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/sjs.js +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @fileoverview Defines the environment for sjs files. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -"use strict"; - -module.exports = { - globals: { - // All these variables are hard-coded to be available for sjs scopes only. - // https://searchfox.org/mozilla-central/rev/26a1b0fce12e6dd495a954c542bb1e7bd6e0d548/netwerk/test/httpserver/httpd.js#2879 - atob: false, - btoa: false, - ChromeUtils: false, - dump: false, - getState: false, - setState: false, - getSharedState: false, - setSharedState: false, - getObjectState: false, - setObjectState: false, - registerPathHandler: false, - Services: false, - // importScripts is also available. - importScripts: false, - }, -}; diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/special-powers-sandbox.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/special-powers-sandbox.js deleted file mode 100644 index f40d440..0000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/special-powers-sandbox.js +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @fileoverview Defines the environment for SpecialPowers sandbox. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -"use strict"; - -module.exports = { - globals: { - // wantComponents defaults to true, - Components: false, - Ci: false, - Cr: false, - Cc: false, - Cu: false, - Services: false, - - // testing/specialpowers/content/SpecialPowersSandbox.jsm - - // SANDBOX_GLOBALS - Blob: false, - ChromeUtils: false, - FileReader: false, - TextDecoder: false, - TextEncoder: false, - URL: false, - - // EXTRA_IMPORTS - EventUtils: false, - - // SpecialPowersSandbox constructor - assert: false, - Assert: false, - BrowsingContext: false, - InspectorUtils: false, - ok: false, - is: false, - isnot: false, - todo: false, - todo_is: false, - info: false, - }, -}; diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/specific.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/specific.js deleted file mode 100644 index 23ebcb5..0000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/specific.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @fileoverview Defines the environment for the Firefox browser. Allows global - * variables which are non-standard and specific to Firefox. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -"use strict"; - -module.exports = { - globals: { - Cc: false, - ChromeUtils: false, - Ci: false, - Components: false, - Cr: false, - Cu: false, - Debugger: false, - InstallTrigger: false, - // https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/InternalError - InternalError: true, - Services: false, - // https://developer.mozilla.org/docs/Web/API/Window/dump - dump: true, - openDialog: false, - // https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/uneval - uneval: false, - }, -}; diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/utils.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/utils.js deleted file mode 100644 index aeda690..0000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/utils.js +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @fileoverview Provides utilities for setting up environments. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -"use strict"; - -var path = require("path"); -var helpers = require("../helpers"); -var globals = require("../globals"); - -/** - * Obtains the globals for a list of files. - * - * @param {Array.} files - * The array of files to get globals for. The paths are relative to the topsrcdir. - * @returns {Object} - * Returns an object with keys of the global names and values of if they are - * writable or not. - */ -function getGlobalsForScripts(environmentName, files, extraDefinitions) { - let fileGlobals = extraDefinitions; - const root = helpers.rootDir; - for (const file of files) { - const fileName = path.join(root, file); - try { - fileGlobals = fileGlobals.concat(globals.getGlobalsForFile(fileName)); - } catch (e) { - console.error(`Could not load globals from file ${fileName}: ${e}`); - console.error( - `You may need to update the mappings for the ${environmentName} environment` - ); - throw new Error(`Could not load globals from file ${fileName}: ${e}`); - } - } - - var globalObjects = {}; - for (let global of fileGlobals) { - globalObjects[global.name] = global.writable; - } - return globalObjects; -} - -module.exports = { - getScriptGlobals( - environmentName, - files, - extraDefinitions = [], - extraEnv = {} - ) { - if (helpers.isMozillaCentralBased()) { - return { - globals: getGlobalsForScripts(environmentName, files, extraDefinitions), - ...extraEnv, - }; - } - return helpers.getSavedEnvironmentItems(environmentName); - }, -}; diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/xpcshell.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/xpcshell.js deleted file mode 100644 index bc3f90e..0000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/xpcshell.js +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @fileoverview Defines the environment for xpcshell test files. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -"use strict"; - -var { getScriptGlobals } = require("./utils"); - -const extraGlobals = [ - // Defined in XPCShellImpl.cpp - "print", - "readline", - "load", - "quit", - "dumpXPC", - "dump", - "gc", - "gczeal", - "options", - "sendCommand", - "atob", - "btoa", - "setInterruptCallback", - "simulateNoScriptActivity", - "registerXPCTestComponents", - - // Assert.jsm globals. - "setReporter", - "report", - "ok", - "equal", - "notEqual", - "deepEqual", - "notDeepEqual", - "strictEqual", - "notStrictEqual", - "throws", - "rejects", - "greater", - "greaterOrEqual", - "less", - "lessOrEqual", - // TestingFunctions.cpp globals - "allocationMarker", - "byteSize", - "saveStack", -]; - -module.exports = getScriptGlobals( - "xpcshell", - ["testing/xpcshell/head.js"], - extraGlobals.map(g => { - return { name: g, writable: false }; - }) -); diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/globals.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/globals.js deleted file mode 100644 index 2c43c18..0000000 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/globals.js +++ /dev/null @@ -1,434 +0,0 @@ -/** - * @fileoverview functions for scanning an AST for globals including - * traversing referenced scripts. - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -"use strict"; - -const path = require("path"); -const fs = require("fs"); -const helpers = require("./helpers"); -const htmlparser = require("htmlparser2"); - -/** - * Parses a list of "name:boolean_value" or/and "name" options divided by comma - * or whitespace. - * - * This function was copied from eslint.js - * - * @param {string} string The string to parse. - * @param {Comment} comment The comment node which has the string. - * @returns {Object} Result map object of names and boolean values - */ -function parseBooleanConfig(string, comment) { - let items = {}; - - // Collapse whitespace around : to make parsing easier - string = string.replace(/\s*:\s*/g, ":"); - // Collapse whitespace around , - string = string.replace(/\s*,\s*/g, ","); - - string.split(/\s|,+/).forEach(function(name) { - if (!name) { - return; - } - - let pos = name.indexOf(":"); - let value; - if (pos !== -1) { - value = name.substring(pos + 1, name.length); - name = name.substring(0, pos); - } - - items[name] = { - value: value === "true", - comment, - }; - }); - - return items; -} - -/** - * Global discovery can require parsing many files. This map of - * {String} => {Object} caches what globals were discovered for a file path. - */ -const globalCache = new Map(); - -/** - * Global discovery can occasionally meet circular dependencies due to the way - * js files are included via html/xhtml files etc. This set is used to avoid - * getting into loops whilst the discovery is in progress. - */ -var globalDiscoveryInProgressForFiles = new Set(); - -/** - * When looking for globals in HTML files, it can be common to have more than - * one script tag with inline javascript. These will normally be called together, - * so we store the globals for just the last HTML file processed. - */ -var lastHTMLGlobals = {}; - -/** - * An object that returns found globals for given AST node types. Each prototype - * property should be named for a node type and accepts a node parameter and a - * parents parameter which is a list of the parent nodes of the current node. - * Each returns an array of globals found. - * - * @param {String} filePath - * The absolute path of the file being parsed. - */ -function GlobalsForNode(filePath, context) { - this.path = filePath; - this.context = context; - - if (this.path) { - this.dirname = path.dirname(this.path); - } else { - this.dirname = null; - } -} - -GlobalsForNode.prototype = { - Program(node) { - let globals = []; - for (let comment of node.comments) { - if (comment.type !== "Block") { - continue; - } - let value = comment.value.trim(); - value = value.replace(/\n/g, ""); - - // We have to discover any globals that ESLint would have defined through - // comment directives. - let match = /^globals?\s+(.+)/.exec(value); - if (match) { - let values = parseBooleanConfig(match[1].trim(), node); - for (let name of Object.keys(values)) { - globals.push({ - name, - writable: values[name].value, - }); - } - // We matched globals, so we won't match import-globals-from. - continue; - } - - match = /^import-globals-from\s+(.+)$/.exec(value); - if (!match) { - continue; - } - - if (!this.dirname) { - // If this is testing context without path, ignore import. - return globals; - } - - let filePath = match[1].trim(); - - if (filePath.endsWith(".mjs")) { - if (this.context) { - this.context.report( - comment, - "import-globals-from does not support module files - use a direct import instead" - ); - } else { - // Fall back to throwing an error, as we do not have a context in all situations, - // e.g. when loading the environment. - throw new Error( - "import-globals-from does not support module files - use a direct import instead" - ); - } - continue; - } - - if (!path.isAbsolute(filePath)) { - filePath = path.resolve(this.dirname, filePath); - } else { - filePath = path.join(helpers.rootDir, filePath); - } - globals = globals.concat(module.exports.getGlobalsForFile(filePath)); - } - - return globals; - }, - - ExpressionStatement(node, parents, globalScope) { - let isGlobal = helpers.getIsGlobalThis(parents); - let globals = []; - - // Note: We check the expression types here and only call the necessary - // functions to aid performance. - if (node.expression.type === "AssignmentExpression") { - globals = helpers.convertThisAssignmentExpressionToGlobals( - node, - isGlobal - ); - } else if (node.expression.type === "CallExpression") { - globals = helpers.convertCallExpressionToGlobals(node, isGlobal); - } - - // Here we assume that if importScripts is set in the global scope, then - // this is a worker. It would be nice if eslint gave us a way of getting - // the environment directly. - // - // If this is testing context without path, ignore import. - if (globalScope && globalScope.set.get("importScripts") && this.dirname) { - let workerDetails = helpers.convertWorkerExpressionToGlobals( - node, - isGlobal, - this.dirname - ); - globals = globals.concat(workerDetails); - } - - return globals; - }, -}; - -module.exports = { - /** - * Returns all globals for a given file. Recursively searches through - * import-globals-from directives and also includes globals defined by - * standard eslint directives. - * - * @param {String} filePath - * The absolute path of the file to be parsed. - * @param {Object} astOptions - * Extra options to pass to the parser. - * @return {Array} - * An array of objects that contain details about the globals: - * - {String} name - * The name of the global. - * - {Boolean} writable - * If the global is writeable or not. - */ - getGlobalsForFile(filePath, astOptions = {}) { - if (globalCache.has(filePath)) { - return globalCache.get(filePath); - } - - if (globalDiscoveryInProgressForFiles.has(filePath)) { - // We're already processing this file, so return an empty set for now - - // the initial processing will pick up on the globals for this file. - return []; - } - globalDiscoveryInProgressForFiles.add(filePath); - - let content = fs.readFileSync(filePath, "utf8"); - - // Parse the content into an AST - let { ast, scopeManager, visitorKeys } = helpers.parseCode( - content, - astOptions - ); - - // Discover global declarations - let globalScope = scopeManager.acquire(ast); - - let globals = Object.keys(globalScope.variables).map(v => ({ - name: globalScope.variables[v].name, - writable: true, - })); - - // Walk over the AST to find any of our custom globals - let handler = new GlobalsForNode(filePath); - - helpers.walkAST(ast, visitorKeys, (type, node, parents) => { - if (type in handler) { - let newGlobals = handler[type](node, parents, globalScope); - globals.push.apply(globals, newGlobals); - } - }); - - globalCache.set(filePath, globals); - - globalDiscoveryInProgressForFiles.delete(filePath); - return globals; - }, - - /** - * Returns all globals for a code. - * This is only for testing. - * - * @param {String} code - * The JS code - * @param {Object} astOptions - * Extra options to pass to the parser. - * @return {Array} - * An array of objects that contain details about the globals: - * - {String} name - * The name of the global. - * - {Boolean} writable - * If the global is writeable or not. - */ - getGlobalsForCode(code, astOptions = {}) { - // Parse the content into an AST - let { ast, scopeManager, visitorKeys } = helpers.parseCode( - code, - astOptions, - { useBabel: false } - ); - - // Discover global declarations - let globalScope = scopeManager.acquire(ast); - - let globals = Object.keys(globalScope.variables).map(v => ({ - name: globalScope.variables[v].name, - writable: true, - })); - - // Walk over the AST to find any of our custom globals - let handler = new GlobalsForNode(null); - - helpers.walkAST(ast, visitorKeys, (type, node, parents) => { - if (type in handler) { - let newGlobals = handler[type](node, parents, globalScope); - globals.push.apply(globals, newGlobals); - } - }); - - return globals; - }, - - /** - * Returns all the globals for an html file that are defined by imported - * scripts (i.e.