summaryrefslogtreecommitdiffstats
path: root/tools/lint/eslint
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /tools/lint/eslint
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tools/lint/eslint')
-rw-r--r--tools/lint/eslint/.eslintrc.js27
-rw-r--r--tools/lint/eslint/__init__.py144
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/.npmignore8
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/LICENSE363
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/README.md56
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/configs/.eslintrc.js8
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/configs/browser-test.js64
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/configs/chrome-test.js40
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/configs/mochitest-test.js39
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js305
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/configs/xpcshell-test.js35
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/environments/browser-window.js108
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/environments/chrome-worker.js25
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/environments/frame-script.js43
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/environments/jsm.js24
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/environments/privileged.js776
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/environments/simpletest.js35
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/environments/utils.js62
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/environments/xpcshell.js43
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/globals.js359
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/helpers.js881
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/index.js72
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/processors/processor-helpers.js120
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/processors/xul.js262
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/avoid-Date-timing.js67
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/avoid-removeChild.js64
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/balanced-listeners.js147
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/balanced-observers.js119
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/consistent-if-bracing.js49
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/import-browser-window-globals.js49
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/import-content-task-globals.js84
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/import-globals.js15
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/import-headjs-globals.js47
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/mark-exported-symbols-as-used.js83
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/mark-test-function-used.js37
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-aArgs.js56
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-arbitrary-setTimeout.js70
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-compare-against-boolean-literals.js34
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-define-cc-etc.js49
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-task.js33
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-throw-cr-literal.js100
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-useless-parameters.js147
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-useless-removeEventListener.js64
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-useless-run-test.js72
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/prefer-boolean-length-check.js130
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/prefer-formatValues.js96
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/reject-chromeutils-import-null.js44
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/reject-importGlobalProperties.js62
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/reject-relative-requires.js34
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/reject-some-requires.js35
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/rejects-requires-await.js42
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-cc-etc.js44
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-chromeutils-generateqi.js103
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-chromeutils-import.js89
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-default-preference-values.js45
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-includes-instead-of-indexOf.js45
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-ownerGlobal.js38
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-returnValue.js42
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-services.js45
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/rules/var-only-at-top-level.js34
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/services.json50
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/manifest.tt10
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/package-lock.json2045
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/package.json55
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/reporters/mozilla-format.js50
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/scripts/createExports.js89
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/avoid-Date-timing.js42
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/avoid-removeChild.js46
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/balanced-listeners.js89
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/balanced-observers.js74
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/consistent-if-bracing.js40
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/mark-exported-symbols-as-used.js45
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/no-arbitrary-setTimeout.js41
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/no-compare-against-boolean-literals.js61
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/no-define-cc-etc.js62
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/no-throw-cr-literal.js62
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/no-useless-parameters.js147
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/no-useless-removeEventListener.js99
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/no-useless-run-test.js124
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/prefer-boolean-length-check.js97
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/prefer-formatValues.js72
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/reject-chromeutils-import-null.js42
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/reject-importGlobalProperties.js46
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/reject-relative-requires.js58
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/reject-some-requires.js49
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/rejects-requires-await.js32
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/use-cc-etc.js55
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/use-chromeutils-generateqi.js81
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/use-chromeutils-import.js80
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/use-default-preference-values.js41
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/use-includes-instead-of-indexOf.js38
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/use-ownerGlobal.js35
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/use-returnValue.js39
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/tests/use-services.js40
-rwxr-xr-xtools/lint/eslint/eslint-plugin-mozilla/update.sh61
-rw-r--r--tools/lint/eslint/eslint-plugin-spidermonkey-js/LICENSE363
-rw-r--r--tools/lint/eslint/eslint-plugin-spidermonkey-js/lib/index.js17
-rw-r--r--tools/lint/eslint/eslint-plugin-spidermonkey-js/lib/processors/self-hosted.js49
-rw-r--r--tools/lint/eslint/eslint-plugin-spidermonkey-js/package.json30
-rw-r--r--tools/lint/eslint/manifest.tt10
-rw-r--r--tools/lint/eslint/modules.json239
-rw-r--r--tools/lint/eslint/setup_helper.py408
-rwxr-xr-xtools/lint/eslint/update.sh71
103 files changed, 11497 insertions, 0 deletions
diff --git a/tools/lint/eslint/.eslintrc.js b/tools/lint/eslint/.eslintrc.js
new file mode 100644
index 0000000000..48285a03d0
--- /dev/null
+++ b/tools/lint/eslint/.eslintrc.js
@@ -0,0 +1,27 @@
+/* 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: 10,
+ },
+
+ 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/__init__.py b/tools/lint/eslint/__init__.py
new file mode 100644
index 0000000000..cf1b29e64a
--- /dev/null
+++ b/tools/lint/eslint/__init__.py
@@ -0,0 +1,144 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# 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/.
+
+from __future__ import absolute_import, print_function
+
+import json
+import os
+import signal
+import subprocess
+import sys
+
+sys.path.append(os.path.join(os.path.dirname(__file__), "eslint"))
+from eslint import setup_helper
+
+from mozbuild.nodeutil import find_node_executable
+
+from mozlint import result
+
+ESLINT_ERROR_MESSAGE = """
+An error occurred running eslint. Please check the following error messages:
+
+{}
+""".strip()
+
+ESLINT_NOT_FOUND_MESSAGE = """
+Could not find eslint! We looked at the --binary option, at the ESLINT
+environment variable, and then at your local node_modules path. Please Install
+eslint and needed plugins with:
+
+mach eslint --setup
+
+and try again.
+""".strip()
+
+
+def setup(root, **lintargs):
+ setup_helper.set_project_root(root)
+
+ if not setup_helper.check_node_executables_valid():
+ return 1
+
+ return setup_helper.eslint_maybe_setup()
+
+
+def lint(paths, config, binary=None, fix=None, setup=None, **lintargs):
+ """Run eslint."""
+ log = lintargs["log"]
+ setup_helper.set_project_root(lintargs["root"])
+ module_path = setup_helper.get_project_root()
+
+ # Valid binaries are:
+ # - Any provided by the binary argument.
+ # - Any pointed at by the ESLINT environmental variable.
+ # - Those provided by |mach lint --setup|.
+
+ if not binary:
+ binary, _ = find_node_executable()
+
+ if not binary:
+ print(ESLINT_NOT_FOUND_MESSAGE)
+ return 1
+
+ extra_args = lintargs.get("extra_args") or []
+ exclude_args = []
+ for path in config.get("exclude", []):
+ exclude_args.extend(
+ ["--ignore-pattern", os.path.relpath(path, lintargs["root"])]
+ )
+
+ cmd_args = (
+ [
+ binary,
+ os.path.join(module_path, "node_modules", "eslint", "bin", "eslint.js"),
+ # This keeps ext as a single argument.
+ "--ext",
+ "[{}]".format(",".join(config["extensions"])),
+ "--format",
+ "json",
+ "--no-error-on-unmatched-pattern",
+ ]
+ + extra_args
+ + exclude_args
+ + paths
+ )
+ log.debug("Command: {}".format(" ".join(cmd_args)))
+
+ # eslint requires that --fix be set before the --ext argument.
+ if fix:
+ cmd_args.insert(2, "--fix")
+
+ shell = False
+ if os.environ.get("MSYSTEM") in ("MINGW32", "MINGW64"):
+ # The eslint binary needs to be run from a shell with msys
+ shell = True
+ encoding = "utf-8"
+
+ orig = signal.signal(signal.SIGINT, signal.SIG_IGN)
+ proc = subprocess.Popen(
+ cmd_args, shell=shell, stdout=subprocess.PIPE, stderr=subprocess.PIPE
+ )
+ signal.signal(signal.SIGINT, orig)
+
+ try:
+ output, errors = proc.communicate()
+ except KeyboardInterrupt:
+ proc.kill()
+ return []
+
+ if errors:
+ errors = errors.decode(encoding, "replace")
+ print(ESLINT_ERROR_MESSAGE.format(errors))
+
+ if proc.returncode >= 2:
+ return 1
+
+ if not output:
+ return [] # no output means success
+ output = output.decode(encoding, "replace")
+ try:
+ jsonresult = json.loads(output)
+ except ValueError:
+ print(ESLINT_ERROR_MESSAGE.format(output))
+ return 1
+
+ results = []
+ for obj in jsonresult:
+ errors = obj["messages"]
+
+ for err in errors:
+ err.update(
+ {
+ "hint": err.get("fix"),
+ "level": "error" if err["severity"] == 2 else "warning",
+ "lineno": err.get("line") or 0,
+ "path": obj["filePath"],
+ "rule": err.get("ruleId"),
+ }
+ )
+ results.append(result.from_config(config, **err))
+
+ return results
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/.npmignore b/tools/lint/eslint/eslint-plugin-mozilla/.npmignore
new file mode 100644
index 0000000000..3713448c7a
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/.npmignore
@@ -0,0 +1,8 @@
+.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
new file mode 100644
index 0000000000..e87a115e46
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/LICENSE
@@ -0,0 +1,363 @@
+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
new file mode 100644
index 0000000000..650507754e
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/README.md
@@ -0,0 +1,56 @@
+# 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
new file mode 100644
index 0000000000..76df4134f5
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/.eslintrc.js
@@ -0,0 +1,8 @@
+"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
new file mode 100644
index 0000000000..596815c850
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/browser-test.js
@@ -0,0 +1,64 @@
+// 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,
+ PromiseDebugging: false,
+ SpecialPowers: false,
+ TestUtils: false,
+ XPCNativeWrapper: false,
+ addLoadEvent: 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,
+ todo: false,
+ todo_is: false,
+ todo_isnot: false,
+ waitForClipboard: false,
+ waitForExplicitFinish: false,
+ waitForFocus: false,
+ },
+
+ plugins: ["mozilla"],
+
+ rules: {
+ "mozilla/import-content-task-globals": "error",
+ "mozilla/import-headjs-globals": "error",
+ "mozilla/mark-test-function-used": "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
new file mode 100644
index 0000000000..d097f8ebdf
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/chrome-test.js
@@ -0,0 +1,40 @@
+// 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"],
+
+ rules: {
+ "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
new file mode 100644
index 0000000000..af71955a4b
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/mochitest-test.js
@@ -0,0 +1,39 @@
+// 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"],
+
+ rules: {
+ "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
new file mode 100644
index 0000000000..72023fd0b9
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
@@ -0,0 +1,305 @@
+/* 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,
+ },
+
+ extends: ["eslint:recommended", "plugin:prettier/recommended"],
+
+ globals: {
+ Cc: false,
+ // Specific to Firefox (Chrome code only).
+ ChromeUtils: false,
+ Ci: false,
+ Components: false,
+ Cr: false,
+ Cu: false,
+ Debugger: false,
+ InstallTrigger: false,
+ // Specific to Firefox
+ // https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/InternalError
+ InternalError: true,
+ Intl: false,
+ SharedArrayBuffer: false,
+ StopIteration: false,
+ dump: true,
+ // Override the "browser" env definition of "location" to allow writing as it
+ // is a writeable property.
+ // See https://bugzilla.mozilla.org/show_bug.cgi?id=1509270#c1 for more information.
+ location: true,
+ openDialog: false,
+ saveStack: false,
+ sizeToContent: false,
+ // Specific to Firefox
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/uneval
+ uneval: false,
+ },
+
+ overrides: [
+ {
+ // We don't have the general browser environment for jsm files, but we do
+ // have our own special environments for them.
+ env: {
+ browser: false,
+ "mozilla/jsm": true,
+ },
+ files: ["**/*.jsm", "**/*.jsm.js"],
+ rules: {
+ "mozilla/mark-exported-symbols-as-used": "error",
+ // TODO: Bug 1575506 turn `builtinGlobals` on here.
+ // We can enable builtinGlobals for jsms due to their scopes.
+ "no-redeclare": ["error", { builtinGlobals: false }],
+ // JSM 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",
+ },
+ ],
+ },
+ },
+ ],
+
+ 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-chromeutils-import-null": "error",
+ "mozilla/reject-importGlobalProperties": ["error", "allownonwebidl"],
+ "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-ownerGlobal": "error",
+ "mozilla/use-returnValue": "error",
+ "mozilla/use-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",
+
+ // 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",
+
+ // 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
new file mode 100644
index 0000000000..4cff7fcdc3
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/xpcshell-test.js
@@ -0,0 +1,35 @@
+// Parent config file for all xpcshell files.
+"use strict";
+
+module.exports = {
+ env: {
+ "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",
+ },
+ ],
+ },
+ },
+ ],
+
+ 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
new file mode 100644
index 0000000000..76e03f2d49
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/browser-window.js
@@ -0,0 +1,108 @@
+/**
+ * @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/places/content/editBookmark.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 },
+];
+
+// 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/", "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-worker.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/chrome-worker.js
new file mode 100644
index 0000000000..db5759b26c
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/chrome-worker.js
@@ -0,0 +1,25 @@
+/**
+ * @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
new file mode 100644
index 0000000000..5f3cb199af
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/frame-script.js
@@ -0,0 +1,43 @@
+/**
+ * @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: {
+ addMessageListener: false,
+ addWeakMessageListener: false,
+ atob: false,
+ btoa: false,
+ chromeOuterWindowID: false,
+ content: false,
+ docShell: false,
+ processMessageManager: false,
+ removeMessageListener: false,
+ removeWeakMessageListener: false,
+ sendAsyncMessage: false,
+ sendSyncMessage: false,
+ tabEventTarget: false,
+ RPMGetAppBuildID: false,
+ RPMGetInnerMostURI: false,
+ RPMGetIntPref: false,
+ RPMGetStringPref: false,
+ RPMGetBoolPref: false,
+ RPMSetBoolPref: false,
+ RPMPrefIsLocked: false,
+ RPMGetFormatURLPref: false,
+ RPMIsWindowPrivate: false,
+ RPMSendAsyncMessage: false,
+ RPMSendQuery: false,
+ RPMAddMessageListener: false,
+ RPMRecordTelemetryEvent: false,
+ RPMAddToHistogram: false,
+ RPMRemoveMessageListener: false,
+ RPMGetHttpResponseHeader: 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
new file mode 100644
index 0000000000..858494b8d4
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/jsm.js
@@ -0,0 +1,24 @@
+/**
+ * @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/ed212c79cfe86357e9a5740082b9364e7f6e526f/js/xpconnect/loader/mozJSComponentLoader.cpp#134-140
+ atob: false,
+ btoa: false,
+ debug: 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,
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/privileged.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/privileged.js
new file mode 100644
index 0000000000..12d9e0096d
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/privileged.js
@@ -0,0 +1,776 @@
+/**
+ * @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: {
+ // 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,
+ 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,
+ 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,
+ FrameLoader: false,
+ GainNode: false,
+ Gamepad: false,
+ GamepadAxisMoveEvent: false,
+ GamepadButton: false,
+ GamepadButtonEvent: false,
+ GamepadEvent: false,
+ GamepadHapticActuator: false,
+ GamepadPose: false,
+ GamepadServiceTest: 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,
+ HiddenPluginEvent: 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,
+ 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,
+ PlacesBookmarkRemoved: false,
+ PlacesEvent: false,
+ PlacesHistoryCleared: false,
+ PlacesObservers: false,
+ PlacesRanking: false,
+ PlacesVisit: 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,
+ 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,
+ 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,
+ 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/simpletest.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/simpletest.js
new file mode 100644
index 0000000000..2f5dd5c33e
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/simpletest.js
@@ -0,0 +1,35 @@
+/**
+ * @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/utils.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/utils.js
new file mode 100644
index 0000000000..aeda690ba5
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/utils.js
@@ -0,0 +1,62 @@
+/**
+ * @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.<String>} 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
new file mode 100644
index 0000000000..570119b6e9
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/xpcshell.js
@@ -0,0 +1,43 @@
+/**
+ * @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";
+
+var { getScriptGlobals } = require("./utils");
+
+const extraGlobals = [
+ // Assert.jsm globals.
+ "setReporter",
+ "report",
+ "ok",
+ "equal",
+ "notEqual",
+ "deepEqual",
+ "notDeepEqual",
+ "strictEqual",
+ "notStrictEqual",
+ "throws",
+ "rejects",
+ "greater",
+ "greaterOrEqual",
+ "less",
+ "lessOrEqual",
+ // TestingFunctions.cpp globals
+ "allocationMarker",
+ "byteSize",
+ "gc",
+ "gczeal",
+];
+
+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
new file mode 100644
index 0000000000..cb1b0d5f66
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/globals.js
@@ -0,0 +1,359 @@
+/**
+ * @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 xul 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) {
+ this.path = filePath;
+ this.dirname = path.dirname(this.path);
+}
+
+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;
+ }
+
+ let filePath = match[1].trim();
+
+ if (!path.isAbsolute(filePath)) {
+ filePath = path.resolve(this.dirname, filePath);
+ }
+ globals = globals.concat(module.exports.getGlobalsForFile(filePath));
+ }
+
+ return globals;
+ },
+
+ ExpressionStatement(node, parents, globalScope) {
+ let isGlobal = helpers.getIsGlobalScope(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 (globalScope && globalScope.set.get("importScripts")) {
+ 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 the globals for an html file that are defined by imported
+ * scripts (i.e. <script src="foo.js">).
+ *
+ * This function will cache results for one html file only - we expect
+ * this to be called sequentially for each chunk of a HTML file, rather
+ * than chucks of different files in random order.
+ *
+ * @param {String} filePath
+ * The absolute path of the file to be parsed.
+ * @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.
+ */
+ getImportedGlobalsForHTMLFile(filePath) {
+ if (lastHTMLGlobals.filename === filePath) {
+ return lastHTMLGlobals.globals;
+ }
+
+ let dir = path.dirname(filePath);
+ let globals = [];
+
+ let content = fs.readFileSync(filePath, "utf8");
+ let scriptSrcs = [];
+
+ // We use htmlparser as this ensures we find the script tags correctly.
+ let parser = new htmlparser.Parser(
+ {
+ onopentag(name, attribs) {
+ if (name === "script" && "src" in attribs) {
+ scriptSrcs.push({
+ src: attribs.src,
+ type:
+ "type" in attribs && attribs.type == "module"
+ ? "module"
+ : "script",
+ });
+ }
+ },
+ },
+ {
+ xmlMode: filePath.endsWith("xhtml"),
+ }
+ );
+
+ parser.parseComplete(content);
+
+ for (let script of scriptSrcs) {
+ // Ensure that the script src isn't just "".
+ if (!script.src) {
+ continue;
+ }
+ let scriptName;
+ if (script.src.includes("http:")) {
+ // We don't handle this currently as the paths are complex to match.
+ } else if (script.src.includes("chrome")) {
+ // This is one way of referencing test files.
+ script.src = script.src.replace("chrome://mochikit/content/", "/");
+ scriptName = path.join(
+ helpers.rootDir,
+ "testing",
+ "mochitest",
+ script.src
+ );
+ } else if (script.src.includes("SimpleTest")) {
+ // This is another way of referencing test files...
+ scriptName = path.join(
+ helpers.rootDir,
+ "testing",
+ "mochitest",
+ script.src
+ );
+ } else if (script.src.startsWith("/tests/")) {
+ scriptName = path.join(helpers.rootDir, script.src.substring(7));
+ } else {
+ // Fallback to hoping this is a relative path.
+ scriptName = path.join(dir, script.src);
+ }
+ if (scriptName && fs.existsSync(scriptName)) {
+ globals.push(
+ ...module.exports.getGlobalsForFile(scriptName, {
+ ecmaVersion: helpers.getECMAVersion(),
+ sourceType: script.type,
+ })
+ );
+ }
+ }
+
+ lastHTMLGlobals.filePath = filePath;
+ return (lastHTMLGlobals.globals = globals);
+ },
+
+ /**
+ * Intended to be used as-is for an ESLint rule that parses for globals in
+ * the current file and recurses through import-globals-from directives.
+ *
+ * @param {Object} context
+ * The ESLint parsing context.
+ */
+ getESLintGlobalParser(context) {
+ let globalScope;
+
+ let parser = {
+ Program(node) {
+ globalScope = context.getScope();
+ },
+ };
+ let filename = context.getFilename();
+
+ let extraHTMLGlobals = [];
+ if (filename.endsWith(".html") || filename.endsWith(".xhtml")) {
+ extraHTMLGlobals = module.exports.getImportedGlobalsForHTMLFile(filename);
+ }
+
+ // Install thin wrappers around GlobalsForNode
+ let handler = new GlobalsForNode(helpers.getAbsoluteFilePath(context));
+
+ for (let type of Object.keys(GlobalsForNode.prototype)) {
+ parser[type] = function(node) {
+ if (type === "Program") {
+ globalScope = context.getScope();
+ helpers.addGlobals(extraHTMLGlobals, globalScope);
+ }
+ let globals = handler[type](node, context.getAncestors(), globalScope);
+ helpers.addGlobals(
+ globals,
+ globalScope,
+ node.type !== "Program" && node
+ );
+ };
+ }
+
+ return parser;
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/helpers.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/helpers.js
new file mode 100644
index 0000000000..a3a5fcf8e7
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/helpers.js
@@ -0,0 +1,881 @@
+/**
+ * @fileoverview A collection of helper functions.
+ * 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 parser = require("babel-eslint");
+const { analyze } = require("eslint-scope");
+const { KEYS: defaultVisitorKeys } = require("eslint-visitor-keys");
+const estraverse = require("estraverse");
+const path = require("path");
+const fs = require("fs");
+const ini = require("multi-ini");
+const recommendedConfig = require("./configs/recommended");
+
+var gModules = null;
+var gRootDir = null;
+var directoryManifests = new Map();
+
+const callExpressionDefinitions = [
+ /^loader\.lazyGetter\(this, "(\w+)"/,
+ /^loader\.lazyImporter\(this, "(\w+)"/,
+ /^loader\.lazyServiceGetter\(this, "(\w+)"/,
+ /^loader\.lazyRequireGetter\(this, "(\w+)"/,
+ /^XPCOMUtils\.defineLazyGetter\(this, "(\w+)"/,
+ /^XPCOMUtils\.defineLazyModuleGetter\(this, "(\w+)"/,
+ /^ChromeUtils\.defineModuleGetter\(this, "(\w+)"/,
+ /^XPCOMUtils\.defineLazyPreferenceGetter\(this, "(\w+)"/,
+ /^XPCOMUtils\.defineLazyProxy\(this, "(\w+)"/,
+ /^XPCOMUtils\.defineLazyScriptGetter\(this, "(\w+)"/,
+ /^XPCOMUtils\.defineLazyServiceGetter\(this, "(\w+)"/,
+ /^XPCOMUtils\.defineConstant\(this, "(\w+)"/,
+ /^DevToolsUtils\.defineLazyModuleGetter\(this, "(\w+)"/,
+ /^DevToolsUtils\.defineLazyGetter\(this, "(\w+)"/,
+ /^Object\.defineProperty\(this, "(\w+)"/,
+ /^Reflect\.defineProperty\(this, "(\w+)"/,
+ /^this\.__defineGetter__\("(\w+)"/,
+];
+
+const callExpressionMultiDefinitions = [
+ "XPCOMUtils.defineLazyGlobalGetters(this,",
+ "XPCOMUtils.defineLazyModuleGetters(this,",
+ "XPCOMUtils.defineLazyServiceGetters(this,",
+ "loader.lazyRequireGetter(this,",
+];
+
+const imports = [
+ /^(?:Cu|Components\.utils|ChromeUtils)\.import\(".*\/((.*?)\.jsm?)", this\)/,
+];
+
+const workerImportFilenameMatch = /(.*\/)*((.*?)\.jsm?)/;
+
+module.exports = {
+ get iniParser() {
+ if (!this._iniParser) {
+ this._iniParser = new ini.Parser();
+ }
+ return this._iniParser;
+ },
+
+ get modulesGlobalData() {
+ if (!gModules) {
+ if (this.isMozillaCentralBased()) {
+ gModules = require(path.join(
+ this.rootDir,
+ "tools",
+ "lint",
+ "eslint",
+ "modules.json"
+ ));
+ } else {
+ gModules = require("./modules.json");
+ }
+ }
+
+ return gModules;
+ },
+
+ get servicesData() {
+ return require("./services.json");
+ },
+
+ /**
+ * Gets the abstract syntax tree (AST) of the JavaScript source code contained
+ * in sourceText. This matches the results for an eslint parser, see
+ * https://eslint.org/docs/developer-guide/working-with-custom-parsers.
+ *
+ * @param {String} sourceText
+ * Text containing valid JavaScript.
+ * @param {Object} astOptions
+ * Extra configuration to pass to the espree parser, these will override
+ * the configuration from getPermissiveConfig().
+ *
+ * @return {Object}
+ * Returns an object containing `ast`, `scopeManager` and
+ * `visitorKeys`
+ */
+ parseCode(sourceText, astOptions = {}) {
+ // Use a permissive config file to allow parsing of anything that Espree
+ // can parse.
+ let config = { ...this.getPermissiveConfig(), ...astOptions };
+
+ let parseResult =
+ "parseForESLint" in parser
+ ? parser.parseForESLint(sourceText, config)
+ : { ast: parser.parse(sourceText, config) };
+
+ let visitorKeys = parseResult.visitorKeys || defaultVisitorKeys;
+ visitorKeys.ExperimentalRestProperty = visitorKeys.RestElement;
+ visitorKeys.ExperimentalSpreadProperty = visitorKeys.SpreadElement;
+
+ return {
+ ast: parseResult.ast,
+ scopeManager: parseResult.scopeManager || analyze(parseResult.ast),
+ visitorKeys,
+ };
+ },
+
+ /**
+ * A simplistic conversion of some AST nodes to a standard string form.
+ *
+ * @param {Object} node
+ * The AST node to convert.
+ *
+ * @return {String}
+ * The JS source for the node.
+ */
+ getASTSource(node, context) {
+ switch (node.type) {
+ case "MemberExpression":
+ if (node.computed) {
+ let filename = context && context.getFilename();
+ throw new Error(
+ `getASTSource unsupported computed MemberExpression in ${filename}`
+ );
+ }
+ return (
+ this.getASTSource(node.object) +
+ "." +
+ this.getASTSource(node.property)
+ );
+ case "ThisExpression":
+ return "this";
+ case "Identifier":
+ return node.name;
+ case "Literal":
+ return JSON.stringify(node.value);
+ case "CallExpression":
+ var args = node.arguments.map(a => this.getASTSource(a)).join(", ");
+ return this.getASTSource(node.callee) + "(" + args + ")";
+ case "ObjectExpression":
+ return "{}";
+ case "ExpressionStatement":
+ return this.getASTSource(node.expression) + ";";
+ case "FunctionExpression":
+ return "function() {}";
+ case "ArrayExpression":
+ return "[" + node.elements.map(this.getASTSource, this).join(",") + "]";
+ case "ArrowFunctionExpression":
+ return "() => {}";
+ case "AssignmentExpression":
+ return (
+ this.getASTSource(node.left) + " = " + this.getASTSource(node.right)
+ );
+ case "BinaryExpression":
+ return (
+ this.getASTSource(node.left) +
+ " " +
+ node.operator +
+ " " +
+ this.getASTSource(node.right)
+ );
+ default:
+ throw new Error("getASTSource unsupported node type: " + node.type);
+ }
+ },
+
+ /**
+ * This walks an AST in a manner similar to ESLint passing node events to the
+ * listener. The listener is expected to be a simple function
+ * which accepts node type, node and parents arguments.
+ *
+ * @param {Object} ast
+ * The AST to walk.
+ * @param {Array} visitorKeys
+ * The visitor keys to use for the AST.
+ * @param {Function} listener
+ * A callback function to call for the nodes. Passed three arguments,
+ * event type, node and an array of parent nodes for the current node.
+ */
+ walkAST(ast, visitorKeys, listener) {
+ let parents = [];
+
+ estraverse.traverse(ast, {
+ enter(node, parent) {
+ listener(node.type, node, parents);
+
+ parents.push(node);
+ },
+
+ leave(node, parent) {
+ if (parents.length == 0) {
+ throw new Error("Left more nodes than entered.");
+ }
+ parents.pop();
+ },
+
+ keys: visitorKeys,
+ });
+ if (parents.length) {
+ throw new Error("Entered more nodes than left.");
+ }
+ },
+
+ /**
+ * Attempts to convert an ExpressionStatement to likely global variable
+ * definitions.
+ *
+ * @param {Object} node
+ * The AST node to convert.
+ * @param {boolean} isGlobal
+ * True if the current node is in the global scope.
+ *
+ * @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.
+ */
+ convertWorkerExpressionToGlobals(node, isGlobal, dirname) {
+ var getGlobalsForFile = require("./globals").getGlobalsForFile;
+
+ let globalModules = this.modulesGlobalData;
+
+ let results = [];
+ let expr = node.expression;
+
+ if (
+ node.expression.type === "CallExpression" &&
+ expr.callee &&
+ expr.callee.type === "Identifier" &&
+ expr.callee.name === "importScripts"
+ ) {
+ for (var arg of expr.arguments) {
+ var match = arg.value && arg.value.match(workerImportFilenameMatch);
+ if (match) {
+ if (!match[1]) {
+ let filePath = path.resolve(dirname, match[2]);
+ if (fs.existsSync(filePath)) {
+ let additionalGlobals = getGlobalsForFile(filePath);
+ results = results.concat(additionalGlobals);
+ }
+ } else if (match[2] in globalModules) {
+ results = results.concat(
+ globalModules[match[2]].map(name => {
+ return { name, writable: true };
+ })
+ );
+ } else {
+ results.push({ name: match[3], writable: true, explicit: true });
+ }
+ }
+ }
+ }
+
+ return results;
+ },
+
+ /**
+ * Attempts to convert an AssignmentExpression into a global variable
+ * definition if it applies to `this` in the global scope.
+ *
+ * @param {Object} node
+ * The AST node to convert.
+ * @param {boolean} isGlobal
+ * True if the current node is in the global scope.
+ *
+ * @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.
+ */
+ convertThisAssignmentExpressionToGlobals(node, isGlobal) {
+ if (
+ isGlobal &&
+ node.expression.left &&
+ node.expression.left.object &&
+ node.expression.left.object.type === "ThisExpression" &&
+ node.expression.left.property &&
+ node.expression.left.property.type === "Identifier"
+ ) {
+ return [{ name: node.expression.left.property.name, writable: true }];
+ }
+ return [];
+ },
+
+ /**
+ * Attempts to convert an CallExpressions that look like module imports
+ * into global variable definitions, using modules.json data if appropriate.
+ *
+ * @param {Object} node
+ * The AST node to convert.
+ * @param {boolean} isGlobal
+ * True if the current node is in the global scope.
+ *
+ * @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.
+ */
+ convertCallExpressionToGlobals(node, isGlobal) {
+ let express = node.expression;
+ if (
+ express.type === "CallExpression" &&
+ express.callee.type === "MemberExpression" &&
+ express.callee.object &&
+ express.callee.object.type === "Identifier" &&
+ express.arguments.length === 1 &&
+ express.arguments[0].type === "ArrayExpression" &&
+ express.callee.property.type === "Identifier" &&
+ express.callee.property.name === "importGlobalProperties"
+ ) {
+ return express.arguments[0].elements.map(literal => {
+ return {
+ explicit: true,
+ name: literal.value,
+ writable: false,
+ };
+ });
+ }
+
+ let source;
+ try {
+ source = this.getASTSource(node);
+ } catch (e) {
+ return [];
+ }
+
+ for (let reg of imports) {
+ let match = source.match(reg);
+ if (match) {
+ // The two argument form is only acceptable in the global scope
+ if (node.expression.arguments.length > 1 && !isGlobal) {
+ return [];
+ }
+
+ let globalModules = this.modulesGlobalData;
+
+ if (match[1] in globalModules) {
+ // XXX We mark as explicit when there is only one exported symbol from
+ // the module. For now this avoids no-unused-vars complaining in the
+ // cases where we import everything from a module but only use one
+ // of them.
+ let explicit = globalModules[match[1]].length == 1;
+ return globalModules[match[1]].map(name => ({
+ name,
+ writable: true,
+ explicit,
+ }));
+ }
+
+ return [{ name: match[2], writable: true, explicit: true }];
+ }
+ }
+
+ // The definition matches below must be in the global scope for us to define
+ // a global, so bail out early if we're not a global.
+ if (!isGlobal) {
+ return [];
+ }
+
+ for (let reg of callExpressionDefinitions) {
+ let match = source.match(reg);
+ if (match) {
+ return [{ name: match[1], writable: true, explicit: true }];
+ }
+ }
+
+ if (
+ callExpressionMultiDefinitions.some(expr => source.startsWith(expr)) &&
+ node.expression.arguments[1]
+ ) {
+ let arg = node.expression.arguments[1];
+ if (arg.type === "ObjectExpression") {
+ return arg.properties
+ .map(p => ({
+ name: p.type === "Property" && p.key.name,
+ writable: true,
+ explicit: true,
+ }))
+ .filter(g => g.name);
+ }
+ if (arg.type === "ArrayExpression") {
+ return arg.elements
+ .map(p => ({
+ name: p.type === "Literal" && p.value,
+ writable: true,
+ explicit: true,
+ }))
+ .filter(g => typeof g.name == "string");
+ }
+ }
+
+ if (
+ node.expression.callee.type == "MemberExpression" &&
+ node.expression.callee.property.type == "Identifier" &&
+ node.expression.callee.property.name == "defineLazyScriptGetter"
+ ) {
+ // The case where we have a single symbol as a string has already been
+ // handled by the regexp, so we have an array of symbols here.
+ return node.expression.arguments[1].elements.map(n => ({
+ name: n.value,
+ writable: true,
+ explicit: true,
+ }));
+ }
+
+ return [];
+ },
+
+ /**
+ * Add a variable to the current scope.
+ * HACK: This relies on eslint internals so it could break at any time.
+ *
+ * @param {String} name
+ * The variable name to add to the scope.
+ * @param {ASTScope} scope
+ * The scope to add to.
+ * @param {boolean} writable
+ * Whether the global can be overwritten.
+ * @param {Object} [node]
+ * The AST node that defined the globals.
+ */
+ addVarToScope(name, scope, writable, node) {
+ scope.__defineGeneric(name, scope.set, scope.variables, null, null);
+
+ let variable = scope.set.get(name);
+ variable.eslintExplicitGlobal = false;
+ variable.writeable = writable;
+ if (node) {
+ variable.defs.push({ node, name: { name } });
+ variable.identifiers.push(node);
+ }
+
+ // Walk to the global scope which holds all undeclared variables.
+ while (scope.type != "global") {
+ scope = scope.upper;
+ }
+
+ // "through" contains all references with no found definition.
+ scope.through = scope.through.filter(function(reference) {
+ if (reference.identifier.name != name) {
+ return true;
+ }
+
+ // Links the variable and the reference.
+ // And this reference is removed from `Scope#through`.
+ reference.resolved = variable;
+ variable.references.push(reference);
+ return false;
+ });
+ },
+
+ /**
+ * Adds a set of globals to a scope.
+ *
+ * @param {Array} globalVars
+ * An array of global variable names.
+ * @param {ASTScope} scope
+ * The scope.
+ * @param {Object} [node]
+ * The AST node that defined the globals.
+ */
+ addGlobals(globalVars, scope, node) {
+ globalVars.forEach(v =>
+ this.addVarToScope(v.name, scope, v.writable, v.explicit && node)
+ );
+ },
+
+ /**
+ * To allow espree to parse almost any JavaScript we need as many features as
+ * possible turned on. This method returns that config.
+ *
+ * @return {Object}
+ * Espree compatible permissive config.
+ */
+ getPermissiveConfig() {
+ return {
+ range: true,
+ loc: true,
+ comment: true,
+ attachComment: true,
+ ecmaVersion: this.getECMAVersion(),
+ sourceType: "script",
+ };
+ },
+
+ /**
+ * Returns the ECMA version of the recommended config.
+ *
+ * @return {Number} The ECMA version of the recommended config.
+ */
+ getECMAVersion() {
+ return recommendedConfig.parserOptions.ecmaVersion;
+ },
+
+ /**
+ * Check whether a node is a function.
+ *
+ * @param {Object} node
+ * The AST node to check
+ *
+ * @return {Boolean}
+ * True or false
+ */
+ getIsFunctionNode(node) {
+ switch (node.type) {
+ case "ArrowFunctionExpression":
+ case "FunctionDeclaration":
+ case "FunctionExpression":
+ return true;
+ }
+ return false;
+ },
+
+ /**
+ * Check whether the context is the global scope.
+ *
+ * @param {Array} ancestors
+ * The parents of the current node.
+ *
+ * @return {Boolean}
+ * True or false
+ */
+ getIsGlobalScope(ancestors) {
+ for (let parent of ancestors) {
+ if (this.getIsFunctionNode(parent)) {
+ return false;
+ }
+ }
+ return true;
+ },
+
+ /**
+ * Check whether we might be in a test head file.
+ *
+ * @param {RuleContext} scope
+ * You should pass this from within a rule
+ * e.g. helpers.getIsHeadFile(context)
+ *
+ * @return {Boolean}
+ * True or false
+ */
+ getIsHeadFile(scope) {
+ var pathAndFilename = this.cleanUpPath(scope.getFilename());
+
+ return /.*[\\/]head(_.+)?\.js$/.test(pathAndFilename);
+ },
+
+ /**
+ * Gets the head files for a potential test file
+ *
+ * @param {RuleContext} scope
+ * You should pass this from within a rule
+ * e.g. helpers.getIsHeadFile(context)
+ *
+ * @return {String[]}
+ * Paths to head files to load for the test
+ */
+ getTestHeadFiles(scope) {
+ if (!this.getIsTest(scope)) {
+ return [];
+ }
+
+ let filepath = this.cleanUpPath(scope.getFilename());
+ let dir = path.dirname(filepath);
+
+ let names = fs
+ .readdirSync(dir)
+ .filter(
+ name =>
+ (name.startsWith("head") || name.startsWith("xpcshell-head")) &&
+ name.endsWith(".js")
+ )
+ .map(name => path.join(dir, name));
+ return names;
+ },
+
+ /**
+ * Gets all the test manifest data for a directory
+ *
+ * @param {String} dir
+ * The directory
+ *
+ * @return {Array}
+ * An array of objects with file and manifest properties
+ */
+ getManifestsForDirectory(dir) {
+ if (directoryManifests.has(dir)) {
+ return directoryManifests.get(dir);
+ }
+
+ let manifests = [];
+ let names = [];
+ try {
+ names = fs.readdirSync(dir);
+ } catch (err) {
+ // Ignore directory not found, it might be faked by a test
+ if (err.code !== "ENOENT") {
+ throw err;
+ }
+ }
+
+ for (let name of names) {
+ if (!name.endsWith(".ini")) {
+ continue;
+ }
+
+ try {
+ let manifest = this.iniParser.parse(
+ fs.readFileSync(path.join(dir, name), "utf8").split("\n")
+ );
+ manifests.push({
+ file: path.join(dir, name),
+ manifest,
+ });
+ } catch (e) {}
+ }
+
+ directoryManifests.set(dir, manifests);
+ return manifests;
+ },
+
+ /**
+ * Gets the manifest file a test is listed in
+ *
+ * @param {RuleContext} scope
+ * You should pass this from within a rule
+ * e.g. helpers.getIsHeadFile(context)
+ *
+ * @return {String}
+ * The path to the test manifest file
+ */
+ getTestManifest(scope) {
+ let filepath = this.cleanUpPath(scope.getFilename());
+
+ let dir = path.dirname(filepath);
+ let filename = path.basename(filepath);
+
+ for (let manifest of this.getManifestsForDirectory(dir)) {
+ if (filename in manifest.manifest) {
+ return manifest.file;
+ }
+ }
+
+ return null;
+ },
+
+ /**
+ * Check whether we are in a test of some kind.
+ *
+ * @param {RuleContext} scope
+ * You should pass this from within a rule
+ * e.g. helpers.getIsTest(context)
+ *
+ * @return {Boolean}
+ * True or false
+ */
+ getIsTest(scope) {
+ // Regardless of the manifest name being in a manifest means we're a test.
+ let manifest = this.getTestManifest(scope);
+ if (manifest) {
+ return true;
+ }
+
+ return !!this.getTestType(scope);
+ },
+
+ /**
+ * Gets the type of test or null if this isn't a test.
+ *
+ * @param {RuleContext} scope
+ * You should pass this from within a rule
+ * e.g. helpers.getIsHeadFile(context)
+ *
+ * @return {String or null}
+ * Test type: xpcshell, browser, chrome, mochitest
+ */
+ getTestType(scope) {
+ let testTypes = ["browser", "xpcshell", "chrome", "mochitest", "a11y"];
+ let manifest = this.getTestManifest(scope);
+ if (manifest) {
+ let name = path.basename(manifest);
+ for (let testType of testTypes) {
+ if (name.startsWith(testType)) {
+ return testType;
+ }
+ }
+ }
+
+ let filepath = this.cleanUpPath(scope.getFilename());
+ let filename = path.basename(filepath);
+
+ if (filename.startsWith("browser_")) {
+ return "browser";
+ }
+
+ if (filename.startsWith("test_")) {
+ let parent = path.basename(path.dirname(filepath));
+ for (let testType of testTypes) {
+ if (parent.startsWith(testType)) {
+ return testType;
+ }
+ }
+
+ // It likely is a test, we're just not sure what kind.
+ return "unknown";
+ }
+
+ // Likely not a test
+ return null;
+ },
+
+ getIsWorker(filePath) {
+ let filename = path.basename(this.cleanUpPath(filePath)).toLowerCase();
+
+ return filename.includes("worker");
+ },
+
+ /**
+ * Gets the root directory of the repository by walking up directories from
+ * this file until a .eslintignore file is found. If this fails, the same
+ * procedure will be attempted from the current working dir.
+ * @return {String} The absolute path of the repository directory
+ */
+ get rootDir() {
+ if (!gRootDir) {
+ function searchUpForIgnore(dirName, filename) {
+ let parsed = path.parse(dirName);
+ while (parsed.root !== dirName) {
+ if (fs.existsSync(path.join(dirName, filename))) {
+ return dirName;
+ }
+ // Move up a level
+ dirName = parsed.dir;
+ parsed = path.parse(dirName);
+ }
+ return null;
+ }
+
+ let possibleRoot = searchUpForIgnore(
+ path.dirname(module.filename),
+ ".eslintignore"
+ );
+ if (!possibleRoot) {
+ possibleRoot = searchUpForIgnore(path.resolve(), ".eslintignore");
+ }
+ if (!possibleRoot) {
+ possibleRoot = searchUpForIgnore(path.resolve(), "package.json");
+ }
+ if (!possibleRoot) {
+ // We've couldn't find a root from the module or CWD, so lets just go
+ // for the CWD. We really don't want to throw if possible, as that
+ // tends to give confusing results when used with ESLint.
+ possibleRoot = process.cwd();
+ }
+
+ gRootDir = possibleRoot;
+ }
+
+ return gRootDir;
+ },
+
+ /**
+ * ESLint may be executed from various places: from mach, at the root of the
+ * repository, or from a directory in the repository when, for instance,
+ * executed by a text editor's plugin.
+ * The value returned by context.getFileName() varies because of this.
+ * This helper function makes sure to return an absolute file path for the
+ * current context, by looking at process.cwd().
+ * @param {Context} context
+ * @return {String} The absolute path
+ */
+ getAbsoluteFilePath(context) {
+ var fileName = this.cleanUpPath(context.getFilename());
+ var cwd = process.cwd();
+
+ if (path.isAbsolute(fileName)) {
+ // Case 2: executed from the repo's root with mach:
+ // fileName: /path/to/mozilla/repo/a/b/c/d.js
+ // cwd: /path/to/mozilla/repo
+ return fileName;
+ } else if (path.basename(fileName) == fileName) {
+ // Case 1b: executed from a nested directory, fileName is the base name
+ // without any path info (happens in Atom with linter-eslint)
+ return path.join(cwd, fileName);
+ }
+ // Case 1: executed form in a nested directory, e.g. from a text editor:
+ // fileName: a/b/c/d.js
+ // cwd: /path/to/mozilla/repo/a/b/c
+ var dirName = path.dirname(fileName);
+ return cwd.slice(0, cwd.length - dirName.length) + fileName;
+ },
+
+ /**
+ * When ESLint is run from SublimeText, paths retrieved from
+ * context.getFileName contain leading and trailing double-quote characters.
+ * These characters need to be removed.
+ */
+ cleanUpPath(pathName) {
+ return pathName.replace(/^"/, "").replace(/"$/, "");
+ },
+
+ get globalScriptPaths() {
+ return [
+ path.join(this.rootDir, "browser", "base", "content", "browser.xhtml"),
+ path.join(
+ this.rootDir,
+ "browser",
+ "base",
+ "content",
+ "global-scripts.inc"
+ ),
+ ];
+ },
+
+ isMozillaCentralBased() {
+ return fs.existsSync(this.globalScriptPaths[0]);
+ },
+
+ getSavedEnvironmentItems(environment) {
+ return require("./environments/saved-globals.json").environments[
+ environment
+ ];
+ },
+
+ getSavedRuleData(rule) {
+ return require("./rules/saved-rules-data.json").rulesData[rule];
+ },
+
+ getBuildEnvironment() {
+ var { execFileSync } = require("child_process");
+ var output = execFileSync(
+ path.join(this.rootDir, "mach"),
+ ["environment", "--format=json"],
+ { silent: true }
+ );
+ return JSON.parse(output);
+ },
+
+ /**
+ * Extract the path of require (and require-like) helpers used in DevTools.
+ */
+ getDevToolsRequirePath(node) {
+ if (
+ node.callee.type == "Identifier" &&
+ node.callee.name == "require" &&
+ node.arguments.length == 1 &&
+ node.arguments[0].type == "Literal"
+ ) {
+ return node.arguments[0].value;
+ } else if (
+ node.callee.type == "MemberExpression" &&
+ node.callee.property.type == "Identifier" &&
+ (node.callee.property.name == "lazyRequireGetter" ||
+ node.callee.property.name == "lazyImporter") &&
+ node.arguments.length >= 3 &&
+ node.arguments[2].type == "Literal"
+ ) {
+ return node.arguments[2].value;
+ }
+ return null;
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/index.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/index.js
new file mode 100644
index 0000000000..c05cb9a089
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/index.js
@@ -0,0 +1,72 @@
+/**
+ * @fileoverview A collection of rules that help enforce JavaScript coding
+ * standard and avoid common errors in the Mozilla project.
+ * 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";
+
+// ------------------------------------------------------------------------------
+// Plugin Definition
+// ------------------------------------------------------------------------------
+module.exports = {
+ configs: {
+ "browser-test": require("../lib/configs/browser-test"),
+ "chrome-test": require("../lib/configs/chrome-test"),
+ "mochitest-test": require("../lib/configs/mochitest-test"),
+ recommended: require("../lib/configs/recommended"),
+ "xpcshell-test": require("../lib/configs/xpcshell-test"),
+ },
+ environments: {
+ "browser-window": require("../lib/environments/browser-window.js"),
+ "chrome-worker": require("../lib/environments/chrome-worker.js"),
+ "frame-script": require("../lib/environments/frame-script.js"),
+ jsm: require("../lib/environments/jsm.js"),
+ simpletest: require("../lib/environments/simpletest.js"),
+ privileged: require("../lib/environments/privileged.js"),
+ xpcshell: require("../lib/environments/xpcshell.js"),
+ },
+ processors: {
+ ".xul": require("../lib/processors/xul"),
+ },
+ rules: {
+ "avoid-Date-timing": require("../lib/rules/avoid-Date-timing"),
+ "avoid-removeChild": require("../lib/rules/avoid-removeChild"),
+ "balanced-listeners": require("../lib/rules/balanced-listeners"),
+ "balanced-observers": require("../lib/rules/balanced-observers"),
+ "consistent-if-bracing": require("../lib/rules/consistent-if-bracing"),
+ "import-browser-window-globals": require("../lib/rules/import-browser-window-globals"),
+ "import-content-task-globals": require("../lib/rules/import-content-task-globals"),
+ "import-globals": require("../lib/rules/import-globals"),
+ "import-headjs-globals": require("../lib/rules/import-headjs-globals"),
+ "mark-exported-symbols-as-used": require("../lib/rules/mark-exported-symbols-as-used"),
+ "mark-test-function-used": require("../lib/rules/mark-test-function-used"),
+ "no-aArgs": require("../lib/rules/no-aArgs"),
+ "no-arbitrary-setTimeout": require("../lib/rules/no-arbitrary-setTimeout"),
+ "no-compare-against-boolean-literals": require("../lib/rules/no-compare-against-boolean-literals"),
+ "no-define-cc-etc": require("../lib/rules/no-define-cc-etc"),
+ "no-task": require("../lib/rules/no-task"),
+ "no-throw-cr-literal": require("../lib/rules/no-throw-cr-literal"),
+ "no-useless-parameters": require("../lib/rules/no-useless-parameters"),
+ "no-useless-removeEventListener": require("../lib/rules/no-useless-removeEventListener"),
+ "no-useless-run-test": require("../lib/rules/no-useless-run-test"),
+ "prefer-boolean-length-check": require("../lib/rules/prefer-boolean-length-check"),
+ "prefer-formatValues": require("../lib/rules/prefer-formatValues"),
+ "reject-chromeutils-import-null": require("../lib/rules/reject-chromeutils-import-null"),
+ "reject-importGlobalProperties": require("../lib/rules/reject-importGlobalProperties"),
+ "reject-relative-requires": require("../lib/rules/reject-relative-requires"),
+ "reject-some-requires": require("../lib/rules/reject-some-requires"),
+ "rejects-requires-await": require("../lib/rules/rejects-requires-await"),
+ "use-cc-etc": require("../lib/rules/use-cc-etc"),
+ "use-chromeutils-generateqi": require("../lib/rules/use-chromeutils-generateqi"),
+ "use-chromeutils-import": require("../lib/rules/use-chromeutils-import"),
+ "use-default-preference-values": require("../lib/rules/use-default-preference-values"),
+ "use-ownerGlobal": require("../lib/rules/use-ownerGlobal"),
+ "use-includes-instead-of-indexOf": require("../lib/rules/use-includes-instead-of-indexOf"),
+ "use-returnValue": require("../lib/rules/use-returnValue"),
+ "use-services": require("../lib/rules/use-services"),
+ "var-only-at-top-level": require("../lib/rules/var-only-at-top-level"),
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/processors/processor-helpers.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/processors/processor-helpers.js
new file mode 100644
index 0000000000..0f56debe1b
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/processors/processor-helpers.js
@@ -0,0 +1,120 @@
+/* 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";
+
+let sax = require("sax");
+
+// Converts sax's error message to something that eslint will understand
+let errorRegex = /(.*)\nLine: (\d+)\nColumn: (\d+)\nChar: (.*)/;
+function parseError(err) {
+ let matches = err.message.match(errorRegex);
+ if (!matches) {
+ return null;
+ }
+
+ return {
+ fatal: true,
+ message: matches[1],
+ line: parseInt(matches[2]) + 1,
+ column: parseInt(matches[3]),
+ };
+}
+
+let entityRegex = /&[\w][\w-\.]*;/g;
+
+// A simple sax listener that generates a tree of element information
+function XMLParser(text) {
+ // Non-strict allows us to ignore many errors from entities and
+ // preprocessing at the expense of failing to report some XML errors.
+ // Unfortunately it also throws away the case of tagnames and attributes
+ let parser = sax.parser(false, {
+ lowercase: true,
+ xmlns: true,
+ });
+
+ parser.onerror = function(err) {
+ this.lastError = parseError(err);
+ };
+
+ this.parser = parser;
+ parser.onopentag = this.onOpenTag.bind(this);
+ parser.onclosetag = this.onCloseTag.bind(this);
+ parser.ontext = this.onText.bind(this);
+ parser.onopencdata = this.onOpenCDATA.bind(this);
+ parser.oncdata = this.onCDATA.bind(this);
+ parser.oncomment = this.onComment.bind(this);
+
+ this.document = {
+ local: "#document",
+ uri: null,
+ children: [],
+ comments: [],
+ };
+ this._currentNode = this.document;
+
+ parser.write(text);
+}
+
+XMLParser.prototype = {
+ parser: null,
+
+ lastError: null,
+
+ onOpenTag(tag) {
+ let node = {
+ parentNode: this._currentNode,
+ local: tag.local,
+ namespace: tag.uri,
+ attributes: {},
+ children: [],
+ comments: [],
+ textContent: "",
+ textLine: this.parser.line,
+ textColumn: this.parser.column,
+ textEndLine: this.parser.line,
+ };
+
+ for (let attr of Object.keys(tag.attributes)) {
+ if (tag.attributes[attr].uri == "") {
+ node.attributes[attr] = tag.attributes[attr].value;
+ }
+ }
+
+ this._currentNode.children.push(node);
+ this._currentNode = node;
+ },
+
+ onCloseTag(tagname) {
+ this._currentNode.textEndLine = this.parser.line;
+ this._currentNode = this._currentNode.parentNode;
+ },
+
+ addText(text) {
+ this._currentNode.textContent += text;
+ },
+
+ onText(text) {
+ // Replace entities with some valid JS token.
+ this.addText(text.replace(entityRegex, "null"));
+ },
+
+ onOpenCDATA() {
+ // Turn the CDATA opening tag into whitespace for indent alignment
+ this.addText(" ".repeat("<![CDATA[".length));
+ },
+
+ onCDATA(text) {
+ this.addText(text);
+ },
+
+ onComment(text) {
+ this._currentNode.comments.push(text);
+ },
+};
+
+module.exports = {
+ XMLParser,
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/processors/xul.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/processors/xul.js
new file mode 100644
index 0000000000..c486b38e06
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/processors/xul.js
@@ -0,0 +1,262 @@
+/**
+ * @fileoverview Converts inline attributes from XUL into JS
+ * functions
+ *
+ * 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";
+
+let path = require("path");
+let fs = require("fs");
+
+let XMLParser = require("./processor-helpers").XMLParser;
+
+// Stores any XML parse error
+let xmlParseError = null;
+
+// Stores the lines of JS code generated from the XUL.
+let scriptLines = [];
+// Stores a map from the synthetic line number to the real line number
+// and column offset.
+let lineMap = [];
+
+let includedRanges = [];
+
+// Deal with ifdefs. This is the state we pretend to have:
+const kIfdefStateForLinting = {
+ MOZ_UPDATER: true,
+ XP_WIN: true,
+ MOZ_BUILD_APP_IS_BROWSER: true,
+ MOZ_SERVICES_SYNC: true,
+ MOZ_DATA_REPORTING: true,
+ MOZ_TELEMETRY_REPORTING: true,
+ MOZ_CRASHREPORTER: true,
+ MOZ_NORMANDY: true,
+ MOZ_MAINTENANCE_SERVICE: true,
+ HAVE_SHELL_SERVICE: true,
+ MENUBAR_CAN_AUTOHIDE: true,
+ MOZILLA_OFFICIAL: true,
+};
+
+// Anything not in the above list is assumed false.
+function dealWithIfdefs(text, filename) {
+ function stripIfdefsFromLines(input, innerFile) {
+ let outputLines = [];
+ let inSkippingIfdef = [false];
+ for (let i = 0; i < input.length; i++) {
+ let line = input[i];
+ let shouldSkip = inSkippingIfdef.some(x => x);
+ if (!line.startsWith("#")) {
+ outputLines.push(shouldSkip ? "" : line);
+ } else {
+ if (
+ line.startsWith("# ") ||
+ line.startsWith("#filter") ||
+ line == "#" ||
+ line.startsWith("#define")
+ ) {
+ outputLines.push("");
+ continue;
+ }
+ // if this isn't just a comment (which we skip), figure out what to do:
+ let term = "";
+ let negate = false;
+ if (line.startsWith("#ifdef")) {
+ term = line.match(/^#ifdef *([A-Z_]+)/);
+ } else if (line.startsWith("#ifndef")) {
+ term = line.match(/^#ifndef *([A-Z_]+)/);
+ negate = true;
+ } else if (line.startsWith("#if ")) {
+ term = line.match(/^defined\(([A-Z_]+)\)/);
+ } else if (line.startsWith("#elifdef")) {
+ // Replace the old one:
+ inSkippingIfdef.pop();
+ term = line.match(/^#elifdef *([A-Z_]+)/);
+ } else if (line.startsWith("#else")) {
+ // Switch the last one around:
+ let old = inSkippingIfdef.pop();
+ inSkippingIfdef.push(!old);
+ outputLines.push("");
+ } else if (line.startsWith("#endif")) {
+ inSkippingIfdef.pop();
+ outputLines.push("");
+ } else if (line.startsWith("#expand")) {
+ // Just strip expansion instructions
+ outputLines.push(line.substring("#expand ".length));
+ } else if (line.startsWith("#include")) {
+ // Uh oh.
+ if (!shouldSkip) {
+ let fileToInclude = line.substr("#include ".length).trim();
+ let subpath = path.join(path.dirname(innerFile), fileToInclude);
+ let contents = fs.readFileSync(subpath, { encoding: "utf-8" });
+ contents = contents.split(/\n/);
+ // Recurse:
+ contents = stripIfdefsFromLines(contents, subpath);
+ if (innerFile == filename) {
+ includedRanges.push({
+ start: i,
+ end: i + contents.length,
+ filename: subpath,
+ });
+ }
+ // And insert the resulting lines:
+ input = input.slice(0, i).concat(contents, input.slice(i + 1));
+ // Re-process this line now that we've spliced things in.
+ i--;
+ } else {
+ outputLines.push("");
+ }
+ } else {
+ throw new Error("Unknown preprocessor directive: " + line);
+ }
+
+ if (term) {
+ // We always want the first capturing subgroup:
+ term = term && term[1];
+ if (!negate) {
+ inSkippingIfdef.push(!kIfdefStateForLinting[term]);
+ } else {
+ inSkippingIfdef.push(kIfdefStateForLinting[term]);
+ }
+ outputLines.push("");
+ // Now just continue; we'll include lines depending on the state of `inSkippingIfdef`.
+ }
+ }
+ }
+ return outputLines;
+ }
+ let lines = text.split(/\n/);
+ return stripIfdefsFromLines(lines, filename).join("\n");
+}
+
+function addSyntheticLine(line, linePos, addDisableLine) {
+ lineMap[scriptLines.length] = { line: linePos };
+ scriptLines.push(line + (addDisableLine ? "" : " // eslint-disable-line"));
+}
+
+function recursiveExpand(node) {
+ for (let [attr, value] of Object.entries(node.attributes)) {
+ if (attr.startsWith("on")) {
+ if (attr == "oncommand" && value == ";") {
+ // Ignore these, see bug 371900 for why people might do this.
+ continue;
+ }
+ // Ignore dashes in the tag name
+ let nodeDesc = node.local.replace(/-/g, "");
+ if (node.attributes.id) {
+ nodeDesc += "_" + node.attributes.id.replace(/[^a-z]/gi, "_");
+ }
+ if (node.attributes.class) {
+ nodeDesc += "_" + node.attributes.class.replace(/[^a-z]/gi, "_");
+ }
+ addSyntheticLine("function " + nodeDesc + "(event) {", node.textLine);
+ let processedLines = value.split(/\r?\n/);
+ let addlLine = 0;
+ for (let line of processedLines) {
+ line = line.replace(/^\s*/, "");
+ lineMap[scriptLines.length] = {
+ // Unfortunately, we only get a line number for the <tag> finishing,
+ // not for individual attributes.
+ line: node.textLine + addlLine,
+ };
+ scriptLines.push(line);
+ addlLine++;
+ }
+ addSyntheticLine("}", node.textLine + processedLines.length - 1);
+ }
+ }
+ for (let kid of node.children) {
+ recursiveExpand(kid);
+ }
+}
+
+module.exports = {
+ preprocess(text, filename) {
+ if (filename.includes(".inc")) {
+ return [];
+ }
+ xmlParseError = null;
+ // The following rules are annoying in XUL.
+ // Indent because in multiline attributes it's impossible to understand for the XML parser.
+ // Semicolons because those shouldn't be required for inline event handlers.
+ // Quotes because we use doublequotes for attributes so using single quotes
+ // for strings inside them makes sense.
+ // No-undef because it's a bunch of work to teach this code how to read
+ // scripts and get globals from them (though ideally we should do that at some point).
+ scriptLines = [
+ "/* eslint-disable indent */",
+ "/* eslint-disable indent-legacy */",
+ "/* eslint-disable semi */",
+ "/* eslint-disable quotes */",
+ "/* eslint-disable no-undef */",
+ ];
+ lineMap = scriptLines.map(() => ({ line: 0 }));
+ includedRanges = [];
+ // Do C-style preprocessing first:
+ text = dealWithIfdefs(text, filename);
+
+ let xp = new XMLParser(text);
+ if (xp.lastError) {
+ xmlParseError = xp.lastError;
+ }
+ let doc = xp.document;
+ if (!doc) {
+ return [];
+ }
+ let node = doc;
+ for (let kid of node.children) {
+ recursiveExpand(kid);
+ }
+
+ let scriptText = scriptLines.join("\n") + "\n";
+ return [scriptText];
+ },
+
+ postprocess(messages, filename) {
+ // If there was an XML parse error then just return that
+ if (xmlParseError) {
+ return [xmlParseError];
+ }
+
+ // For every message from every script block update the line to point to the
+ // correct place.
+ let errors = [];
+ for (let i = 0; i < messages.length; i++) {
+ for (let message of messages[i]) {
+ // ESLint indexes lines starting at 1 but our arrays start at 0
+ let mapped = lineMap[message.line - 1];
+ // Ensure we don't modify this by making a copy. We might need it for another failure.
+ let target = mapped.line;
+ let includedRange = includedRanges.find(
+ r => target >= r.start && target <= r.end
+ );
+ // If this came from an #included file, indicate this in the message
+ if (includedRange) {
+ target = includedRange.start;
+ message.message +=
+ " (from included file " +
+ path.basename(includedRange.filename) +
+ ")";
+ }
+ // Compensate for line numbers shifting as a result of #include:
+ let includeBallooning = includedRanges
+ .filter(r => target >= r.end)
+ .map(r => r.end - r.start)
+ .reduce((acc, next) => acc + next, 0);
+ target -= includeBallooning;
+ // Add back the 1 to go back to 1-indexing.
+ message.line = target + 1;
+
+ // We never have column information, unfortunately.
+ message.column = NaN;
+
+ errors.push(message);
+ }
+ }
+
+ return errors;
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/avoid-Date-timing.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/avoid-Date-timing.js
new file mode 100644
index 0000000000..4f06390189
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/avoid-Date-timing.js
@@ -0,0 +1,67 @@
+/**
+ * @fileoverview Disallow using Date for timing in performance sensitive code
+ *
+ * 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
+// -----------------------------------------------------------------------------
+
+module.exports = {
+ meta: {
+ docs: {
+ description: "disallow use of Date for timing measurements",
+ category: "Best Practices",
+ },
+ schema: [],
+ },
+
+ // ---------------------------------------------------------------------------
+ // Public
+ // --------------------------------------------------------------------------
+
+ create(context) {
+ return {
+ CallExpression(node) {
+ let callee = node.callee;
+ if (
+ callee.type !== "MemberExpression" ||
+ callee.object.type !== "Identifier" ||
+ callee.object.name !== "Date" ||
+ callee.property.type !== "Identifier" ||
+ callee.property.name !== "now"
+ ) {
+ return;
+ }
+
+ context.report(
+ node,
+ "use performance.now() instead of Date.now() for timing " +
+ "measurements"
+ );
+ },
+
+ NewExpression(node) {
+ let callee = node.callee;
+ if (
+ callee.type !== "Identifier" ||
+ callee.name !== "Date" ||
+ node.arguments.length > 0
+ ) {
+ return;
+ }
+
+ context.report(
+ node,
+ "use performance.now() instead of new Date() for timing " +
+ "measurements"
+ );
+ },
+ };
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/avoid-removeChild.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/avoid-removeChild.js
new file mode 100644
index 0000000000..99d0ff5027
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/avoid-removeChild.js
@@ -0,0 +1,64 @@
+/**
+ * @fileoverview Reject using element.parentNode.removeChild(element) when
+ * element.remove() can be used instead.
+ *
+ * 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 helpers = require("../helpers");
+
+module.exports = function(context) {
+ // ---------------------------------------------------------------------------
+ // Public
+ // --------------------------------------------------------------------------
+
+ return {
+ CallExpression(node) {
+ let callee = node.callee;
+ if (
+ callee.type !== "MemberExpression" ||
+ callee.property.type !== "Identifier" ||
+ callee.property.name != "removeChild" ||
+ node.arguments.length != 1
+ ) {
+ return;
+ }
+
+ if (
+ callee.object.type == "MemberExpression" &&
+ callee.object.property.type == "Identifier" &&
+ callee.object.property.name == "parentNode" &&
+ helpers.getASTSource(callee.object.object, context) ==
+ helpers.getASTSource(node.arguments[0])
+ ) {
+ context.report(
+ node,
+ "use element.remove() instead of " +
+ "element.parentNode.removeChild(element)"
+ );
+ }
+
+ if (
+ node.arguments[0].type == "MemberExpression" &&
+ node.arguments[0].property.type == "Identifier" &&
+ node.arguments[0].property.name == "firstChild" &&
+ helpers.getASTSource(callee.object, context) ==
+ helpers.getASTSource(node.arguments[0].object)
+ ) {
+ context.report(
+ node,
+ "use element.firstChild.remove() instead of " +
+ "element.removeChild(element.firstChild)"
+ );
+ }
+ },
+ };
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/balanced-listeners.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/balanced-listeners.js
new file mode 100644
index 0000000000..b6fb25139a
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/balanced-listeners.js
@@ -0,0 +1,147 @@
+/**
+ * @fileoverview Check that there's a removeEventListener for each
+ * addEventListener and an off for each on.
+ * Note that for now, this rule is rather simple in that it only checks that
+ * for each event name there is both an add and remove listener. It doesn't
+ * check that these are called on the right objects or with the same callback.
+ *
+ * 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
+// -----------------------------------------------------------------------------
+
+module.exports = function(context) {
+ // ---------------------------------------------------------------------------
+ // Helpers
+ // ---------------------------------------------------------------------------
+
+ var DICTIONARY = {
+ addEventListener: "removeEventListener",
+ on: "off",
+ };
+ // Invert this dictionary to make it easy later.
+ var INVERTED_DICTIONARY = {};
+ for (var i in DICTIONARY) {
+ INVERTED_DICTIONARY[DICTIONARY[i]] = i;
+ }
+
+ // Collect the add/remove listeners in these 2 arrays.
+ var addedListeners = [];
+ var removedListeners = [];
+
+ function addAddedListener(node) {
+ var capture = false;
+ let options = node.arguments[2];
+ if (options) {
+ if (options.type == "ObjectExpression") {
+ if (
+ options.properties.some(
+ p => p.key.name == "once" && p.value.value === true
+ )
+ ) {
+ // No point in adding listeners using the 'once' option.
+ return;
+ }
+ capture = options.properties.some(
+ p => p.key.name == "capture" && p.value.value === true
+ );
+ } else {
+ capture = options.value;
+ }
+ }
+ addedListeners.push({
+ functionName: node.callee.property.name,
+ type: node.arguments[0].value,
+ node: node.callee.property,
+ useCapture: capture,
+ });
+ }
+
+ function addRemovedListener(node) {
+ var capture = false;
+ let options = node.arguments[2];
+ if (options) {
+ if (options.type == "ObjectExpression") {
+ capture = options.properties.some(
+ p => p.key.name == "capture" && p.value.value === true
+ );
+ } else {
+ capture = options.value;
+ }
+ }
+ removedListeners.push({
+ functionName: node.callee.property.name,
+ type: node.arguments[0].value,
+ useCapture: capture,
+ });
+ }
+
+ function getUnbalancedListeners() {
+ var unbalanced = [];
+
+ for (var j = 0; j < addedListeners.length; j++) {
+ if (!hasRemovedListener(addedListeners[j])) {
+ unbalanced.push(addedListeners[j]);
+ }
+ }
+ addedListeners = removedListeners = [];
+
+ return unbalanced;
+ }
+
+ function hasRemovedListener(addedListener) {
+ for (var k = 0; k < removedListeners.length; k++) {
+ var listener = removedListeners[k];
+ if (
+ DICTIONARY[addedListener.functionName] === listener.functionName &&
+ addedListener.type === listener.type &&
+ addedListener.useCapture === listener.useCapture
+ ) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ // ---------------------------------------------------------------------------
+ // Public
+ // ---------------------------------------------------------------------------
+
+ return {
+ CallExpression(node) {
+ if (node.arguments.length === 0) {
+ return;
+ }
+
+ if (node.callee.type === "MemberExpression") {
+ var listenerMethodName = node.callee.property.name;
+
+ if (DICTIONARY.hasOwnProperty(listenerMethodName)) {
+ addAddedListener(node);
+ } else if (INVERTED_DICTIONARY.hasOwnProperty(listenerMethodName)) {
+ addRemovedListener(node);
+ }
+ }
+ },
+
+ "Program:exit": function() {
+ getUnbalancedListeners().forEach(function(listener) {
+ context.report(
+ listener.node,
+ "No corresponding '{{functionName}}({{type}})' was found.",
+ {
+ functionName: DICTIONARY[listener.functionName],
+ type: listener.type,
+ }
+ );
+ });
+ },
+ };
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/balanced-observers.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/balanced-observers.js
new file mode 100644
index 0000000000..f714b31cda
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/balanced-observers.js
@@ -0,0 +1,119 @@
+/**
+ * @fileoverview Check that there's a Services.(prefs|obs).removeObserver for
+ * each addObserver.
+ *
+ * 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
+// -----------------------------------------------------------------------------
+
+module.exports = function(context) {
+ // ---------------------------------------------------------------------------
+ // Helpers
+ // ---------------------------------------------------------------------------
+
+ var addedObservers = [];
+ var removedObservers = [];
+
+ function getObserverAPI(node) {
+ const object = node.callee.object;
+ if (
+ object.type == "MemberExpression" &&
+ object.property.type == "Identifier"
+ ) {
+ return object.property.name;
+ }
+ return null;
+ }
+
+ function isServicesObserver(api) {
+ return api == "obs" || api == "prefs";
+ }
+
+ function getObservableName(node, api) {
+ if (api === "obs") {
+ return node.arguments[1].value;
+ }
+ return node.arguments[0].value;
+ }
+
+ function addAddedObserver(node) {
+ const api = getObserverAPI(node);
+ if (!isServicesObserver(api)) {
+ return;
+ }
+
+ addedObservers.push({
+ functionName: node.callee.property.name,
+ observable: getObservableName(node, api),
+ node: node.callee.property,
+ });
+ }
+
+ function addRemovedObserver(node) {
+ const api = getObserverAPI(node);
+ if (!isServicesObserver(api)) {
+ return;
+ }
+
+ removedObservers.push({
+ functionName: node.callee.property.name,
+ observable: getObservableName(node, api),
+ });
+ }
+
+ function getUnbalancedObservers() {
+ const unbalanced = addedObservers.filter(
+ observer => !hasRemovedObserver(observer)
+ );
+ addedObservers = removedObservers = [];
+
+ return unbalanced;
+ }
+
+ function hasRemovedObserver(addedObserver) {
+ return removedObservers.some(
+ observer => addedObserver.observable === observer.observable
+ );
+ }
+
+ // ---------------------------------------------------------------------------
+ // Public
+ // ---------------------------------------------------------------------------
+
+ return {
+ CallExpression(node) {
+ if (node.arguments.length === 0) {
+ return;
+ }
+
+ if (node.callee.type === "MemberExpression") {
+ var methodName = node.callee.property.name;
+
+ if (methodName === "addObserver") {
+ addAddedObserver(node);
+ } else if (methodName === "removeObserver") {
+ addRemovedObserver(node);
+ }
+ }
+ },
+
+ "Program:exit": function() {
+ getUnbalancedObservers().forEach(function(observer) {
+ context.report(
+ observer.node,
+ "No corresponding 'removeObserver(\"{{observable}}\")' was found.",
+ {
+ observable: observer.observable,
+ }
+ );
+ });
+ },
+ };
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/consistent-if-bracing.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/consistent-if-bracing.js
new file mode 100644
index 0000000000..af51dcea1f
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/consistent-if-bracing.js
@@ -0,0 +1,49 @@
+/**
+ * @fileoverview checks if/else if/else bracing is consistent
+ *
+ * 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 = {
+ meta: {
+ messages: {
+ consistentIfBracing: "Bracing of if..else bodies should be consistent.",
+ },
+ },
+
+ create(context) {
+ return {
+ IfStatement(node) {
+ if (node.parent.type !== "IfStatement") {
+ let types = new Set();
+ for (
+ let currentNode = node;
+ currentNode;
+ currentNode = currentNode.alternate
+ ) {
+ let type = currentNode.consequent.type;
+ types.add(type == "BlockStatement" ? "Block" : "NotBlock");
+ if (
+ currentNode.alternate &&
+ currentNode.alternate.type !== "IfStatement"
+ ) {
+ type = currentNode.alternate.type;
+ types.add(type == "BlockStatement" ? "Block" : "NotBlock");
+ break;
+ }
+ }
+ if (types.size > 1) {
+ context.report({
+ node,
+ messageId: "consistentIfBracing",
+ });
+ }
+ }
+ },
+ };
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/import-browser-window-globals.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/import-browser-window-globals.js
new file mode 100644
index 0000000000..bcbdb3ec54
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/import-browser-window-globals.js
@@ -0,0 +1,49 @@
+/**
+ * @fileoverview For scripts included in browser-window, this will automatically
+ * inject the browser-window global scopes into the file.
+ *
+ * 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 helpers = require("../helpers");
+var browserWindowEnv = require("../environments/browser-window");
+
+module.exports = function(context) {
+ // ---------------------------------------------------------------------------
+ // Public
+ // ---------------------------------------------------------------------------
+
+ return {
+ Program(node) {
+ let filePath = helpers.getAbsoluteFilePath(context);
+ let relativePath = path.relative(helpers.rootDir, filePath);
+ // We need to translate the path on Windows, due to the change
+ // from \ to /, and browserjsScripts assumes Posix.
+ if (path.win32) {
+ relativePath = relativePath.split(path.sep).join("/");
+ }
+
+ if (
+ browserWindowEnv.browserjsScripts &&
+ browserWindowEnv.browserjsScripts.includes(relativePath)
+ ) {
+ for (let global in browserWindowEnv.globals) {
+ helpers.addVarToScope(
+ global,
+ context.getScope(),
+ browserWindowEnv.globals[global]
+ );
+ }
+ }
+ },
+ };
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/import-content-task-globals.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/import-content-task-globals.js
new file mode 100644
index 0000000000..b8545b45f8
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/import-content-task-globals.js
@@ -0,0 +1,84 @@
+/**
+ * @fileoverview For ContentTask.spawn, this will automatically declare the
+ * frame script variables in the global scope.
+ * Note: due to the way ESLint works, it appears it is only
+ * easy to declare these variables on a file-global scope, rather
+ * than function global.
+ *
+ * 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 helpers = require("../helpers");
+var frameScriptEnv = require("../environments/frame-script");
+
+// The global environment of SpecialPowers.spawn tasks is
+// controlled by the Sandbox environment created by
+// SpecialPowersSandbox.jsm. This list should be kept in sync with
+// that module.
+var sandboxGlobals = [
+ "Assert",
+ "Blob",
+ "BrowsingContext",
+ "ChromeUtils",
+ "ContentTaskUtils",
+ "EventUtils",
+ "Services",
+ "TextDecoder",
+ "TextEncoder",
+ "URL",
+ "assert",
+ "info",
+ "is",
+ "isnot",
+ "ok",
+ "todo",
+ "todo_is",
+];
+
+module.exports = function(context) {
+ // ---------------------------------------------------------------------------
+ // Public
+ // ---------------------------------------------------------------------------
+
+ return {
+ "CallExpression[callee.object.name='ContentTask'][callee.property.name='spawn']": function(
+ node
+ ) {
+ for (let global in frameScriptEnv.globals) {
+ helpers.addVarToScope(
+ global,
+ context.getScope(),
+ frameScriptEnv.globals[global]
+ );
+ }
+ },
+ "CallExpression[callee.object.name='SpecialPowers'][callee.property.name='spawn']": function(
+ node
+ ) {
+ let globals = [...sandboxGlobals, "SpecialPowers", "content", "docShell"];
+ for (let global of globals) {
+ helpers.addVarToScope(global, context.getScope(), false);
+ }
+ },
+ "CallExpression[callee.object.name='SpecialPowers'][callee.property.name='spawnChrome']": function(
+ node
+ ) {
+ let globals = [
+ ...sandboxGlobals,
+ "browsingContext",
+ "windowGlobalParent",
+ ];
+ for (let global of globals) {
+ helpers.addVarToScope(global, context.getScope(), false);
+ }
+ },
+ };
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/import-globals.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/import-globals.js
new file mode 100644
index 0000000000..053a9e702f
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/import-globals.js
@@ -0,0 +1,15 @@
+/**
+ * @fileoverview Discovers all globals for the current file.
+ *
+ * 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
+// -----------------------------------------------------------------------------
+
+module.exports = require("../globals").getESLintGlobalParser;
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/import-headjs-globals.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/import-headjs-globals.js
new file mode 100644
index 0000000000..cffd7a4c8e
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/import-headjs-globals.js
@@ -0,0 +1,47 @@
+/**
+ * @fileoverview Import globals from head.js and from any files that were
+ * imported by head.js (as far as we can correctly resolve the path).
+ *
+ * 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 globals = require("../globals");
+
+module.exports = function(context) {
+ function importHead(path, node) {
+ try {
+ let stats = fs.statSync(path);
+ if (!stats.isFile()) {
+ return;
+ }
+ } catch (e) {
+ return;
+ }
+
+ let newGlobals = globals.getGlobalsForFile(path);
+ helpers.addGlobals(newGlobals, context.getScope());
+ }
+
+ // ---------------------------------------------------------------------------
+ // Public
+ // ---------------------------------------------------------------------------
+
+ return {
+ Program(node) {
+ let heads = helpers.getTestHeadFiles(context);
+ for (let head of heads) {
+ importHead(head, node);
+ }
+ },
+ };
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/mark-exported-symbols-as-used.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/mark-exported-symbols-as-used.js
new file mode 100644
index 0000000000..c535a54a16
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/mark-exported-symbols-as-used.js
@@ -0,0 +1,83 @@
+/**
+ * @fileoverview Simply marks exported symbols as used. Designed for use in
+ * .jsm files only.
+ *
+ * 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";
+
+function markArrayElementsAsUsed(context, node, expression) {
+ if (expression.type != "ArrayExpression") {
+ context.report({
+ node,
+ message: "Unexpected assignment of non-Array to EXPORTED_SYMBOLS",
+ });
+ return;
+ }
+
+ for (let element of expression.elements) {
+ context.markVariableAsUsed(element.value);
+ }
+ // Also mark EXPORTED_SYMBOLS as used.
+ context.markVariableAsUsed("EXPORTED_SYMBOLS");
+}
+
+// -----------------------------------------------------------------------------
+// Rule Definition
+// -----------------------------------------------------------------------------
+
+module.exports = function(context) {
+ // Ignore assignments not in the global scope, e.g. where special module
+ // definitions are required due to having different ways of importing files,
+ // e.g. osfile.
+ function isGlobalScope() {
+ return !context.getScope().upper;
+ }
+
+ // ---------------------------------------------------------------------------
+ // Public
+ // ---------------------------------------------------------------------------
+
+ return {
+ AssignmentExpression(node, parents) {
+ if (
+ node.operator === "=" &&
+ node.left.type === "MemberExpression" &&
+ node.left.object.type === "ThisExpression" &&
+ node.left.property.name === "EXPORTED_SYMBOLS" &&
+ isGlobalScope()
+ ) {
+ markArrayElementsAsUsed(context, node, node.right);
+ }
+ },
+
+ VariableDeclaration(node, parents) {
+ if (!isGlobalScope()) {
+ return;
+ }
+
+ for (let item of node.declarations) {
+ if (
+ item.id &&
+ item.id.type == "Identifier" &&
+ item.id.name === "EXPORTED_SYMBOLS"
+ ) {
+ if (node.kind === "let") {
+ // The use of 'let' isn't allowed as the lexical scope may die after
+ // the script executes.
+ context.report({
+ node,
+ message:
+ "EXPORTED_SYMBOLS cannot be declared via `let`. Use `var` or `this.EXPORTED_SYMBOLS =`",
+ });
+ }
+
+ markArrayElementsAsUsed(context, node, item.init);
+ }
+ }
+ },
+ };
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/mark-test-function-used.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/mark-test-function-used.js
new file mode 100644
index 0000000000..0c0dcfdbe5
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/mark-test-function-used.js
@@ -0,0 +1,37 @@
+/**
+ * @fileoverview Simply marks `test` (the test method) or `run_test` as used
+ * when in mochitests or xpcshell tests respectively. This avoids ESLint telling
+ * us that the function is never called.
+ *
+ * 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 helpers = require("../helpers");
+
+module.exports = function(context) {
+ // ---------------------------------------------------------------------------
+ // Public
+ // ---------------------------------------------------------------------------
+
+ return {
+ Program() {
+ let testType = helpers.getTestType(context);
+ if (testType == "browser") {
+ context.markVariableAsUsed("test");
+ return;
+ }
+
+ if (testType == "xpcshell") {
+ context.markVariableAsUsed("run_test");
+ }
+ },
+ };
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-aArgs.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-aArgs.js
new file mode 100644
index 0000000000..af7fe06336
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-aArgs.js
@@ -0,0 +1,56 @@
+/**
+ * @fileoverview warns against using hungarian notation in function arguments
+ * (i.e. aArg).
+ *
+ * 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
+// -----------------------------------------------------------------------------
+
+module.exports = function(context) {
+ // ---------------------------------------------------------------------------
+ // Helpers
+ // ---------------------------------------------------------------------------
+
+ function isPrefixed(name) {
+ return name.length >= 2 && /^a[A-Z]/.test(name);
+ }
+
+ function deHungarianize(name) {
+ return name.substring(1, 2).toLowerCase() + name.substring(2, name.length);
+ }
+
+ function checkFunction(node) {
+ for (var i = 0; i < node.params.length; i++) {
+ var param = node.params[i];
+ if (param.name && isPrefixed(param.name)) {
+ var errorObj = {
+ name: param.name,
+ suggestion: deHungarianize(param.name),
+ };
+ context.report(
+ param,
+ "Parameter '{{name}}' uses Hungarian Notation, " +
+ "consider using '{{suggestion}}' instead.",
+ errorObj
+ );
+ }
+ }
+ }
+
+ // ---------------------------------------------------------------------------
+ // Public
+ // ---------------------------------------------------------------------------
+
+ return {
+ FunctionDeclaration: checkFunction,
+ ArrowFunctionExpression: checkFunction,
+ FunctionExpression: checkFunction,
+ };
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-arbitrary-setTimeout.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-arbitrary-setTimeout.js
new file mode 100644
index 0000000000..be0b5c5ffb
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-arbitrary-setTimeout.js
@@ -0,0 +1,70 @@
+/**
+ * @fileoverview Reject use of non-zero values in setTimeout
+ *
+ * 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 helpers = require("../helpers");
+var testTypes = new Set(["browser", "xpcshell"]);
+
+module.exports = {
+ meta: {
+ docs: {
+ description: "disallow setTimeout with non-zero values in tests",
+ category: "Best Practices",
+ },
+ schema: [],
+ },
+
+ // ---------------------------------------------------------------------------
+ // Public
+ // --------------------------------------------------------------------------
+
+ create(context) {
+ return {
+ CallExpression(node) {
+ // We don't want to run this on mochitest plain as it already
+ // prevents flaky setTimeout at runtime. This check is built-in
+ // to the rule itself as sometimes other tests can live alongside
+ // plain mochitests and so it can't be configured via eslintrc.
+ if (!testTypes.has(helpers.getTestType(context))) {
+ return;
+ }
+
+ let callee = node.callee;
+ if (callee.type === "MemberExpression") {
+ if (
+ callee.property.name !== "setTimeout" ||
+ callee.object.name !== "window" ||
+ node.arguments.length < 2
+ ) {
+ return;
+ }
+ } else if (callee.type === "Identifier") {
+ if (callee.name !== "setTimeout" || node.arguments.length < 2) {
+ return;
+ }
+ } else {
+ return;
+ }
+
+ let timeout = node.arguments[1];
+ if (timeout.type !== "Literal" || timeout.value > 0) {
+ context.report(
+ node,
+ "listen for events instead of setTimeout() " +
+ "with arbitrary delay"
+ );
+ }
+ },
+ };
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-compare-against-boolean-literals.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-compare-against-boolean-literals.js
new file mode 100644
index 0000000000..bb48563fff
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-compare-against-boolean-literals.js
@@ -0,0 +1,34 @@
+/**
+ * @fileoverview Restrict comparing against `true` or `false`.
+ *
+ * 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
+// -----------------------------------------------------------------------------
+
+module.exports = function(context) {
+ // ---------------------------------------------------------------------------
+ // Public
+ // --------------------------------------------------------------------------
+
+ return {
+ BinaryExpression(node) {
+ if (
+ ["==", "!="].includes(node.operator) &&
+ (["true", "false"].includes(node.left.raw) ||
+ ["true", "false"].includes(node.right.raw))
+ ) {
+ context.report(
+ node,
+ "Don't compare for inexact equality against boolean literals"
+ );
+ }
+ },
+ };
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-define-cc-etc.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-define-cc-etc.js
new file mode 100644
index 0000000000..0b441e4712
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-define-cc-etc.js
@@ -0,0 +1,49 @@
+/**
+ * @fileoverview Reject defining Cc/Ci/Cr/Cu.
+ *
+ * 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
+// -----------------------------------------------------------------------------
+
+const componentsBlacklist = ["Cc", "Ci", "Cr", "Cu"];
+
+module.exports = function(context) {
+ // ---------------------------------------------------------------------------
+ // Public
+ // --------------------------------------------------------------------------
+
+ return {
+ VariableDeclarator(node) {
+ if (
+ node.id.type == "Identifier" &&
+ componentsBlacklist.includes(node.id.name)
+ ) {
+ context.report(
+ node,
+ `${node.id.name} is now defined in global scope, a separate definition is no longer necessary.`
+ );
+ }
+
+ if (node.id.type == "ObjectPattern") {
+ for (let property of node.id.properties) {
+ if (
+ property.type == "Property" &&
+ componentsBlacklist.includes(property.value.name)
+ ) {
+ context.report(
+ node,
+ `${property.value.name} is now defined in global scope, a separate definition is no longer necessary.`
+ );
+ }
+ }
+ }
+ },
+ };
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-task.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-task.js
new file mode 100644
index 0000000000..2bab6e8742
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-task.js
@@ -0,0 +1,33 @@
+/**
+ * @fileoverview Reject common XPCOM methods called with useless optional
+ * parameters, or non-existent parameters.
+ *
+ * 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
+// -----------------------------------------------------------------------------
+
+module.exports = function(context) {
+ // ---------------------------------------------------------------------------
+ // Public
+ // --------------------------------------------------------------------------
+
+ return {
+ CallExpression(node) {
+ let callee = node.callee;
+ if (
+ callee.type === "MemberExpression" &&
+ callee.object.type === "Identifier" &&
+ callee.object.name === "Task"
+ ) {
+ context.report({ node, message: "Task.jsm is deprecated." });
+ }
+ },
+ };
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-throw-cr-literal.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-throw-cr-literal.js
new file mode 100644
index 0000000000..21f27ff130
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-throw-cr-literal.js
@@ -0,0 +1,100 @@
+/**
+ * @fileoverview Rule to prevent throwing bare Cr.ERRORs.
+ *
+ * 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
+// -----------------------------------------------------------------------------
+
+function isCr(object) {
+ return object.type === "Identifier" && object.name === "Cr";
+}
+
+function isComponentsResults(object) {
+ return (
+ object.type === "MemberExpression" &&
+ object.object.type === "Identifier" &&
+ object.object.name === "Components" &&
+ object.property.type === "Identifier" &&
+ object.property.name === "results"
+ );
+}
+
+function isNewError(argument) {
+ return (
+ argument.type === "NewExpression" &&
+ argument.callee.type === "Identifier" &&
+ argument.callee.name === "Error" &&
+ argument.arguments.length === 1
+ );
+}
+
+function fixT(context, node, argument, fixer) {
+ const sourceText = context.getSourceCode().getText(argument);
+ return fixer.replaceText(node, `Components.Exception("", ${sourceText})`);
+}
+
+module.exports = {
+ meta: {
+ fixable: "code",
+ messages: {
+ bareCR: "Do not throw bare Cr.ERRORs, use Components.Exception instead",
+ bareComponentsResults:
+ "Do not throw bare Components.results.ERRORs, use Components.Exception instead",
+ newErrorCR:
+ "Do not pass Cr.ERRORs to new Error(), use Components.Exception instead",
+ newErrorComponentsResults:
+ "Do not pass Components.results.ERRORs to new Error(), use Components.Exception instead",
+ },
+ },
+
+ create(context) {
+ return {
+ ThrowStatement(node) {
+ if (node.argument.type === "MemberExpression") {
+ const fix = fixT.bind(null, context, node.argument, node.argument);
+
+ if (isCr(node.argument.object)) {
+ context.report({
+ node,
+ messageId: "bareCR",
+ fix,
+ });
+ } else if (isComponentsResults(node.argument.object)) {
+ context.report({
+ node,
+ messageId: "bareComponentsResults",
+ fix,
+ });
+ }
+ } else if (isNewError(node.argument)) {
+ const argument = node.argument.arguments[0];
+
+ if (argument.type === "MemberExpression") {
+ const fix = fixT.bind(null, context, node.argument, argument);
+
+ if (isCr(argument.object)) {
+ context.report({
+ node,
+ messageId: "newErrorCR",
+ fix,
+ });
+ } else if (isComponentsResults(argument.object)) {
+ context.report({
+ node,
+ messageId: "newErrorComponentsResults",
+ fix,
+ });
+ }
+ }
+ }
+ },
+ };
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-useless-parameters.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-useless-parameters.js
new file mode 100644
index 0000000000..4fd0734465
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-useless-parameters.js
@@ -0,0 +1,147 @@
+/**
+ * @fileoverview Reject common XPCOM methods called with useless optional
+ * parameters, or non-existent parameters.
+ *
+ * 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
+// -----------------------------------------------------------------------------
+
+module.exports = {
+ meta: {
+ type: "suggestion",
+ fixable: "code",
+ },
+ create(context) {
+ function getRangeAfterArgToEnd(argNumber, args) {
+ let sourceCode = context.getSourceCode();
+ return [
+ sourceCode.getTokenAfter(args[argNumber]).range[0],
+ args[args.length - 1].range[1],
+ ];
+ }
+
+ // ---------------------------------------------------------------------------
+ // Public
+ // --------------------------------------------------------------------------
+
+ return {
+ CallExpression(node) {
+ let callee = node.callee;
+ if (
+ callee.type !== "MemberExpression" ||
+ callee.property.type !== "Identifier"
+ ) {
+ return;
+ }
+
+ let isFalse = arg => arg.type === "Literal" && arg.value === false;
+ let isFalsy = arg => arg.type === "Literal" && !arg.value;
+ let isBool = arg =>
+ arg.type === "Literal" && (arg.value === false || arg.value === true);
+ let name = callee.property.name;
+ let args = node.arguments;
+
+ if (
+ ["addEventListener", "removeEventListener", "addObserver"].includes(
+ name
+ ) &&
+ args.length === 3 &&
+ isFalse(args[2])
+ ) {
+ context.report({
+ node,
+ fix: fixer => {
+ return fixer.removeRange(getRangeAfterArgToEnd(1, args));
+ },
+ message: `${name}'s third parameter can be omitted when it's false.`,
+ });
+ }
+
+ if (name === "clearUserPref" && args.length > 1) {
+ context.report({
+ node,
+ fix: fixer => {
+ return fixer.removeRange(getRangeAfterArgToEnd(0, args));
+ },
+ message: `${name} takes only 1 parameter.`,
+ });
+ }
+
+ if (name === "removeObserver" && args.length === 3 && isBool(args[2])) {
+ context.report({
+ node,
+ fix: fixer => {
+ return fixer.removeRange(getRangeAfterArgToEnd(1, args));
+ },
+ message: "removeObserver only takes 2 parameters.",
+ });
+ }
+
+ if (name === "appendElement" && args.length === 2 && isFalse(args[1])) {
+ context.report({
+ node,
+ fix: fixer => {
+ return fixer.removeRange(getRangeAfterArgToEnd(0, args));
+ },
+ message: `${name}'s second parameter can be omitted when it's false.`,
+ });
+ }
+
+ if (
+ name === "notifyObservers" &&
+ args.length === 3 &&
+ isFalsy(args[2])
+ ) {
+ context.report({
+ node,
+ fix: fixer => {
+ return fixer.removeRange(getRangeAfterArgToEnd(1, args));
+ },
+ message: `${name}'s third parameter can be omitted.`,
+ });
+ }
+
+ if (
+ name === "getComputedStyle" &&
+ args.length === 2 &&
+ isFalsy(args[1])
+ ) {
+ context.report({
+ node,
+ fix: fixer => {
+ return fixer.removeRange(getRangeAfterArgToEnd(0, args));
+ },
+ message: "getComputedStyle's second parameter can be omitted.",
+ });
+ }
+
+ if (
+ name === "newURI" &&
+ args.length > 1 &&
+ isFalsy(args[args.length - 1])
+ ) {
+ context.report({
+ node,
+ fix: fixer => {
+ if (args.length > 2 && isFalsy(args[args.length - 2])) {
+ return fixer.removeRange(getRangeAfterArgToEnd(0, args));
+ }
+
+ return fixer.removeRange(
+ getRangeAfterArgToEnd(args.length - 2, args)
+ );
+ },
+ message: "newURI's last parameters are optional.",
+ });
+ }
+ },
+ };
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-useless-removeEventListener.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-useless-removeEventListener.js
new file mode 100644
index 0000000000..e58edfcb98
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-useless-removeEventListener.js
@@ -0,0 +1,64 @@
+/**
+ * @fileoverview Reject calls to removeEventListenter where {once: true} could
+ * be used instead.
+ *
+ * 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
+// -----------------------------------------------------------------------------
+
+module.exports = function(context) {
+ // ---------------------------------------------------------------------------
+ // Public
+ // --------------------------------------------------------------------------
+
+ return {
+ CallExpression(node) {
+ let callee = node.callee;
+ if (
+ callee.type !== "MemberExpression" ||
+ callee.property.type !== "Identifier" ||
+ callee.property.name !== "addEventListener" ||
+ node.arguments.length == 4
+ ) {
+ return;
+ }
+
+ let listener = node.arguments[1];
+ if (
+ !listener ||
+ listener.type != "FunctionExpression" ||
+ !listener.body ||
+ listener.body.type != "BlockStatement" ||
+ !listener.body.body.length ||
+ listener.body.body[0].type != "ExpressionStatement" ||
+ listener.body.body[0].expression.type != "CallExpression"
+ ) {
+ return;
+ }
+
+ let call = listener.body.body[0].expression;
+ if (
+ call.callee.type == "MemberExpression" &&
+ call.callee.property.type == "Identifier" &&
+ call.callee.property.name == "removeEventListener" &&
+ ((call.arguments[0].type == "Literal" &&
+ call.arguments[0].value == node.arguments[0].value) ||
+ (call.arguments[0].type == "Identifier" &&
+ call.arguments[0].name == node.arguments[0].name))
+ ) {
+ context.report(
+ call,
+ "use {once: true} instead of removeEventListener as " +
+ "the first instruction of the listener"
+ );
+ }
+ },
+ };
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-useless-run-test.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-useless-run-test.js
new file mode 100644
index 0000000000..d16757c347
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-useless-run-test.js
@@ -0,0 +1,72 @@
+/**
+ * @fileoverview Reject run_test() definitions where they aren't necessary.
+ *
+ * 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
+// -----------------------------------------------------------------------------
+
+module.exports = {
+ meta: {
+ type: "suggestion",
+ fixable: "code",
+ },
+ create(context) {
+ return {
+ "Program > FunctionDeclaration": function(node) {
+ if (
+ node.id.name === "run_test" &&
+ node.body.type === "BlockStatement" &&
+ node.body.body.length === 1 &&
+ node.body.body[0].type === "ExpressionStatement" &&
+ node.body.body[0].expression.type === "CallExpression" &&
+ node.body.body[0].expression.callee.name === "run_next_test"
+ ) {
+ context.report({
+ node,
+ fix: fixer => {
+ let sourceCode = context.getSourceCode();
+ let startNode;
+ if (sourceCode.getCommentsBefore) {
+ // ESLint 4 has getCommentsBefore.
+ startNode = sourceCode.getCommentsBefore(node);
+ } else if (node && node.body && node.leadingComments) {
+ // This is for ESLint 3.
+ startNode = node.leadingComments;
+ }
+
+ // If we have comments, we want the start node to be the comments,
+ // rather than the token before the comments, so that we don't
+ // remove the comments - for run_test, these are likely to be useful
+ // information about the test.
+ if (startNode && startNode.length) {
+ startNode = startNode[startNode.length - 1];
+ } else {
+ startNode = sourceCode.getTokenBefore(node);
+ }
+
+ return fixer.removeRange([
+ // If there's no startNode, we fall back to zero, i.e. start of
+ // file.
+ startNode ? startNode.range[1] + 1 : 0,
+ // We know the function is a block and it'll end with }. Normally
+ // there's a new line after that, so just advance past it. This
+ // may be slightly not dodgy in some cases, but covers the existing
+ // cases.
+ node.range[1] + 1,
+ ]);
+ },
+ message:
+ "Useless run_test function - only contains run_next_test; whole function can be removed",
+ });
+ }
+ },
+ };
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/prefer-boolean-length-check.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/prefer-boolean-length-check.js
new file mode 100644
index 0000000000..543d07b765
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/prefer-boolean-length-check.js
@@ -0,0 +1,130 @@
+/**
+ * @fileoverview Prefer boolean length check
+ *
+ * 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
+// -----------------------------------------------------------------------------
+function funcForBooleanLength(context, node, conditionCheck) {
+ let newText = "";
+ const sourceCode = context.getSourceCode();
+ switch (node.operator) {
+ case ">":
+ if (node.right.value == 0) {
+ if (conditionCheck) {
+ newText = sourceCode.getText(node.left);
+ } else {
+ newText = "!!" + sourceCode.getText(node.left);
+ }
+ } else {
+ newText = "!" + sourceCode.getText(node.right);
+ }
+ break;
+ case "<":
+ if (node.right.value == 0) {
+ newText = "!" + sourceCode.getText(node.left);
+ } else if (conditionCheck) {
+ newText = sourceCode.getText(node.right);
+ } else {
+ newText = "!!" + sourceCode.getText(node.right);
+ }
+ break;
+ case "==":
+ if (node.right.value == 0) {
+ newText = "!" + sourceCode.getText(node.left);
+ } else {
+ newText = "!" + sourceCode.getText(node.right);
+ }
+ break;
+ case "!=":
+ if (node.right.value == 0) {
+ if (conditionCheck) {
+ newText = sourceCode.getText(node.left);
+ } else {
+ newText = "!!" + sourceCode.getText(node.left);
+ }
+ } else if (conditionCheck) {
+ newText = sourceCode.getText(node.right);
+ } else {
+ newText = "!!" + sourceCode.getText(node.right);
+ }
+ break;
+ }
+ return newText;
+}
+
+module.exports = {
+ meta: {
+ type: "suggestion",
+ fixable: "code",
+ },
+ create(context) {
+ // ---------------------------------------------------------------------------
+ // Public
+ // --------------------------------------------------------------------------
+
+ const conditionStatement = [
+ "IfStatement",
+ "WhileStatement",
+ "DoWhileStatement",
+ "ForStatement",
+ "ForInStatement",
+ "ConditionalExpression",
+ ];
+
+ return {
+ BinaryExpression(node) {
+ if (
+ ["==", "!=", ">", "<"].includes(node.operator) &&
+ ((node.right.type == "Literal" &&
+ node.right.value == 0 &&
+ node.left.property &&
+ node.left.property.name == "length") ||
+ (node.left.type == "Literal" &&
+ node.left.value == 0 &&
+ node.right.property &&
+ node.right.property.name == "length"))
+ ) {
+ if (
+ conditionStatement.includes(node.parent.type) ||
+ (node.parent.type == "LogicalExpression" &&
+ conditionStatement.includes(node.parent.parent.type))
+ ) {
+ context.report({
+ node,
+ fix: fixer => {
+ let generateExpression = funcForBooleanLength(
+ context,
+ node,
+ true
+ );
+
+ return fixer.replaceText(node, generateExpression);
+ },
+ message: "Prefer boolean length check",
+ });
+ } else {
+ context.report({
+ node,
+ fix: fixer => {
+ let generateExpression = funcForBooleanLength(
+ context,
+ node,
+ false
+ );
+ return fixer.replaceText(node, generateExpression);
+ },
+ message: "Prefer boolean length check",
+ });
+ }
+ }
+ },
+ };
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/prefer-formatValues.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/prefer-formatValues.js
new file mode 100644
index 0000000000..45b8c40901
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/prefer-formatValues.js
@@ -0,0 +1,96 @@
+/**
+ * @fileoverview Reject multiple calls to document.l10n.formatValue in the same
+ * code block.
+ *
+ * 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
+// -----------------------------------------------------------------------------
+
+function isIdentifier(node, id) {
+ return node && node.type === "Identifier" && node.name === id;
+}
+
+/**
+ * As we enter blocks new sets are pushed onto this stack and then popped when
+ * we exit the block.
+ */
+const BlockStack = [];
+
+module.exports = {
+ meta: {
+ docs: {
+ description: "disallow multiple document.l10n.formatValue calls",
+ category: "Best Practices",
+ },
+ schema: [],
+ },
+
+ // ---------------------------------------------------------------------------
+ // Public
+ // --------------------------------------------------------------------------
+
+ create(context) {
+ function enterBlock() {
+ BlockStack.push(new Set());
+ }
+
+ function exitBlock() {
+ let calls = BlockStack.pop();
+ if (calls.size > 1) {
+ for (let callNode of calls) {
+ context.report(
+ callNode,
+ "prefer to use a single document.l10n.formatValues call instead " +
+ "of multiple calls to document.l10n.formatValue or document.l10n.formatValues"
+ );
+ }
+ }
+ }
+
+ return {
+ Program: enterBlock,
+ "Program:exit": exitBlock,
+ BlockStatement: enterBlock,
+ "BlockStatement:exit": exitBlock,
+
+ CallExpression(node) {
+ if (!BlockStack.length) {
+ context.report(node, "call expression found outside of known block");
+ }
+
+ let callee = node.callee;
+ if (callee.type !== "MemberExpression") {
+ return;
+ }
+
+ if (
+ !isIdentifier(callee.property, "formatValue") &&
+ !isIdentifier(callee.property, "formatValues")
+ ) {
+ return;
+ }
+
+ if (callee.object.type !== "MemberExpression") {
+ return;
+ }
+
+ if (
+ !isIdentifier(callee.object.object, "document") ||
+ !isIdentifier(callee.object.property, "l10n")
+ ) {
+ return;
+ }
+
+ let calls = BlockStack[BlockStack.length - 1];
+ calls.add(node);
+ },
+ };
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/reject-chromeutils-import-null.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/reject-chromeutils-import-null.js
new file mode 100644
index 0000000000..b7fd1593b8
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/reject-chromeutils-import-null.js
@@ -0,0 +1,44 @@
+/**
+ * @fileoverview Reject calls to ChromeUtils.import(..., null). This allows to
+ * retrieve the global object for the JSM, instead we should rely on explicitly
+ * exported symbols.
+ *
+ * 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
+// -----------------------------------------------------------------------------
+
+function isIdentifier(node, id) {
+ return node && node.type === "Identifier" && node.name === id;
+}
+
+module.exports = function(context) {
+ // ---------------------------------------------------------------------------
+ // Public
+ // --------------------------------------------------------------------------
+
+ return {
+ CallExpression(node) {
+ let { callee } = node;
+ if (
+ isIdentifier(callee.object, "ChromeUtils") &&
+ isIdentifier(callee.property, "import") &&
+ node.arguments.length >= 2 &&
+ node.arguments[1].type == "Literal" &&
+ node.arguments[1].raw == "null"
+ ) {
+ context.report(
+ node,
+ "ChromeUtils.import should not be called with (..., null) to " +
+ "retrieve the JSM global object. Rely on explicit exports instead."
+ );
+ }
+ },
+ };
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/reject-importGlobalProperties.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/reject-importGlobalProperties.js
new file mode 100644
index 0000000000..a2f495ddb7
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/reject-importGlobalProperties.js
@@ -0,0 +1,62 @@
+/**
+ * @fileoverview Reject use of Cu.importGlobalProperties
+ *
+ * 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 privilegedGlobals = Object.keys(
+ require("../environments/privileged.js").globals
+);
+
+// -----------------------------------------------------------------------------
+// Rule Definition
+// -----------------------------------------------------------------------------
+
+module.exports = {
+ meta: {
+ messages: {
+ unexpectedCall: "Unexpected call to Cu.importGlobalProperties",
+ unexpectedCallWebIdl:
+ "Unnecessary call to Cu.importGlobalProperties (webidl names are automatically imported)",
+ },
+ schema: [
+ {
+ // XXX Better name?
+ enum: ["everything", "allownonwebidl"],
+ },
+ ],
+ type: "problem",
+ },
+
+ create(context) {
+ return {
+ CallExpression(node) {
+ if (node.callee.type !== "MemberExpression") {
+ return;
+ }
+ let memexp = node.callee;
+ if (
+ memexp.object.type === "Identifier" &&
+ // Only Cu, not Components.utils; see bug 1230369.
+ memexp.object.name === "Cu" &&
+ memexp.property.type === "Identifier" &&
+ memexp.property.name === "importGlobalProperties"
+ ) {
+ if (context.options.includes("allownonwebidl")) {
+ for (let element of node.arguments[0].elements) {
+ if (privilegedGlobals.includes(element.value)) {
+ context.report({ node, messageId: "unexpectedCallWebIdl" });
+ }
+ }
+ } else {
+ context.report({ node, messageId: "unexpectedCall" });
+ }
+ }
+ },
+ };
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/reject-relative-requires.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/reject-relative-requires.js
new file mode 100644
index 0000000000..eb100b13fa
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/reject-relative-requires.js
@@ -0,0 +1,34 @@
+/**
+ * @fileoverview Reject some uses of require.
+ *
+ * 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 helpers = require("../helpers");
+
+module.exports = function(context) {
+ // ---------------------------------------------------------------------------
+ // Public
+ // --------------------------------------------------------------------------
+
+ const isRelativePath = function(path) {
+ return path.startsWith("./") || path.startsWith("../");
+ };
+
+ return {
+ CallExpression(node) {
+ const path = helpers.getDevToolsRequirePath(node);
+ if (path && isRelativePath(path)) {
+ context.report(node, "relative paths are not allowed with require()");
+ }
+ },
+ };
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/reject-some-requires.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/reject-some-requires.js
new file mode 100644
index 0000000000..ab31069293
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/reject-some-requires.js
@@ -0,0 +1,35 @@
+/**
+ * @fileoverview Reject some uses of require.
+ *
+ * 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 helpers = require("../helpers");
+
+module.exports = function(context) {
+ // ---------------------------------------------------------------------------
+ // Public
+ // --------------------------------------------------------------------------
+
+ if (typeof context.options[0] !== "string") {
+ throw new Error("reject-some-requires expects a regexp");
+ }
+ const RX = new RegExp(context.options[0]);
+
+ return {
+ CallExpression(node) {
+ const path = helpers.getDevToolsRequirePath(node);
+ if (path && RX.test(path)) {
+ context.report(node, `require(${path}) is not allowed`);
+ }
+ },
+ };
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/rejects-requires-await.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/rejects-requires-await.js
new file mode 100644
index 0000000000..1bc0bcd58d
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/rejects-requires-await.js
@@ -0,0 +1,42 @@
+/**
+ * @fileoverview Reject use of Cu.importGlobalProperties
+ *
+ * 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 = {
+ meta: {
+ messages: {
+ rejectRequiresAwait: "Assert.rejects needs to be preceded by await.",
+ },
+ },
+
+ create(context) {
+ return {
+ CallExpression(node) {
+ if (node.callee.type === "MemberExpression") {
+ let memexp = node.callee;
+ if (
+ memexp.object.type === "Identifier" &&
+ memexp.object.name === "Assert" &&
+ memexp.property.type === "Identifier" &&
+ memexp.property.name === "rejects"
+ ) {
+ // We have ourselves an Assert.rejects.
+
+ if (node.parent.type !== "AwaitExpression") {
+ context.report({
+ node,
+ messageId: "rejectRequiresAwait",
+ });
+ }
+ }
+ }
+ },
+ };
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-cc-etc.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-cc-etc.js
new file mode 100644
index 0000000000..053f379adb
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-cc-etc.js
@@ -0,0 +1,44 @@
+/**
+ * @fileoverview Reject use of Components.classes etc, prefer the shorthand instead.
+ *
+ * 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
+// -----------------------------------------------------------------------------
+
+const componentsMap = {
+ classes: "Cc",
+ interfaces: "Ci",
+ results: "Cr",
+ utils: "Cu",
+};
+
+module.exports = function(context) {
+ // ---------------------------------------------------------------------------
+ // Public
+ // --------------------------------------------------------------------------
+
+ return {
+ MemberExpression(node) {
+ if (
+ node.object.type === "Identifier" &&
+ node.object.name === "Components" &&
+ node.property.type === "Identifier" &&
+ Object.getOwnPropertyNames(componentsMap).includes(node.property.name)
+ ) {
+ context.report(
+ node,
+ `Use ${componentsMap[node.property.name]} rather than Components.${
+ node.property.name
+ }`
+ );
+ }
+ },
+ };
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-chromeutils-generateqi.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-chromeutils-generateqi.js
new file mode 100644
index 0000000000..6d72f785de
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-chromeutils-generateqi.js
@@ -0,0 +1,103 @@
+/**
+ * @fileoverview Reject use of XPCOMUtils.generateQI and JS-implemented
+ * QueryInterface methods in favor of ChromeUtils.
+ *
+ * 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
+// -----------------------------------------------------------------------------
+
+function isIdentifier(node, id) {
+ return node && node.type === "Identifier" && node.name === id;
+}
+
+function isMemberExpression(node, object, member) {
+ return (
+ node.type === "MemberExpression" &&
+ isIdentifier(node.object, object) &&
+ isIdentifier(node.property, member)
+ );
+}
+
+const MSG_NO_JS_QUERY_INTERFACE =
+ "Please use ChromeUtils.generateQI rather than manually creating " +
+ "JavaScript QueryInterface functions";
+
+const MSG_NO_XPCOMUTILS_GENERATEQI =
+ "Please use ChromeUtils.generateQI instead of XPCOMUtils.generateQI";
+
+function funcToGenerateQI(context, node) {
+ const sourceCode = context.getSourceCode();
+ const text = sourceCode.getText(node);
+
+ let interfaces = [];
+ let match;
+ let re = /\bCi\.([a-zA-Z0-9]+)\b|\b(nsI[A-Z][a-zA-Z0-9]+)\b/g;
+ while ((match = re.exec(text))) {
+ interfaces.push(match[1] || match[2]);
+ }
+
+ let ifaces = interfaces
+ .filter(iface => iface != "nsISupports")
+ .map(iface => JSON.stringify(iface))
+ .join(", ");
+
+ return `ChromeUtils.generateQI([${ifaces}])`;
+}
+
+module.exports = {
+ meta: {
+ fixable: "code",
+ },
+
+ create(context) {
+ return {
+ CallExpression(node) {
+ let { callee } = node;
+ if (isMemberExpression(callee, "XPCOMUtils", "generateQI")) {
+ context.report({
+ node,
+ message: MSG_NO_XPCOMUTILS_GENERATEQI,
+ fix(fixer) {
+ return fixer.replaceText(callee, "ChromeUtils.generateQI");
+ },
+ });
+ }
+ },
+
+ "AssignmentExpression > MemberExpression[property.name='QueryInterface']": function(
+ node
+ ) {
+ const { right } = node.parent;
+ if (right.type === "FunctionExpression") {
+ context.report({
+ node: node.parent,
+ message: MSG_NO_JS_QUERY_INTERFACE,
+ fix(fixer) {
+ return fixer.replaceText(right, funcToGenerateQI(context, right));
+ },
+ });
+ }
+ },
+
+ "Property[key.name='QueryInterface'][value.type='FunctionExpression']": function(
+ node
+ ) {
+ context.report({
+ node,
+ message: MSG_NO_JS_QUERY_INTERFACE,
+ fix(fixer) {
+ let generateQI = funcToGenerateQI(context, node.value);
+ return fixer.replaceText(node, `QueryInterface: ${generateQI}`);
+ },
+ });
+ },
+ };
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-chromeutils-import.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-chromeutils-import.js
new file mode 100644
index 0000000000..eefff06e11
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-chromeutils-import.js
@@ -0,0 +1,89 @@
+/**
+ * @fileoverview Reject use of Cu.import and XPCOMUtils.defineLazyModuleGetter
+ * in favor of ChromeUtils.
+ *
+ * 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
+// -----------------------------------------------------------------------------
+
+function isIdentifier(node, id) {
+ return node && node.type === "Identifier" && node.name === id;
+}
+
+function isMemberExpression(node, object, member) {
+ return (
+ node.type === "MemberExpression" &&
+ isIdentifier(node.object, object) &&
+ isIdentifier(node.property, member)
+ );
+}
+
+module.exports = {
+ meta: {
+ schema: [
+ {
+ type: "object",
+ properties: {
+ allowCu: {
+ type: "boolean",
+ },
+ },
+ additionalProperties: false,
+ },
+ ],
+ fixable: "code",
+ },
+
+ create(context) {
+ return {
+ CallExpression(node) {
+ if (node.callee.type !== "MemberExpression") {
+ return;
+ }
+
+ let { allowCu } = context.options[0] || {};
+ let { callee } = node;
+
+ // Is the expression starting with `Cu` or `Components.utils`?
+ if (
+ ((!allowCu && isIdentifier(callee.object, "Cu")) ||
+ isMemberExpression(callee.object, "Components", "utils")) &&
+ isIdentifier(callee.property, "import")
+ ) {
+ context.report({
+ node,
+ message: "Please use ChromeUtils.import instead of Cu.import",
+ fix(fixer) {
+ return fixer.replaceText(callee, "ChromeUtils.import");
+ },
+ });
+ }
+
+ if (
+ isMemberExpression(callee, "XPCOMUtils", "defineLazyModuleGetter") &&
+ node.arguments.length < 4
+ ) {
+ context.report({
+ node,
+ message:
+ "Please use ChromeUtils.defineModuleGetter instead of " +
+ "XPCOMUtils.defineLazyModuleGetter",
+ fix(fixer) {
+ return fixer.replaceText(
+ callee,
+ "ChromeUtils.defineModuleGetter"
+ );
+ },
+ });
+ }
+ },
+ };
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-default-preference-values.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-default-preference-values.js
new file mode 100644
index 0000000000..7c2ffaf933
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-default-preference-values.js
@@ -0,0 +1,45 @@
+/**
+ * @fileoverview Require providing a second parameter to get*Pref
+ * methods instead of using a try/catch block.
+ *
+ * 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
+// -----------------------------------------------------------------------------
+
+module.exports = function(context) {
+ // ---------------------------------------------------------------------------
+ // Public
+ // --------------------------------------------------------------------------
+
+ return {
+ TryStatement(node) {
+ let types = ["Bool", "Char", "Float", "Int"];
+ let methods = types.map(type => "get" + type + "Pref");
+ if (node.block.type != "BlockStatement" || node.block.body.length != 1) {
+ return;
+ }
+
+ let firstStm = node.block.body[0];
+ if (
+ firstStm.type != "ExpressionStatement" ||
+ firstStm.expression.type != "AssignmentExpression" ||
+ firstStm.expression.right.type != "CallExpression" ||
+ firstStm.expression.right.callee.type != "MemberExpression" ||
+ firstStm.expression.right.callee.property.type != "Identifier" ||
+ !methods.includes(firstStm.expression.right.callee.property.name)
+ ) {
+ return;
+ }
+
+ let msg = "provide a default value instead of using a try/catch block";
+ context.report(node, msg);
+ },
+ };
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-includes-instead-of-indexOf.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-includes-instead-of-indexOf.js
new file mode 100644
index 0000000000..d4b3da5f1e
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-includes-instead-of-indexOf.js
@@ -0,0 +1,45 @@
+/**
+ * @fileoverview Use .includes instead of .indexOf
+ *
+ * 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
+// -----------------------------------------------------------------------------
+
+module.exports = function(context) {
+ // ---------------------------------------------------------------------------
+ // Public
+ // --------------------------------------------------------------------------
+
+ return {
+ BinaryExpression(node) {
+ if (
+ node.left.type != "CallExpression" ||
+ node.left.callee.type != "MemberExpression" ||
+ node.left.callee.property.type != "Identifier" ||
+ node.left.callee.property.name != "indexOf"
+ ) {
+ return;
+ }
+
+ if (
+ (["!=", "!==", "==", "==="].includes(node.operator) &&
+ node.right.type == "UnaryExpression" &&
+ node.right.operator == "-" &&
+ node.right.argument.type == "Literal" &&
+ node.right.argument.value == 1) ||
+ ([">=", "<"].includes(node.operator) &&
+ node.right.type == "Literal" &&
+ node.right.value == 0)
+ ) {
+ context.report(node, "use .includes instead of .indexOf");
+ }
+ },
+ };
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-ownerGlobal.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-ownerGlobal.js
new file mode 100644
index 0000000000..34b22a1269
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-ownerGlobal.js
@@ -0,0 +1,38 @@
+/**
+ * @fileoverview Require .ownerGlobal instead of .ownerDocument.defaultView.
+ *
+ * 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
+// -----------------------------------------------------------------------------
+
+module.exports = function(context) {
+ // ---------------------------------------------------------------------------
+ // Public
+ // --------------------------------------------------------------------------
+
+ return {
+ MemberExpression(node) {
+ if (
+ node.property.type != "Identifier" ||
+ node.property.name != "defaultView" ||
+ node.object.type != "MemberExpression" ||
+ node.object.property.type != "Identifier" ||
+ node.object.property.name != "ownerDocument"
+ ) {
+ return;
+ }
+
+ context.report(
+ node,
+ "use .ownerGlobal instead of .ownerDocument.defaultView"
+ );
+ },
+ };
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-returnValue.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-returnValue.js
new file mode 100644
index 0000000000..eb693d0014
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-returnValue.js
@@ -0,0 +1,42 @@
+/**
+ * @fileoverview Warn when idempotent methods are called and their return value is unused.
+ *
+ * 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
+// -----------------------------------------------------------------------------
+
+module.exports = function(context) {
+ // ---------------------------------------------------------------------------
+ // Public
+ // --------------------------------------------------------------------------
+
+ return {
+ ExpressionStatement(node) {
+ if (
+ !node.expression ||
+ node.expression.type != "CallExpression" ||
+ !node.expression.callee ||
+ node.expression.callee.type != "MemberExpression" ||
+ !node.expression.callee.property ||
+ node.expression.callee.property.type != "Identifier" ||
+ (node.expression.callee.property.name != "concat" &&
+ node.expression.callee.property.name != "join" &&
+ node.expression.callee.property.name != "slice")
+ ) {
+ return;
+ }
+
+ context.report(
+ node,
+ `{Array/String}.${node.expression.callee.property.name} doesn't modify the instance in-place`
+ );
+ },
+ };
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-services.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-services.js
new file mode 100644
index 0000000000..1235cd0f99
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-services.js
@@ -0,0 +1,45 @@
+/**
+ * @fileoverview Require use of Services.* rather than getService.
+ *
+ * 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 helpers = require("../helpers");
+
+let servicesInterfaceMap = helpers.servicesData;
+
+// -----------------------------------------------------------------------------
+// Rule Definition
+// -----------------------------------------------------------------------------
+module.exports = function(context) {
+ // ---------------------------------------------------------------------------
+ // Public
+ // --------------------------------------------------------------------------
+ return {
+ CallExpression(node) {
+ if (
+ !node.callee ||
+ !node.callee.property ||
+ node.callee.property.type != "Identifier" ||
+ node.callee.property.name != "getService" ||
+ node.arguments.length != 1 ||
+ !node.arguments[0].property ||
+ node.arguments[0].property.type != "Identifier" ||
+ !node.arguments[0].property.name ||
+ !(node.arguments[0].property.name in servicesInterfaceMap)
+ ) {
+ return;
+ }
+
+ let serviceName = servicesInterfaceMap[node.arguments[0].property.name];
+
+ context.report(
+ node,
+ `Use Services.${serviceName} rather than getService().`
+ );
+ },
+ };
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/var-only-at-top-level.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/var-only-at-top-level.js
new file mode 100644
index 0000000000..9365982b0c
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/var-only-at-top-level.js
@@ -0,0 +1,34 @@
+/**
+ * @fileoverview Marks all var declarations that are not at the top level
+ * invalid.
+ *
+ * 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 helpers = require("../helpers");
+
+module.exports = function(context) {
+ // ---------------------------------------------------------------------------
+ // Public
+ // --------------------------------------------------------------------------
+
+ return {
+ VariableDeclaration(node) {
+ if (node.kind === "var") {
+ if (helpers.getIsGlobalScope(context.getAncestors())) {
+ return;
+ }
+
+ context.report(node, "Unexpected var, use let or const instead.");
+ }
+ },
+ };
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/services.json b/tools/lint/eslint/eslint-plugin-mozilla/lib/services.json
new file mode 100644
index 0000000000..dd250ee15e
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/services.json
@@ -0,0 +1,50 @@
+{
+ "mozIJSSubScriptLoader": "scriptloader",
+ "mozILocaleService": "locale",
+ "mozIMozIntl": "intl",
+ "mozIStorageService": "storage",
+ "nsIAppShellService": "appShell",
+ "nsIAppStartup": "startup",
+ "nsICacheStorageService": "cache2",
+ "nsICategoryManager": "catMan",
+ "nsIClearDataService": "clearData",
+ "nsIClipboard": "clipboard",
+ "nsIConsoleService": "console",
+ "nsICookieManager": "cookies",
+ "nsIDOMRequestService": "DOMRequest",
+ "nsIDOMStorageManager": "domStorageManager",
+ "nsIDirectoryService": "dirsvc",
+ "nsIDroppedLinkHandler": "droppedLinkHandler",
+ "nsIEffectiveTLDService": "eTLD",
+ "nsIEnterprisePolicies": "policies",
+ "nsIEventListenerService": "els",
+ "nsIFocusManager": "focus",
+ "nsIIOService": "io",
+ "nsILoadContextInfoFactory": "loadContextInfo",
+ "nsILocalStorageManager": "domStorageManager",
+ "nsILoginManager": "logins",
+ "nsINetUtil": "io",
+ "nsIObserverService": "obs",
+ "nsIPermissionManager": "perms",
+ "nsIPrefBranch": "prefs",
+ "nsIPrefService": "prefs",
+ "nsIProfiler": "profiler",
+ "nsIPromptService": "prompt",
+ "nsIProperties": "dirsvc",
+ "nsIPropertyBag2": "sysinfo",
+ "nsIQuotaManagerService": "qms",
+ "nsIScriptSecurityManager": "scriptSecurityManager",
+ "nsISearchService": "search",
+ "nsISpeculativeConnect": "io",
+ "nsIStringBundleService": "strings",
+ "nsISystemInfo": "sysinfo",
+ "nsITelemetry": "telemetry",
+ "nsITextToSubURI": "textToSubURI",
+ "nsIThreadManager": "tm",
+ "nsIURLFormatter": "urlFormatter",
+ "nsIVersionComparator": "vc",
+ "nsIWindowMediator": "wm",
+ "nsIWindowWatcher": "ww",
+ "nsIXULAppInfo": "appinfo",
+ "nsIXULRuntime": "appinfo"
+} \ No newline at end of file
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/manifest.tt b/tools/lint/eslint/eslint-plugin-mozilla/manifest.tt
new file mode 100644
index 0000000000..e58dfbb57c
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/manifest.tt
@@ -0,0 +1,10 @@
+[
+ {
+ "algorithm": "sha512",
+ "visibility": "public",
+ "filename": "eslint-plugin-mozilla.tar.gz",
+ "unpack": true,
+ "digest": "196e87a20b68bcafb4fb7893c829beb3d44144f6985a4194bc41b135618f373732ae8e0604ed0548ae5e79f1c0eede33a802fbf4f12678c59a3615c481923912",
+ "size": 5272799
+ }
+] \ No newline at end of file
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/package-lock.json b/tools/lint/eslint/eslint-plugin-mozilla/package-lock.json
new file mode 100644
index 0000000000..a385b07225
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/package-lock.json
@@ -0,0 +1,2045 @@
+{
+ "name": "eslint-plugin-mozilla",
+ "version": "2.9.2",
+ "lockfileVersion": 1,
+ "requires": true,
+ "dependencies": {
+ "@babel/code-frame": {
+ "version": "7.10.4",
+ "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.4.tgz",
+ "integrity": "sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg==",
+ "requires": {
+ "@babel/highlight": "^7.10.4"
+ }
+ },
+ "@babel/core": {
+ "version": "7.8.3",
+ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.8.3.tgz",
+ "integrity": "sha512-4XFkf8AwyrEG7Ziu3L2L0Cv+WyY47Tcsp70JFmpftbAA1K7YL/sgE9jh9HyNj08Y/U50ItUchpN0w6HxAoX1rA==",
+ "requires": {
+ "@babel/code-frame": "^7.8.3",
+ "@babel/generator": "^7.8.3",
+ "@babel/helpers": "^7.8.3",
+ "@babel/parser": "^7.8.3",
+ "@babel/template": "^7.8.3",
+ "@babel/traverse": "^7.8.3",
+ "@babel/types": "^7.8.3",
+ "convert-source-map": "^1.7.0",
+ "debug": "^4.1.0",
+ "gensync": "^1.0.0-beta.1",
+ "json5": "^2.1.0",
+ "lodash": "^4.17.13",
+ "resolve": "^1.3.2",
+ "semver": "^5.4.1",
+ "source-map": "^0.5.0"
+ }
+ },
+ "@babel/generator": {
+ "version": "7.10.5",
+ "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.10.5.tgz",
+ "integrity": "sha512-3vXxr3FEW7E7lJZiWQ3bM4+v/Vyr9C+hpolQ8BGFr9Y8Ri2tFLWTixmwKBafDujO1WVah4fhZBeU1bieKdghig==",
+ "requires": {
+ "@babel/types": "^7.10.5",
+ "jsesc": "^2.5.1",
+ "source-map": "^0.5.0"
+ }
+ },
+ "@babel/helper-function-name": {
+ "version": "7.10.4",
+ "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.10.4.tgz",
+ "integrity": "sha512-YdaSyz1n8gY44EmN7x44zBn9zQ1Ry2Y+3GTA+3vH6Mizke1Vw0aWDM66FOYEPw8//qKkmqOckrGgTYa+6sceqQ==",
+ "requires": {
+ "@babel/helper-get-function-arity": "^7.10.4",
+ "@babel/template": "^7.10.4",
+ "@babel/types": "^7.10.4"
+ }
+ },
+ "@babel/helper-get-function-arity": {
+ "version": "7.10.4",
+ "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.10.4.tgz",
+ "integrity": "sha512-EkN3YDB+SRDgiIUnNgcmiD361ti+AVbL3f3Henf6dqqUyr5dMsorno0lJWJuLhDhkI5sYEpgj6y9kB8AOU1I2A==",
+ "requires": {
+ "@babel/types": "^7.10.4"
+ }
+ },
+ "@babel/helper-split-export-declaration": {
+ "version": "7.10.4",
+ "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.10.4.tgz",
+ "integrity": "sha512-pySBTeoUff56fL5CBU2hWm9TesA4r/rOkI9DyJLvvgz09MB9YtfIYe3iBriVaYNaPe+Alua0vBIOVOLs2buWhg==",
+ "requires": {
+ "@babel/types": "^7.10.4"
+ }
+ },
+ "@babel/helper-validator-identifier": {
+ "version": "7.10.4",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz",
+ "integrity": "sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw=="
+ },
+ "@babel/helpers": {
+ "version": "7.10.4",
+ "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.10.4.tgz",
+ "integrity": "sha512-L2gX/XeUONeEbI78dXSrJzGdz4GQ+ZTA/aazfUsFaWjSe95kiCuOZ5HsXvkiw3iwF+mFHSRUfJU8t6YavocdXA==",
+ "requires": {
+ "@babel/template": "^7.10.4",
+ "@babel/traverse": "^7.10.4",
+ "@babel/types": "^7.10.4"
+ }
+ },
+ "@babel/highlight": {
+ "version": "7.10.4",
+ "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.4.tgz",
+ "integrity": "sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA==",
+ "requires": {
+ "@babel/helper-validator-identifier": "^7.10.4",
+ "chalk": "^2.0.0",
+ "js-tokens": "^4.0.0"
+ }
+ },
+ "@babel/parser": {
+ "version": "7.10.5",
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.5.tgz",
+ "integrity": "sha512-wfryxy4bE1UivvQKSQDU4/X6dr+i8bctjUjj8Zyt3DQy7NtPizJXT8M52nqpNKL+nq2PW8lxk4ZqLj0fD4B4hQ=="
+ },
+ "@babel/template": {
+ "version": "7.10.4",
+ "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.10.4.tgz",
+ "integrity": "sha512-ZCjD27cGJFUB6nmCB1Enki3r+L5kJveX9pq1SvAUKoICy6CZ9yD8xO086YXdYhvNjBdnekm4ZnaP5yC8Cs/1tA==",
+ "requires": {
+ "@babel/code-frame": "^7.10.4",
+ "@babel/parser": "^7.10.4",
+ "@babel/types": "^7.10.4"
+ }
+ },
+ "@babel/traverse": {
+ "version": "7.10.5",
+ "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.10.5.tgz",
+ "integrity": "sha512-yc/fyv2gUjPqzTz0WHeRJH2pv7jA9kA7mBX2tXl/x5iOE81uaVPuGPtaYk7wmkx4b67mQ7NqI8rmT2pF47KYKQ==",
+ "requires": {
+ "@babel/code-frame": "^7.10.4",
+ "@babel/generator": "^7.10.5",
+ "@babel/helper-function-name": "^7.10.4",
+ "@babel/helper-split-export-declaration": "^7.10.4",
+ "@babel/parser": "^7.10.5",
+ "@babel/types": "^7.10.5",
+ "debug": "^4.1.0",
+ "globals": "^11.1.0",
+ "lodash": "^4.17.19"
+ }
+ },
+ "@babel/types": {
+ "version": "7.10.5",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.5.tgz",
+ "integrity": "sha512-ixV66KWfCI6GKoA/2H9v6bQdbfXEwwpOdQ8cRvb4F+eyvhlaHxWFMQB4+3d9QFJXZsiiiqVrewNV0DFEQpyT4Q==",
+ "requires": {
+ "@babel/helper-validator-identifier": "^7.10.4",
+ "lodash": "^4.17.19",
+ "to-fast-properties": "^2.0.0"
+ }
+ },
+ "@eslint/eslintrc": {
+ "version": "0.1.3",
+ "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.1.3.tgz",
+ "integrity": "sha512-4YVwPkANLeNtRjMekzux1ci8hIaH5eGKktGqR0d3LWsKNn5B2X/1Z6Trxy7jQXl9EBGE6Yj02O+t09FMeRllaA==",
+ "dev": true,
+ "requires": {
+ "ajv": "^6.12.4",
+ "debug": "^4.1.1",
+ "espree": "^7.3.0",
+ "globals": "^12.1.0",
+ "ignore": "^4.0.6",
+ "import-fresh": "^3.2.1",
+ "js-yaml": "^3.13.1",
+ "lodash": "^4.17.19",
+ "minimatch": "^3.0.4",
+ "strip-json-comments": "^3.1.1"
+ },
+ "dependencies": {
+ "globals": {
+ "version": "12.4.0",
+ "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz",
+ "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==",
+ "dev": true,
+ "requires": {
+ "type-fest": "^0.8.1"
+ }
+ }
+ }
+ },
+ "@types/color-name": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
+ "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
+ "dev": true
+ },
+ "acorn": {
+ "version": "7.4.0",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz",
+ "integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==",
+ "dev": true
+ },
+ "acorn-jsx": {
+ "version": "5.3.1",
+ "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz",
+ "integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==",
+ "dev": true
+ },
+ "ajv": {
+ "version": "6.12.5",
+ "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.5.tgz",
+ "integrity": "sha512-lRF8RORchjpKG50/WFf8xmg7sgCLFiYNNnqdKflk63whMQcWR5ngGjiSXkL9bjxy6B2npOK2HSMN49jEBMSkag==",
+ "dev": true,
+ "requires": {
+ "fast-deep-equal": "^3.1.1",
+ "fast-json-stable-stringify": "^2.0.0",
+ "json-schema-traverse": "^0.4.1",
+ "uri-js": "^4.2.2"
+ }
+ },
+ "ansi-colors": {
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz",
+ "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==",
+ "dev": true
+ },
+ "ansi-regex": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz",
+ "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==",
+ "dev": true
+ },
+ "ansi-styles": {
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
+ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
+ "requires": {
+ "color-convert": "^1.9.0"
+ }
+ },
+ "anymatch": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz",
+ "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==",
+ "dev": true,
+ "requires": {
+ "normalize-path": "^3.0.0",
+ "picomatch": "^2.0.4"
+ }
+ },
+ "argparse": {
+ "version": "1.0.10",
+ "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
+ "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
+ "dev": true,
+ "requires": {
+ "sprintf-js": "~1.0.2"
+ }
+ },
+ "array.prototype.map": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/array.prototype.map/-/array.prototype.map-1.0.2.tgz",
+ "integrity": "sha512-Az3OYxgsa1g7xDYp86l0nnN4bcmuEITGe1rbdEBVkrqkzMgDcbdQ2R7r41pNzti+4NMces3H8gMmuioZUilLgw==",
+ "dev": true,
+ "requires": {
+ "define-properties": "^1.1.3",
+ "es-abstract": "^1.17.0-next.1",
+ "es-array-method-boxes-properly": "^1.0.0",
+ "is-string": "^1.0.4"
+ }
+ },
+ "astral-regex": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz",
+ "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==",
+ "dev": true
+ },
+ "babel-eslint": {
+ "version": "10.1.0",
+ "resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-10.1.0.tgz",
+ "integrity": "sha512-ifWaTHQ0ce+448CYop8AdrQiBsGrnC+bMgfyKFdi6EsPLTAWG+QfyDeM6OH+FmWnKvEq5NnBMLvlBUPKQZoDSg==",
+ "requires": {
+ "@babel/code-frame": "^7.0.0",
+ "@babel/parser": "^7.7.0",
+ "@babel/traverse": "^7.7.0",
+ "@babel/types": "^7.7.0",
+ "eslint-visitor-keys": "^1.0.0",
+ "resolve": "^1.12.0"
+ }
+ },
+ "balanced-match": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
+ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
+ "dev": true
+ },
+ "binary-extensions": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.1.0.tgz",
+ "integrity": "sha512-1Yj8h9Q+QDF5FzhMs/c9+6UntbD5MkRfRwac8DoEm9ZfUBZ7tZ55YcGVAzEe4bXsdQHEk+s9S5wsOKVdZrw0tQ==",
+ "dev": true
+ },
+ "brace-expansion": {
+ "version": "1.1.11",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
+ "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
+ "dev": true,
+ "requires": {
+ "balanced-match": "^1.0.0",
+ "concat-map": "0.0.1"
+ }
+ },
+ "braces": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
+ "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
+ "dev": true,
+ "requires": {
+ "fill-range": "^7.0.1"
+ }
+ },
+ "browser-stdout": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz",
+ "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==",
+ "dev": true
+ },
+ "callsites": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
+ "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==",
+ "dev": true
+ },
+ "camelcase": {
+ "version": "5.3.1",
+ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
+ "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",
+ "dev": true
+ },
+ "chalk": {
+ "version": "2.4.2",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
+ "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
+ "requires": {
+ "ansi-styles": "^3.2.1",
+ "escape-string-regexp": "^1.0.5",
+ "supports-color": "^5.3.0"
+ }
+ },
+ "chokidar": {
+ "version": "3.4.2",
+ "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.4.2.tgz",
+ "integrity": "sha512-IZHaDeBeI+sZJRX7lGcXsdzgvZqKv6sECqsbErJA4mHWfpRrD8B97kSFN4cQz6nGBGiuFia1MKR4d6c1o8Cv7A==",
+ "dev": true,
+ "requires": {
+ "anymatch": "~3.1.1",
+ "braces": "~3.0.2",
+ "fsevents": "~2.1.2",
+ "glob-parent": "~5.1.0",
+ "is-binary-path": "~2.1.0",
+ "is-glob": "~4.0.1",
+ "normalize-path": "~3.0.0",
+ "readdirp": "~3.4.0"
+ }
+ },
+ "cliui": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz",
+ "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==",
+ "dev": true,
+ "requires": {
+ "string-width": "^3.1.0",
+ "strip-ansi": "^5.2.0",
+ "wrap-ansi": "^5.1.0"
+ },
+ "dependencies": {
+ "ansi-regex": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
+ "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
+ "dev": true
+ },
+ "strip-ansi": {
+ "version": "5.2.0",
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
+ "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==",
+ "dev": true,
+ "requires": {
+ "ansi-regex": "^4.1.0"
+ }
+ }
+ }
+ },
+ "color-convert": {
+ "version": "1.9.3",
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
+ "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
+ "requires": {
+ "color-name": "1.1.3"
+ }
+ },
+ "color-name": {
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
+ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU="
+ },
+ "concat-map": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
+ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
+ "dev": true
+ },
+ "convert-source-map": {
+ "version": "1.7.0",
+ "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.7.0.tgz",
+ "integrity": "sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA==",
+ "requires": {
+ "safe-buffer": "~5.1.1"
+ }
+ },
+ "cross-spawn": {
+ "version": "7.0.3",
+ "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
+ "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
+ "dev": true,
+ "requires": {
+ "path-key": "^3.1.0",
+ "shebang-command": "^2.0.0",
+ "which": "^2.0.1"
+ }
+ },
+ "debug": {
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
+ "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
+ "requires": {
+ "ms": "^2.1.1"
+ }
+ },
+ "decamelize": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
+ "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=",
+ "dev": true
+ },
+ "deep-is": {
+ "version": "0.1.3",
+ "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz",
+ "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=",
+ "dev": true
+ },
+ "define-properties": {
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz",
+ "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==",
+ "dev": true,
+ "requires": {
+ "object-keys": "^1.0.12"
+ }
+ },
+ "diff": {
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
+ "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
+ "dev": true
+ },
+ "doctrine": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",
+ "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==",
+ "dev": true,
+ "requires": {
+ "esutils": "^2.0.2"
+ }
+ },
+ "dom-serializer": {
+ "version": "0.2.2",
+ "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.2.2.tgz",
+ "integrity": "sha512-2/xPb3ORsQ42nHYiSunXkDjPLBaEj/xTwUO4B7XCZQTRk7EBtTOPaygh10YAAh2OI1Qrp6NWfpAhzswj0ydt9g==",
+ "requires": {
+ "domelementtype": "^2.0.1",
+ "entities": "^2.0.0"
+ },
+ "dependencies": {
+ "domelementtype": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.0.1.tgz",
+ "integrity": "sha512-5HOHUDsYZWV8FGWN0Njbr/Rn7f/eWSQi1v7+HsUVwXgn8nWWlL64zKDkS0n8ZmQ3mlWOMuXOnR+7Nx/5tMO5AQ=="
+ },
+ "entities": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/entities/-/entities-2.0.3.tgz",
+ "integrity": "sha512-MyoZ0jgnLvB2X3Lg5HqpFmn1kybDiIfEQmKzTb5apr51Rb+T3KdmMiqa70T+bhGnyv7bQ6WMj2QMHpGMmlrUYQ=="
+ }
+ }
+ },
+ "domelementtype": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz",
+ "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w=="
+ },
+ "domhandler": {
+ "version": "2.4.2",
+ "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.4.2.tgz",
+ "integrity": "sha512-JiK04h0Ht5u/80fdLMCEmV4zkNh2BcoMFBmZ/91WtYZ8qVXSKjiw7fXMgFPnHcSZgOo3XdinHvmnDUeMf5R4wA==",
+ "requires": {
+ "domelementtype": "1"
+ }
+ },
+ "domutils": {
+ "version": "1.7.0",
+ "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.7.0.tgz",
+ "integrity": "sha512-Lgd2XcJ/NjEw+7tFvfKxOzCYKZsdct5lczQ2ZaQY8Djz7pfAD3Gbp8ySJWtreII/vDlMVmxwa6pHmdxIYgttDg==",
+ "requires": {
+ "dom-serializer": "0",
+ "domelementtype": "1"
+ }
+ },
+ "emoji-regex": {
+ "version": "7.0.3",
+ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz",
+ "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==",
+ "dev": true
+ },
+ "enquirer": {
+ "version": "2.3.6",
+ "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz",
+ "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==",
+ "dev": true,
+ "requires": {
+ "ansi-colors": "^4.1.1"
+ }
+ },
+ "entities": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz",
+ "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w=="
+ },
+ "es-abstract": {
+ "version": "1.17.6",
+ "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.6.tgz",
+ "integrity": "sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw==",
+ "dev": true,
+ "requires": {
+ "es-to-primitive": "^1.2.1",
+ "function-bind": "^1.1.1",
+ "has": "^1.0.3",
+ "has-symbols": "^1.0.1",
+ "is-callable": "^1.2.0",
+ "is-regex": "^1.1.0",
+ "object-inspect": "^1.7.0",
+ "object-keys": "^1.1.1",
+ "object.assign": "^4.1.0",
+ "string.prototype.trimend": "^1.0.1",
+ "string.prototype.trimstart": "^1.0.1"
+ }
+ },
+ "es-array-method-boxes-properly": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/es-array-method-boxes-properly/-/es-array-method-boxes-properly-1.0.0.tgz",
+ "integrity": "sha512-wd6JXUmyHmt8T5a2xreUwKcGPq6f1f+WwIJkijUqiGcJz1qqnZgP6XIK+QyIWU5lT7imeNxUll48bziG+TSYcA==",
+ "dev": true
+ },
+ "es-get-iterator": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.0.tgz",
+ "integrity": "sha512-UfrmHuWQlNMTs35e1ypnvikg6jCz3SK8v8ImvmDsh36fCVUR1MqoFDiyn0/k52C8NqO3YsO8Oe0azeesNuqSsQ==",
+ "dev": true,
+ "requires": {
+ "es-abstract": "^1.17.4",
+ "has-symbols": "^1.0.1",
+ "is-arguments": "^1.0.4",
+ "is-map": "^2.0.1",
+ "is-set": "^2.0.1",
+ "is-string": "^1.0.5",
+ "isarray": "^2.0.5"
+ }
+ },
+ "es-to-primitive": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz",
+ "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==",
+ "dev": true,
+ "requires": {
+ "is-callable": "^1.1.4",
+ "is-date-object": "^1.0.1",
+ "is-symbol": "^1.0.2"
+ }
+ },
+ "escape-string-regexp": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
+ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ="
+ },
+ "eslint": {
+ "version": "7.8.0",
+ "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.8.0.tgz",
+ "integrity": "sha512-qgtVyLZqKd2ZXWnLQA4NtVbOyH56zivOAdBFWE54RFkSZjokzNrcP4Z0eVWsZ+84ByXv+jL9k/wE1ENYe8xRFw==",
+ "dev": true,
+ "requires": {
+ "@babel/code-frame": "^7.0.0",
+ "@eslint/eslintrc": "^0.1.0",
+ "ajv": "^6.10.0",
+ "chalk": "^4.0.0",
+ "cross-spawn": "^7.0.2",
+ "debug": "^4.0.1",
+ "doctrine": "^3.0.0",
+ "enquirer": "^2.3.5",
+ "eslint-scope": "^5.1.0",
+ "eslint-utils": "^2.1.0",
+ "eslint-visitor-keys": "^1.3.0",
+ "espree": "^7.3.0",
+ "esquery": "^1.2.0",
+ "esutils": "^2.0.2",
+ "file-entry-cache": "^5.0.1",
+ "functional-red-black-tree": "^1.0.1",
+ "glob-parent": "^5.0.0",
+ "globals": "^12.1.0",
+ "ignore": "^4.0.6",
+ "import-fresh": "^3.0.0",
+ "imurmurhash": "^0.1.4",
+ "is-glob": "^4.0.0",
+ "js-yaml": "^3.13.1",
+ "json-stable-stringify-without-jsonify": "^1.0.1",
+ "levn": "^0.4.1",
+ "lodash": "^4.17.19",
+ "minimatch": "^3.0.4",
+ "natural-compare": "^1.4.0",
+ "optionator": "^0.9.1",
+ "progress": "^2.0.0",
+ "regexpp": "^3.1.0",
+ "semver": "^7.2.1",
+ "strip-ansi": "^6.0.0",
+ "strip-json-comments": "^3.1.0",
+ "table": "^5.2.3",
+ "text-table": "^0.2.0",
+ "v8-compile-cache": "^2.0.3"
+ },
+ "dependencies": {
+ "ansi-styles": {
+ "version": "4.2.1",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz",
+ "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==",
+ "dev": true,
+ "requires": {
+ "@types/color-name": "^1.1.1",
+ "color-convert": "^2.0.1"
+ }
+ },
+ "chalk": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
+ "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==",
+ "dev": true,
+ "requires": {
+ "ansi-styles": "^4.1.0",
+ "supports-color": "^7.1.0"
+ }
+ },
+ "color-convert": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
+ "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
+ "dev": true,
+ "requires": {
+ "color-name": "~1.1.4"
+ }
+ },
+ "color-name": {
+ "version": "1.1.4",
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
+ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
+ "dev": true
+ },
+ "globals": {
+ "version": "12.4.0",
+ "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz",
+ "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==",
+ "dev": true,
+ "requires": {
+ "type-fest": "^0.8.1"
+ }
+ },
+ "has-flag": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
+ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
+ "dev": true
+ },
+ "semver": {
+ "version": "7.3.2",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz",
+ "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==",
+ "dev": true
+ },
+ "supports-color": {
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
+ "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
+ "dev": true,
+ "requires": {
+ "has-flag": "^4.0.0"
+ }
+ }
+ }
+ },
+ "eslint-scope": {
+ "version": "5.1.0",
+ "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.0.tgz",
+ "integrity": "sha512-iiGRvtxWqgtx5m8EyQUJihBloE4EnYeGE/bz1wSPwJE6tZuJUtHlhqDM4Xj2ukE8Dyy1+HCZ4hE0fzIVMzb58w==",
+ "requires": {
+ "esrecurse": "^4.1.0",
+ "estraverse": "^4.1.1"
+ }
+ },
+ "eslint-utils": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz",
+ "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==",
+ "dev": true,
+ "requires": {
+ "eslint-visitor-keys": "^1.1.0"
+ }
+ },
+ "eslint-visitor-keys": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz",
+ "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ=="
+ },
+ "espree": {
+ "version": "7.3.0",
+ "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.0.tgz",
+ "integrity": "sha512-dksIWsvKCixn1yrEXO8UosNSxaDoSYpq9reEjZSbHLpT5hpaCAKTLBwq0RHtLrIr+c0ByiYzWT8KTMRzoRCNlw==",
+ "dev": true,
+ "requires": {
+ "acorn": "^7.4.0",
+ "acorn-jsx": "^5.2.0",
+ "eslint-visitor-keys": "^1.3.0"
+ }
+ },
+ "esprima": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
+ "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
+ "dev": true
+ },
+ "esquery": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.3.1.tgz",
+ "integrity": "sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ==",
+ "dev": true,
+ "requires": {
+ "estraverse": "^5.1.0"
+ },
+ "dependencies": {
+ "estraverse": {
+ "version": "5.2.0",
+ "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz",
+ "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==",
+ "dev": true
+ }
+ }
+ },
+ "esrecurse": {
+ "version": "4.2.1",
+ "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz",
+ "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==",
+ "requires": {
+ "estraverse": "^4.1.0"
+ }
+ },
+ "estraverse": {
+ "version": "4.3.0",
+ "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz",
+ "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw=="
+ },
+ "esutils": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
+ "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
+ "dev": true
+ },
+ "fast-deep-equal": {
+ "version": "3.1.3",
+ "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
+ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
+ "dev": true
+ },
+ "fast-json-stable-stringify": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
+ "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==",
+ "dev": true
+ },
+ "fast-levenshtein": {
+ "version": "2.0.6",
+ "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz",
+ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=",
+ "dev": true
+ },
+ "file-entry-cache": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz",
+ "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==",
+ "dev": true,
+ "requires": {
+ "flat-cache": "^2.0.1"
+ }
+ },
+ "fill-range": {
+ "version": "7.0.1",
+ "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
+ "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
+ "dev": true,
+ "requires": {
+ "to-regex-range": "^5.0.1"
+ }
+ },
+ "find-up": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz",
+ "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==",
+ "dev": true,
+ "requires": {
+ "locate-path": "^6.0.0",
+ "path-exists": "^4.0.0"
+ }
+ },
+ "flat": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/flat/-/flat-4.1.0.tgz",
+ "integrity": "sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw==",
+ "dev": true,
+ "requires": {
+ "is-buffer": "~2.0.3"
+ }
+ },
+ "flat-cache": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz",
+ "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==",
+ "dev": true,
+ "requires": {
+ "flatted": "^2.0.0",
+ "rimraf": "2.6.3",
+ "write": "1.0.3"
+ }
+ },
+ "flatted": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.2.tgz",
+ "integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==",
+ "dev": true
+ },
+ "fs.realpath": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
+ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
+ "dev": true
+ },
+ "fsevents": {
+ "version": "2.1.3",
+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz",
+ "integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==",
+ "dev": true,
+ "optional": true
+ },
+ "function-bind": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
+ "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
+ "dev": true
+ },
+ "functional-red-black-tree": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz",
+ "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=",
+ "dev": true
+ },
+ "gensync": {
+ "version": "1.0.0-beta.1",
+ "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.1.tgz",
+ "integrity": "sha512-r8EC6NO1sngH/zdD9fiRDLdcgnbayXah+mLgManTaIZJqEC1MZstmnox8KpnI2/fxQwrp5OpCOYWLp4rBl4Jcg=="
+ },
+ "get-caller-file": {
+ "version": "2.0.5",
+ "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
+ "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
+ "dev": true
+ },
+ "glob": {
+ "version": "7.1.6",
+ "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
+ "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
+ "dev": true,
+ "requires": {
+ "fs.realpath": "^1.0.0",
+ "inflight": "^1.0.4",
+ "inherits": "2",
+ "minimatch": "^3.0.4",
+ "once": "^1.3.0",
+ "path-is-absolute": "^1.0.0"
+ }
+ },
+ "glob-parent": {
+ "version": "5.1.1",
+ "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz",
+ "integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==",
+ "dev": true,
+ "requires": {
+ "is-glob": "^4.0.1"
+ }
+ },
+ "globals": {
+ "version": "11.12.0",
+ "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz",
+ "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA=="
+ },
+ "growl": {
+ "version": "1.10.5",
+ "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz",
+ "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==",
+ "dev": true
+ },
+ "has": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
+ "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
+ "dev": true,
+ "requires": {
+ "function-bind": "^1.1.1"
+ }
+ },
+ "has-flag": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
+ "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0="
+ },
+ "has-symbols": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz",
+ "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==",
+ "dev": true
+ },
+ "he": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
+ "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==",
+ "dev": true
+ },
+ "htmlparser2": {
+ "version": "3.10.1",
+ "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.10.1.tgz",
+ "integrity": "sha512-IgieNijUMbkDovyoKObU1DUhm1iwNYE/fuifEoEHfd1oZKZDaONBSkal7Y01shxsM49R4XaMdGez3WnF9UfiCQ==",
+ "requires": {
+ "domelementtype": "^1.3.1",
+ "domhandler": "^2.3.0",
+ "domutils": "^1.5.1",
+ "entities": "^1.1.1",
+ "inherits": "^2.0.1",
+ "readable-stream": "^3.1.1"
+ }
+ },
+ "ignore": {
+ "version": "4.0.6",
+ "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz",
+ "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==",
+ "dev": true
+ },
+ "import-fresh": {
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz",
+ "integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==",
+ "dev": true,
+ "requires": {
+ "parent-module": "^1.0.0",
+ "resolve-from": "^4.0.0"
+ }
+ },
+ "imurmurhash": {
+ "version": "0.1.4",
+ "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
+ "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=",
+ "dev": true
+ },
+ "inflight": {
+ "version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
+ "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
+ "dev": true,
+ "requires": {
+ "once": "^1.3.0",
+ "wrappy": "1"
+ }
+ },
+ "inherits": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
+ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
+ },
+ "is-arguments": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.0.4.tgz",
+ "integrity": "sha512-xPh0Rmt8NE65sNzvyUmWgI1tz3mKq74lGA0mL8LYZcoIzKOzDh6HmrYm3d18k60nHerC8A9Km8kYu87zfSFnLA==",
+ "dev": true
+ },
+ "is-binary-path": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
+ "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
+ "dev": true,
+ "requires": {
+ "binary-extensions": "^2.0.0"
+ }
+ },
+ "is-buffer": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz",
+ "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==",
+ "dev": true
+ },
+ "is-callable": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.2.tgz",
+ "integrity": "sha512-dnMqspv5nU3LoewK2N/y7KLtxtakvTuaCsU9FU50/QDmdbHNy/4/JuRtMHqRU22o3q+W89YQndQEeCVwK+3qrA==",
+ "dev": true
+ },
+ "is-date-object": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz",
+ "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==",
+ "dev": true
+ },
+ "is-extglob": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
+ "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=",
+ "dev": true
+ },
+ "is-fullwidth-code-point": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
+ "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=",
+ "dev": true
+ },
+ "is-glob": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz",
+ "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==",
+ "dev": true,
+ "requires": {
+ "is-extglob": "^2.1.1"
+ }
+ },
+ "is-map": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.1.tgz",
+ "integrity": "sha512-T/S49scO8plUiAOA2DBTBG3JHpn1yiw0kRp6dgiZ0v2/6twi5eiB0rHtHFH9ZIrvlWc6+4O+m4zg5+Z833aXgw==",
+ "dev": true
+ },
+ "is-number": {
+ "version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
+ "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
+ "dev": true
+ },
+ "is-plain-obj": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz",
+ "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=",
+ "dev": true
+ },
+ "is-regex": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.1.tgz",
+ "integrity": "sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg==",
+ "dev": true,
+ "requires": {
+ "has-symbols": "^1.0.1"
+ }
+ },
+ "is-set": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.1.tgz",
+ "integrity": "sha512-eJEzOtVyenDs1TMzSQ3kU3K+E0GUS9sno+F0OBT97xsgcJsF9nXMBtkT9/kut5JEpM7oL7X/0qxR17K3mcwIAA==",
+ "dev": true
+ },
+ "is-string": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.5.tgz",
+ "integrity": "sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==",
+ "dev": true
+ },
+ "is-symbol": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz",
+ "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==",
+ "dev": true,
+ "requires": {
+ "has-symbols": "^1.0.1"
+ }
+ },
+ "isarray": {
+ "version": "2.0.5",
+ "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz",
+ "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==",
+ "dev": true
+ },
+ "isexe": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
+ "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=",
+ "dev": true
+ },
+ "iterate-iterator": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/iterate-iterator/-/iterate-iterator-1.0.1.tgz",
+ "integrity": "sha512-3Q6tudGN05kbkDQDI4CqjaBf4qf85w6W6GnuZDtUVYwKgtC1q8yxYX7CZed7N+tLzQqS6roujWvszf13T+n9aw==",
+ "dev": true
+ },
+ "iterate-value": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/iterate-value/-/iterate-value-1.0.2.tgz",
+ "integrity": "sha512-A6fMAio4D2ot2r/TYzr4yUWrmwNdsN5xL7+HUiyACE4DXm+q8HtPcnFTp+NnW3k4N05tZ7FVYFFb2CR13NxyHQ==",
+ "dev": true,
+ "requires": {
+ "es-get-iterator": "^1.0.2",
+ "iterate-iterator": "^1.0.1"
+ }
+ },
+ "js-tokens": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
+ "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="
+ },
+ "js-yaml": {
+ "version": "3.14.0",
+ "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.0.tgz",
+ "integrity": "sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==",
+ "dev": true,
+ "requires": {
+ "argparse": "^1.0.7",
+ "esprima": "^4.0.0"
+ }
+ },
+ "jsesc": {
+ "version": "2.5.2",
+ "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz",
+ "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA=="
+ },
+ "json-schema-traverse": {
+ "version": "0.4.1",
+ "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
+ "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
+ "dev": true
+ },
+ "json-stable-stringify-without-jsonify": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz",
+ "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=",
+ "dev": true
+ },
+ "json5": {
+ "version": "2.1.3",
+ "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.3.tgz",
+ "integrity": "sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA==",
+ "requires": {
+ "minimist": "^1.2.5"
+ }
+ },
+ "levn": {
+ "version": "0.4.1",
+ "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz",
+ "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==",
+ "dev": true,
+ "requires": {
+ "prelude-ls": "^1.2.1",
+ "type-check": "~0.4.0"
+ }
+ },
+ "locate-path": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
+ "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==",
+ "dev": true,
+ "requires": {
+ "p-locate": "^5.0.0"
+ }
+ },
+ "lodash": {
+ "version": "4.17.19",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz",
+ "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ=="
+ },
+ "log-symbols": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.0.0.tgz",
+ "integrity": "sha512-FN8JBzLx6CzeMrB0tg6pqlGU1wCrXW+ZXGH481kfsBqer0hToTIiHdjH4Mq8xJUbvATujKCvaREGWpGUionraA==",
+ "dev": true,
+ "requires": {
+ "chalk": "^4.0.0"
+ },
+ "dependencies": {
+ "ansi-styles": {
+ "version": "4.2.1",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz",
+ "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==",
+ "dev": true,
+ "requires": {
+ "@types/color-name": "^1.1.1",
+ "color-convert": "^2.0.1"
+ }
+ },
+ "chalk": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
+ "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==",
+ "dev": true,
+ "requires": {
+ "ansi-styles": "^4.1.0",
+ "supports-color": "^7.1.0"
+ }
+ },
+ "color-convert": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
+ "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
+ "dev": true,
+ "requires": {
+ "color-name": "~1.1.4"
+ }
+ },
+ "color-name": {
+ "version": "1.1.4",
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
+ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
+ "dev": true
+ },
+ "has-flag": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
+ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
+ "dev": true
+ },
+ "supports-color": {
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
+ "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
+ "dev": true,
+ "requires": {
+ "has-flag": "^4.0.0"
+ }
+ }
+ }
+ },
+ "minimatch": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
+ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
+ "dev": true,
+ "requires": {
+ "brace-expansion": "^1.1.7"
+ }
+ },
+ "minimist": {
+ "version": "1.2.5",
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
+ "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
+ },
+ "mkdirp": {
+ "version": "0.5.5",
+ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
+ "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
+ "dev": true,
+ "requires": {
+ "minimist": "^1.2.5"
+ }
+ },
+ "mocha": {
+ "version": "8.1.3",
+ "resolved": "https://registry.npmjs.org/mocha/-/mocha-8.1.3.tgz",
+ "integrity": "sha512-ZbaYib4hT4PpF4bdSO2DohooKXIn4lDeiYqB+vTmCdr6l2woW0b6H3pf5x4sM5nwQMru9RvjjHYWVGltR50ZBw==",
+ "dev": true,
+ "requires": {
+ "ansi-colors": "4.1.1",
+ "browser-stdout": "1.3.1",
+ "chokidar": "3.4.2",
+ "debug": "4.1.1",
+ "diff": "4.0.2",
+ "escape-string-regexp": "4.0.0",
+ "find-up": "5.0.0",
+ "glob": "7.1.6",
+ "growl": "1.10.5",
+ "he": "1.2.0",
+ "js-yaml": "3.14.0",
+ "log-symbols": "4.0.0",
+ "minimatch": "3.0.4",
+ "ms": "2.1.2",
+ "object.assign": "4.1.0",
+ "promise.allsettled": "1.0.2",
+ "serialize-javascript": "4.0.0",
+ "strip-json-comments": "3.0.1",
+ "supports-color": "7.1.0",
+ "which": "2.0.2",
+ "wide-align": "1.1.3",
+ "workerpool": "6.0.0",
+ "yargs": "13.3.2",
+ "yargs-parser": "13.1.2",
+ "yargs-unparser": "1.6.1"
+ },
+ "dependencies": {
+ "escape-string-regexp": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
+ "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
+ "dev": true
+ },
+ "has-flag": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
+ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
+ "dev": true
+ },
+ "strip-json-comments": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.0.1.tgz",
+ "integrity": "sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw==",
+ "dev": true
+ },
+ "supports-color": {
+ "version": "7.1.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz",
+ "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==",
+ "dev": true,
+ "requires": {
+ "has-flag": "^4.0.0"
+ }
+ }
+ }
+ },
+ "ms": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
+ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
+ },
+ "multi-ini": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/multi-ini/-/multi-ini-2.1.0.tgz",
+ "integrity": "sha512-ANOg4WIoTXYfqyT2Y6FGb8YQyItatdJvfAZKAfFMWT1+D3vUstocjkUQ82EduAeK69rCR6a9k0fggxRhsFnAyQ==",
+ "requires": {
+ "lodash": "^4.0.0"
+ }
+ },
+ "natural-compare": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
+ "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=",
+ "dev": true
+ },
+ "normalize-path": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
+ "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
+ "dev": true
+ },
+ "object-inspect": {
+ "version": "1.8.0",
+ "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.8.0.tgz",
+ "integrity": "sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA==",
+ "dev": true
+ },
+ "object-keys": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
+ "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==",
+ "dev": true
+ },
+ "object.assign": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz",
+ "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==",
+ "dev": true,
+ "requires": {
+ "define-properties": "^1.1.2",
+ "function-bind": "^1.1.1",
+ "has-symbols": "^1.0.0",
+ "object-keys": "^1.0.11"
+ }
+ },
+ "once": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
+ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
+ "dev": true,
+ "requires": {
+ "wrappy": "1"
+ }
+ },
+ "optionator": {
+ "version": "0.9.1",
+ "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz",
+ "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==",
+ "dev": true,
+ "requires": {
+ "deep-is": "^0.1.3",
+ "fast-levenshtein": "^2.0.6",
+ "levn": "^0.4.1",
+ "prelude-ls": "^1.2.1",
+ "type-check": "^0.4.0",
+ "word-wrap": "^1.2.3"
+ }
+ },
+ "p-limit": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.0.2.tgz",
+ "integrity": "sha512-iwqZSOoWIW+Ew4kAGUlN16J4M7OB3ysMLSZtnhmqx7njIHFPlxWBX8xo3lVTyFVq6mI/lL9qt2IsN1sHwaxJkg==",
+ "dev": true,
+ "requires": {
+ "p-try": "^2.0.0"
+ }
+ },
+ "p-locate": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz",
+ "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==",
+ "dev": true,
+ "requires": {
+ "p-limit": "^3.0.2"
+ }
+ },
+ "p-try": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
+ "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
+ "dev": true
+ },
+ "parent-module": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
+ "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==",
+ "dev": true,
+ "requires": {
+ "callsites": "^3.0.0"
+ }
+ },
+ "path-exists": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
+ "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
+ "dev": true
+ },
+ "path-is-absolute": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
+ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
+ "dev": true
+ },
+ "path-key": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
+ "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
+ "dev": true
+ },
+ "path-parse": {
+ "version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
+ "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw=="
+ },
+ "picomatch": {
+ "version": "2.2.2",
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz",
+ "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==",
+ "dev": true
+ },
+ "prelude-ls": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",
+ "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==",
+ "dev": true
+ },
+ "progress": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz",
+ "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==",
+ "dev": true
+ },
+ "promise.allsettled": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/promise.allsettled/-/promise.allsettled-1.0.2.tgz",
+ "integrity": "sha512-UpcYW5S1RaNKT6pd+s9jp9K9rlQge1UXKskec0j6Mmuq7UJCvlS2J2/s/yuPN8ehftf9HXMxWlKiPbGGUzpoRg==",
+ "dev": true,
+ "requires": {
+ "array.prototype.map": "^1.0.1",
+ "define-properties": "^1.1.3",
+ "es-abstract": "^1.17.0-next.1",
+ "function-bind": "^1.1.1",
+ "iterate-value": "^1.0.0"
+ }
+ },
+ "punycode": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
+ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==",
+ "dev": true
+ },
+ "randombytes": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
+ "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==",
+ "dev": true,
+ "requires": {
+ "safe-buffer": "^5.1.0"
+ }
+ },
+ "readable-stream": {
+ "version": "3.6.0",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
+ "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
+ "requires": {
+ "inherits": "^2.0.3",
+ "string_decoder": "^1.1.1",
+ "util-deprecate": "^1.0.1"
+ }
+ },
+ "readdirp": {
+ "version": "3.4.0",
+ "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.4.0.tgz",
+ "integrity": "sha512-0xe001vZBnJEK+uKcj8qOhyAKPzIT+gStxWr3LCB0DwcXR5NZJ3IaC+yGnHCYzB/S7ov3m3EEbZI2zeNvX+hGQ==",
+ "dev": true,
+ "requires": {
+ "picomatch": "^2.2.1"
+ }
+ },
+ "regexpp": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz",
+ "integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==",
+ "dev": true
+ },
+ "require-directory": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
+ "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=",
+ "dev": true
+ },
+ "require-main-filename": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz",
+ "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==",
+ "dev": true
+ },
+ "resolve": {
+ "version": "1.17.0",
+ "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz",
+ "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==",
+ "requires": {
+ "path-parse": "^1.0.6"
+ }
+ },
+ "resolve-from": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
+ "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==",
+ "dev": true
+ },
+ "rimraf": {
+ "version": "2.6.3",
+ "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz",
+ "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==",
+ "dev": true,
+ "requires": {
+ "glob": "^7.1.3"
+ }
+ },
+ "safe-buffer": {
+ "version": "5.1.2",
+ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
+ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
+ },
+ "sax": {
+ "version": "1.2.4",
+ "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
+ "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
+ },
+ "semver": {
+ "version": "5.7.1",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
+ "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ=="
+ },
+ "serialize-javascript": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz",
+ "integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==",
+ "dev": true,
+ "requires": {
+ "randombytes": "^2.1.0"
+ }
+ },
+ "set-blocking": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
+ "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=",
+ "dev": true
+ },
+ "shebang-command": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
+ "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
+ "dev": true,
+ "requires": {
+ "shebang-regex": "^3.0.0"
+ }
+ },
+ "shebang-regex": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
+ "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
+ "dev": true
+ },
+ "slice-ansi": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz",
+ "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==",
+ "dev": true,
+ "requires": {
+ "ansi-styles": "^3.2.0",
+ "astral-regex": "^1.0.0",
+ "is-fullwidth-code-point": "^2.0.0"
+ }
+ },
+ "source-map": {
+ "version": "0.5.7",
+ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
+ "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w="
+ },
+ "sprintf-js": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
+ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
+ "dev": true
+ },
+ "string-width": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz",
+ "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==",
+ "dev": true,
+ "requires": {
+ "emoji-regex": "^7.0.1",
+ "is-fullwidth-code-point": "^2.0.0",
+ "strip-ansi": "^5.1.0"
+ },
+ "dependencies": {
+ "ansi-regex": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
+ "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
+ "dev": true
+ },
+ "strip-ansi": {
+ "version": "5.2.0",
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
+ "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==",
+ "dev": true,
+ "requires": {
+ "ansi-regex": "^4.1.0"
+ }
+ }
+ }
+ },
+ "string.prototype.trimend": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz",
+ "integrity": "sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g==",
+ "dev": true,
+ "requires": {
+ "define-properties": "^1.1.3",
+ "es-abstract": "^1.17.5"
+ }
+ },
+ "string.prototype.trimstart": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz",
+ "integrity": "sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw==",
+ "dev": true,
+ "requires": {
+ "define-properties": "^1.1.3",
+ "es-abstract": "^1.17.5"
+ }
+ },
+ "string_decoder": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
+ "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
+ "requires": {
+ "safe-buffer": "~5.2.0"
+ },
+ "dependencies": {
+ "safe-buffer": {
+ "version": "5.2.1",
+ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
+ "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
+ }
+ }
+ },
+ "strip-ansi": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz",
+ "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==",
+ "dev": true,
+ "requires": {
+ "ansi-regex": "^5.0.0"
+ }
+ },
+ "strip-json-comments": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
+ "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==",
+ "dev": true
+ },
+ "supports-color": {
+ "version": "5.5.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
+ "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
+ "requires": {
+ "has-flag": "^3.0.0"
+ }
+ },
+ "table": {
+ "version": "5.4.6",
+ "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz",
+ "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==",
+ "dev": true,
+ "requires": {
+ "ajv": "^6.10.2",
+ "lodash": "^4.17.14",
+ "slice-ansi": "^2.1.0",
+ "string-width": "^3.0.0"
+ }
+ },
+ "text-table": {
+ "version": "0.2.0",
+ "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",
+ "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=",
+ "dev": true
+ },
+ "to-fast-properties": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
+ "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4="
+ },
+ "to-regex-range": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
+ "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
+ "dev": true,
+ "requires": {
+ "is-number": "^7.0.0"
+ }
+ },
+ "type-check": {
+ "version": "0.4.0",
+ "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
+ "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==",
+ "dev": true,
+ "requires": {
+ "prelude-ls": "^1.2.1"
+ }
+ },
+ "type-fest": {
+ "version": "0.8.1",
+ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz",
+ "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==",
+ "dev": true
+ },
+ "uri-js": {
+ "version": "4.4.0",
+ "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.0.tgz",
+ "integrity": "sha512-B0yRTzYdUCCn9n+F4+Gh4yIDtMQcaJsmYBDsTSG8g/OejKBodLQ2IHfN3bM7jUsRXndopT7OIXWdYqc1fjmV6g==",
+ "dev": true,
+ "requires": {
+ "punycode": "^2.1.0"
+ }
+ },
+ "util-deprecate": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
+ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
+ },
+ "v8-compile-cache": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz",
+ "integrity": "sha512-8OQ9CL+VWyt3JStj7HX7/ciTL2V3Rl1Wf5OL+SNTm0yK1KvtReVulksyeRnCANHHuUxHlQig+JJDlUhBt1NQDQ==",
+ "dev": true
+ },
+ "which": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
+ "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
+ "dev": true,
+ "requires": {
+ "isexe": "^2.0.0"
+ }
+ },
+ "which-module": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz",
+ "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=",
+ "dev": true
+ },
+ "wide-align": {
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz",
+ "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==",
+ "dev": true,
+ "requires": {
+ "string-width": "^1.0.2 || 2"
+ },
+ "dependencies": {
+ "ansi-regex": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
+ "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=",
+ "dev": true
+ },
+ "string-width": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",
+ "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==",
+ "dev": true,
+ "requires": {
+ "is-fullwidth-code-point": "^2.0.0",
+ "strip-ansi": "^4.0.0"
+ }
+ },
+ "strip-ansi": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
+ "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=",
+ "dev": true,
+ "requires": {
+ "ansi-regex": "^3.0.0"
+ }
+ }
+ }
+ },
+ "word-wrap": {
+ "version": "1.2.3",
+ "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
+ "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==",
+ "dev": true
+ },
+ "workerpool": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.0.0.tgz",
+ "integrity": "sha512-fU2OcNA/GVAJLLyKUoHkAgIhKb0JoCpSjLC/G2vYKxUjVmQwGbRVeoPJ1a8U4pnVofz4AQV5Y/NEw8oKqxEBtA==",
+ "dev": true
+ },
+ "wrap-ansi": {
+ "version": "5.1.0",
+ "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz",
+ "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==",
+ "dev": true,
+ "requires": {
+ "ansi-styles": "^3.2.0",
+ "string-width": "^3.0.0",
+ "strip-ansi": "^5.0.0"
+ },
+ "dependencies": {
+ "ansi-regex": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
+ "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
+ "dev": true
+ },
+ "strip-ansi": {
+ "version": "5.2.0",
+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
+ "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==",
+ "dev": true,
+ "requires": {
+ "ansi-regex": "^4.1.0"
+ }
+ }
+ }
+ },
+ "wrappy": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
+ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
+ "dev": true
+ },
+ "write": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz",
+ "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==",
+ "dev": true,
+ "requires": {
+ "mkdirp": "^0.5.1"
+ }
+ },
+ "y18n": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz",
+ "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==",
+ "dev": true
+ },
+ "yargs": {
+ "version": "13.3.2",
+ "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.2.tgz",
+ "integrity": "sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==",
+ "dev": true,
+ "requires": {
+ "cliui": "^5.0.0",
+ "find-up": "^3.0.0",
+ "get-caller-file": "^2.0.1",
+ "require-directory": "^2.1.1",
+ "require-main-filename": "^2.0.0",
+ "set-blocking": "^2.0.0",
+ "string-width": "^3.0.0",
+ "which-module": "^2.0.0",
+ "y18n": "^4.0.0",
+ "yargs-parser": "^13.1.2"
+ },
+ "dependencies": {
+ "find-up": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz",
+ "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==",
+ "dev": true,
+ "requires": {
+ "locate-path": "^3.0.0"
+ }
+ },
+ "locate-path": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz",
+ "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==",
+ "dev": true,
+ "requires": {
+ "p-locate": "^3.0.0",
+ "path-exists": "^3.0.0"
+ }
+ },
+ "p-limit": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
+ "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
+ "dev": true,
+ "requires": {
+ "p-try": "^2.0.0"
+ }
+ },
+ "p-locate": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz",
+ "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==",
+ "dev": true,
+ "requires": {
+ "p-limit": "^2.0.0"
+ }
+ },
+ "path-exists": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz",
+ "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=",
+ "dev": true
+ }
+ }
+ },
+ "yargs-parser": {
+ "version": "13.1.2",
+ "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz",
+ "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==",
+ "dev": true,
+ "requires": {
+ "camelcase": "^5.0.0",
+ "decamelize": "^1.2.0"
+ }
+ },
+ "yargs-unparser": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-1.6.1.tgz",
+ "integrity": "sha512-qZV14lK9MWsGCmcr7u5oXGH0dbGqZAIxTDrWXZDo5zUr6b6iUmelNKO6x6R1dQT24AH3LgRxJpr8meWy2unolA==",
+ "dev": true,
+ "requires": {
+ "camelcase": "^5.3.1",
+ "decamelize": "^1.2.0",
+ "flat": "^4.1.0",
+ "is-plain-obj": "^1.1.0",
+ "yargs": "^14.2.3"
+ },
+ "dependencies": {
+ "find-up": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz",
+ "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==",
+ "dev": true,
+ "requires": {
+ "locate-path": "^3.0.0"
+ }
+ },
+ "locate-path": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz",
+ "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==",
+ "dev": true,
+ "requires": {
+ "p-locate": "^3.0.0",
+ "path-exists": "^3.0.0"
+ }
+ },
+ "p-limit": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
+ "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
+ "dev": true,
+ "requires": {
+ "p-try": "^2.0.0"
+ }
+ },
+ "p-locate": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz",
+ "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==",
+ "dev": true,
+ "requires": {
+ "p-limit": "^2.0.0"
+ }
+ },
+ "path-exists": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz",
+ "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=",
+ "dev": true
+ },
+ "yargs": {
+ "version": "14.2.3",
+ "resolved": "https://registry.npmjs.org/yargs/-/yargs-14.2.3.tgz",
+ "integrity": "sha512-ZbotRWhF+lkjijC/VhmOT9wSgyBQ7+zr13+YLkhfsSiTriYsMzkTUFP18pFhWwBeMa5gUc1MzbhrO6/VB7c9Xg==",
+ "dev": true,
+ "requires": {
+ "cliui": "^5.0.0",
+ "decamelize": "^1.2.0",
+ "find-up": "^3.0.0",
+ "get-caller-file": "^2.0.1",
+ "require-directory": "^2.1.1",
+ "require-main-filename": "^2.0.0",
+ "set-blocking": "^2.0.0",
+ "string-width": "^3.0.0",
+ "which-module": "^2.0.0",
+ "y18n": "^4.0.0",
+ "yargs-parser": "^15.0.1"
+ }
+ },
+ "yargs-parser": {
+ "version": "15.0.1",
+ "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-15.0.1.tgz",
+ "integrity": "sha512-0OAMV2mAZQrs3FkNpDQcBk1x5HXb8X4twADss4S0Iuk+2dGnLOE/fRHrsYm542GduMveyA77OF4wrNJuanRCWw==",
+ "dev": true,
+ "requires": {
+ "camelcase": "^5.0.0",
+ "decamelize": "^1.2.0"
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/package.json b/tools/lint/eslint/eslint-plugin-mozilla/package.json
new file mode 100644
index 0000000000..8edd8684a5
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/package.json
@@ -0,0 +1,55 @@
+{
+ "name": "eslint-plugin-mozilla",
+ "version": "2.9.2",
+ "description": "A collection of rules that help enforce JavaScript coding standard in the Mozilla project.",
+ "keywords": [
+ "eslint",
+ "eslintplugin",
+ "eslint-plugin",
+ "mozilla",
+ "firefox"
+ ],
+ "bugs": {
+ "url": "https://bugzilla.mozilla.org/enter_bug.cgi?product=Testing&component=Lint"
+ },
+ "homepage": "http://firefox-source-docs.mozilla.org/tools/lint/linters/eslint-plugin-mozilla.html",
+ "repository": {
+ "type": "hg",
+ "url": "https://hg.mozilla.org/mozilla-central/"
+ },
+ "author": "Mike Ratcliffe",
+ "main": "lib/index.js",
+ "dependencies": {
+ "@babel/core": "7.8.3",
+ "babel-eslint": "10.1.0",
+ "eslint-scope": "5.1.0",
+ "eslint-visitor-keys": "1.3.0",
+ "estraverse": "4.3.0",
+ "htmlparser2": "3.10.1",
+ "multi-ini": "2.1.0",
+ "sax": "1.2.4"
+ },
+ "devDependencies": {
+ "eslint": "7.8.0",
+ "mocha": "^8.1.3"
+ },
+ "peerDependencies": {
+ "eslint-config-prettier": "^6.0.0",
+ "eslint-plugin-fetch-options": "^0.0.5",
+ "eslint-plugin-html": "^6.0.0",
+ "eslint-plugin-no-unsanitized": "^3.1.4",
+ "eslint-plugin-prettier": "^3.0.1",
+ "eslint": "^7.8.0",
+ "prettier": "^1.17.0"
+ },
+ "engines": {
+ "node": ">=6.9.1"
+ },
+ "scripts": {
+ "prepack": "node scripts/createExports.js",
+ "test": "mocha --reporter 'reporters/mozilla-format.js' tests",
+ "postpublish": "rm -f lib/modules.json lib/environments/saved-globals.json lib/rules/saved-rules-data.json",
+ "update-tooltool": "./update.sh"
+ },
+ "license": "MPL-2.0"
+}
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/reporters/mozilla-format.js b/tools/lint/eslint/eslint-plugin-mozilla/reporters/mozilla-format.js
new file mode 100644
index 0000000000..885727e8aa
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/reporters/mozilla-format.js
@@ -0,0 +1,50 @@
+/* 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/. */
+
+/**
+ * This file outputs the format that treeherder requires. If we integrate
+ * these tests with ./mach, then we may replace this with a json handler within
+ * mach itself.
+ */
+
+"use strict";
+
+var mocha = require("mocha");
+var path = require("path");
+module.exports = MozillaFormatter;
+
+function MozillaFormatter(runner) {
+ mocha.reporters.Base.call(this, runner);
+ var passes = 0;
+ var failures = 0;
+
+ runner.on("start", () => {
+ console.log("SUITE-START | eslint-plugin-mozilla");
+ });
+
+ runner.on("pass", function(test) {
+ passes++;
+ let title = test.title.replace(/\n/g, "|");
+ console.log(`TEST-PASS | ${path.basename(test.file)} | ${title}`);
+ });
+
+ runner.on("fail", function(test, err) {
+ failures++;
+ // Replace any newlines in the title.
+ let title = test.title.replace(/\n/g, "|");
+ console.log(
+ `TEST-UNEXPECTED-FAIL | ${path.basename(test.file)} | ${title} | ${
+ err.message
+ }`
+ );
+ });
+
+ runner.on("end", function() {
+ console.log("INFO | Result summary:");
+ console.log(`INFO | Passed: ${passes}`);
+ console.log(`INFO | Failed: ${failures}`);
+ console.log("SUITE-END");
+ process.exit(failures);
+ });
+}
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/scripts/createExports.js b/tools/lint/eslint/eslint-plugin-mozilla/scripts/createExports.js
new file mode 100644
index 0000000000..60d61b0f72
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/scripts/createExports.js
@@ -0,0 +1,89 @@
+/**
+ * @fileoverview A script to export the known globals to a file.
+ * 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 fs = require("fs");
+var path = require("path");
+var helpers = require("../lib/helpers");
+
+const eslintDir = path.join(helpers.rootDir, "tools", "lint", "eslint");
+
+const globalsFile = path.join(
+ eslintDir,
+ "eslint-plugin-mozilla",
+ "lib",
+ "environments",
+ "saved-globals.json"
+);
+const rulesFile = path.join(
+ eslintDir,
+ "eslint-plugin-mozilla",
+ "lib",
+ "rules",
+ "saved-rules-data.json"
+);
+
+console.log("Copying modules.json");
+
+const modulesFile = path.join(eslintDir, "modules.json");
+const shipModulesFile = path.join(
+ eslintDir,
+ "eslint-plugin-mozilla",
+ "lib",
+ "modules.json"
+);
+
+fs.writeFileSync(shipModulesFile, fs.readFileSync(modulesFile));
+
+console.log("Copying services.json");
+
+const env = helpers.getBuildEnvironment();
+
+const servicesFile = path.join(
+ env.topobjdir,
+ "xpcom",
+ "components",
+ "services.json"
+);
+const shipServicesFile = path.join(
+ eslintDir,
+ "eslint-plugin-mozilla",
+ "lib",
+ "services.json"
+);
+
+fs.writeFileSync(shipServicesFile, fs.readFileSync(servicesFile));
+
+console.log("Generating globals file");
+
+// Export the environments.
+let environmentGlobals = require("../lib/index.js").environments;
+
+return fs.writeFile(
+ globalsFile,
+ JSON.stringify({ environments: environmentGlobals }),
+ err => {
+ if (err) {
+ console.error(err);
+ process.exit(1);
+ }
+
+ console.log("Globals file generation complete");
+
+ console.log("Creating rules data file");
+ let rulesData = {};
+
+ return fs.writeFile(rulesFile, JSON.stringify({ rulesData }), err1 => {
+ if (err1) {
+ console.error(err1);
+ process.exit(1);
+ }
+
+ console.log("Globals file generation complete");
+ });
+ }
+);
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/avoid-Date-timing.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/avoid-Date-timing.js
new file mode 100644
index 0000000000..597961e8cc
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/avoid-Date-timing.js
@@ -0,0 +1,42 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/avoid-Date-timing");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function invalidCode(code, type, message) {
+ return { code, errors: [{ message, type }] };
+}
+
+ruleTester.run("avoid-Date-timing", rule, {
+ valid: [
+ "new Date('2017-07-11');",
+ "new Date(1499790192440);",
+ "new Date(2017, 7, 11);",
+ "Date.UTC(2017, 7);",
+ ],
+ invalid: [
+ invalidCode(
+ "Date.now();",
+ "CallExpression",
+ "use performance.now() instead of Date.now() for timing measurements"
+ ),
+ invalidCode(
+ "new Date();",
+ "NewExpression",
+ "use performance.now() instead of new Date() for timing measurements"
+ ),
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/avoid-removeChild.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/avoid-removeChild.js
new file mode 100644
index 0000000000..e6a146898d
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/avoid-removeChild.js
@@ -0,0 +1,46 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/avoid-removeChild");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function invalidCode(code, message) {
+ if (!message) {
+ message =
+ "use element.remove() instead of " +
+ "element.parentNode.removeChild(element)";
+ }
+ return { code, errors: [{ message, type: "CallExpression" }] };
+}
+
+ruleTester.run("avoid-removeChild", rule, {
+ valid: [
+ "elt.remove();",
+ "elt.parentNode.parentNode.removeChild(elt2.parentNode);",
+ "elt.parentNode.removeChild(elt2);",
+ "elt.removeChild(elt2);",
+ ],
+ invalid: [
+ invalidCode("elt.parentNode.removeChild(elt);"),
+ invalidCode("elt.parentNode.parentNode.removeChild(elt.parentNode);"),
+ invalidCode("$(e).parentNode.removeChild($(e));"),
+ invalidCode("$('e').parentNode.removeChild($('e'));"),
+ invalidCode(
+ "elt.removeChild(elt.firstChild);",
+ "use element.firstChild.remove() instead of " +
+ "element.removeChild(element.firstChild)"
+ ),
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/balanced-listeners.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/balanced-listeners.js
new file mode 100644
index 0000000000..ca84e3474f
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/balanced-listeners.js
@@ -0,0 +1,89 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/balanced-listeners");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function error(code, message) {
+ return {
+ code,
+ errors: [{ message, type: "Identifier" }],
+ };
+}
+
+ruleTester.run("balanced-listeners", rule, {
+ valid: [
+ "elt.addEventListener('event', handler);" +
+ "elt.removeEventListener('event', handler);",
+
+ "elt.addEventListener('event', handler, true);" +
+ "elt.removeEventListener('event', handler, true);",
+
+ "elt.addEventListener('event', handler, false);" +
+ "elt.removeEventListener('event', handler, false);",
+
+ "elt.addEventListener('event', handler);" +
+ "elt.removeEventListener('event', handler, false);",
+
+ "elt.addEventListener('event', handler, false);" +
+ "elt.removeEventListener('event', handler);",
+
+ "elt.addEventListener('event', handler, {capture: false});" +
+ "elt.removeEventListener('event', handler);",
+
+ "elt.addEventListener('event', handler);" +
+ "elt.removeEventListener('event', handler, {capture: false});",
+
+ "elt.addEventListener('event', handler, {capture: true});" +
+ "elt.removeEventListener('event', handler, true);",
+
+ "elt.addEventListener('event', handler, true);" +
+ "elt.removeEventListener('event', handler, {capture: true});",
+
+ "elt.addEventListener('event', handler, {once: true});",
+
+ "elt.addEventListener('event', handler, {once: true, capture: true});",
+ ],
+ invalid: [
+ error(
+ "elt.addEventListener('click', handler, false);",
+ "No corresponding 'removeEventListener(click)' was found."
+ ),
+
+ error(
+ "elt.addEventListener('click', handler, false);" +
+ "elt.removeEventListener('click', handler, true);",
+ "No corresponding 'removeEventListener(click)' was found."
+ ),
+
+ error(
+ "elt.addEventListener('click', handler, {capture: false});" +
+ "elt.removeEventListener('click', handler, true);",
+ "No corresponding 'removeEventListener(click)' was found."
+ ),
+
+ error(
+ "elt.addEventListener('click', handler, {capture: true});" +
+ "elt.removeEventListener('click', handler);",
+ "No corresponding 'removeEventListener(click)' was found."
+ ),
+
+ error(
+ "elt.addEventListener('click', handler, true);" +
+ "elt.removeEventListener('click', handler);",
+ "No corresponding 'removeEventListener(click)' was found."
+ ),
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/balanced-observers.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/balanced-observers.js
new file mode 100644
index 0000000000..e5f31fa969
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/balanced-observers.js
@@ -0,0 +1,74 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/balanced-observers");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function error(code, message) {
+ return {
+ code,
+ errors: [{ message, type: "Identifier" }],
+ };
+}
+
+ruleTester.run("balanced-observers", rule, {
+ valid: [
+ "Services.obs.addObserver(observer, 'observable');" +
+ "Services.obs.removeObserver(observer, 'observable');",
+ "Services.prefs.addObserver('preference.name', otherObserver);" +
+ "Services.prefs.removeObserver('preference.name', otherObserver);",
+ ],
+ invalid: [
+ error(
+ // missing Services.obs.removeObserver
+ "Services.obs.addObserver(observer, 'observable');",
+ "No corresponding 'removeObserver(\"observable\")' was found."
+ ),
+
+ error(
+ // wrong observable name for Services.obs.removeObserver
+ "Services.obs.addObserver(observer, 'observable');" +
+ "Services.obs.removeObserver(observer, 'different-observable');",
+ "No corresponding 'removeObserver(\"observable\")' was found."
+ ),
+
+ error(
+ // missing Services.prefs.removeObserver
+ "Services.prefs.addObserver('preference.name', otherObserver);",
+ "No corresponding 'removeObserver(\"preference.name\")' was found."
+ ),
+
+ error(
+ // wrong observable name for Services.prefs.removeObserver
+ "Services.prefs.addObserver('preference.name', otherObserver);" +
+ "Services.prefs.removeObserver('other.preference', otherObserver);",
+ "No corresponding 'removeObserver(\"preference.name\")' was found."
+ ),
+
+ error(
+ // mismatch Services.prefs vs Services.obs
+ "Services.obs.addObserver(observer, 'observable');" +
+ "Services.prefs.removeObserver(observer, 'observable');",
+ "No corresponding 'removeObserver(\"observable\")' was found."
+ ),
+
+ error(
+ "Services.prefs.addObserver('preference.name', otherObserver);" +
+ // mismatch Services.prefs vs Services.obs
+ "Services.obs.removeObserver('preference.name', otherObserver);",
+ "No corresponding 'removeObserver(\"preference.name\")' was found."
+ ),
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/consistent-if-bracing.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/consistent-if-bracing.js
new file mode 100644
index 0000000000..b6b5b849b9
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/consistent-if-bracing.js
@@ -0,0 +1,40 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/consistent-if-bracing");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 8 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function invalidCode(code) {
+ return { code, errors: [{ messageId: "consistentIfBracing" }] };
+}
+
+ruleTester.run("consistent-if-bracing", rule, {
+ valid: [
+ "if (true) {1} else {0}",
+ "if (false) 1; else 0",
+ "if (true) {1} else if (true) {2} else {0}",
+ "if (true) {1} else if (true) {2} else if (true) {3} else {0}",
+ ],
+ invalid: [
+ invalidCode(`if (true) {1} else 0`),
+ invalidCode("if (true) 1; else {0}"),
+ invalidCode("if (true) {1} else if (true) 2; else {0}"),
+ invalidCode("if (true) 1; else if (true) {2} else {0}"),
+ invalidCode("if (true) {1} else if (true) 2; else {0}"),
+ invalidCode("if (true) {1} else if (true) {2} else 0"),
+ invalidCode("if (true) {1} else if (true) {2} else if (true) 3; else {0}"),
+ invalidCode("if (true) {if (true) 1; else {0}} else {0}"),
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/mark-exported-symbols-as-used.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/mark-exported-symbols-as-used.js
new file mode 100644
index 0000000000..d004650997
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/mark-exported-symbols-as-used.js
@@ -0,0 +1,45 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/mark-exported-symbols-as-used");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function invalidCode(code, type, message) {
+ return { code, errors: [{ message, type }] };
+}
+
+ruleTester.run("mark-exported-symbols-as-used", rule, {
+ valid: [
+ "var EXPORTED_SYMBOLS = ['foo'];",
+ "this.EXPORTED_SYMBOLS = ['foo'];",
+ ],
+ invalid: [
+ invalidCode(
+ "let EXPORTED_SYMBOLS = ['foo'];",
+ "VariableDeclaration",
+ "EXPORTED_SYMBOLS cannot be declared via `let`. Use `var` or `this.EXPORTED_SYMBOLS =`"
+ ),
+ invalidCode(
+ "var EXPORTED_SYMBOLS = 'foo';",
+ "VariableDeclaration",
+ "Unexpected assignment of non-Array to EXPORTED_SYMBOLS"
+ ),
+ invalidCode(
+ "this.EXPORTED_SYMBOLS = 'foo';",
+ "AssignmentExpression",
+ "Unexpected assignment of non-Array to EXPORTED_SYMBOLS"
+ ),
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/no-arbitrary-setTimeout.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/no-arbitrary-setTimeout.js
new file mode 100644
index 0000000000..907b439b3c
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/no-arbitrary-setTimeout.js
@@ -0,0 +1,41 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/no-arbitrary-setTimeout");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function wrapCode(code, filename = "xpcshell/test_foo.js") {
+ return { code, filename };
+}
+
+function invalidCode(code) {
+ let message =
+ "listen for events instead of setTimeout() with arbitrary delay";
+ let obj = wrapCode(code);
+ obj.errors = [{ message, type: "CallExpression" }];
+ return obj;
+}
+
+ruleTester.run("no-arbitrary-setTimeout", rule, {
+ valid: [
+ wrapCode("setTimeout(function() {}, 0);"),
+ wrapCode("setTimeout(function() {});"),
+ wrapCode("setTimeout(function() {}, 10);", "test_foo.js"),
+ ],
+ invalid: [
+ invalidCode("setTimeout(function() {}, 10);"),
+ invalidCode("setTimeout(function() {}, timeout);"),
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/no-compare-against-boolean-literals.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/no-compare-against-boolean-literals.js
new file mode 100644
index 0000000000..722e6b5dda
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/no-compare-against-boolean-literals.js
@@ -0,0 +1,61 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/no-compare-against-boolean-literals");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function callError(message) {
+ return [{ message, type: "BinaryExpression" }];
+}
+
+const MESSAGE = "Don't compare for inexact equality against boolean literals";
+
+ruleTester.run("no-compare-against-boolean-literals", rule, {
+ valid: [`if (!foo) {}`, `if (!!foo) {}`],
+ invalid: [
+ {
+ code: `if (foo == true) {}`,
+ errors: callError(MESSAGE),
+ },
+ {
+ code: `if (foo != true) {}`,
+ errors: callError(MESSAGE),
+ },
+ {
+ code: `if (foo == false) {}`,
+ errors: callError(MESSAGE),
+ },
+ {
+ code: `if (foo != false) {}`,
+ errors: callError(MESSAGE),
+ },
+ {
+ code: `if (true == foo) {}`,
+ errors: callError(MESSAGE),
+ },
+ {
+ code: `if (true != foo) {}`,
+ errors: callError(MESSAGE),
+ },
+ {
+ code: `if (false == foo) {}`,
+ errors: callError(MESSAGE),
+ },
+ {
+ code: `if (false != foo) {}`,
+ errors: callError(MESSAGE),
+ },
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/no-define-cc-etc.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/no-define-cc-etc.js
new file mode 100644
index 0000000000..735c7f4654
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/no-define-cc-etc.js
@@ -0,0 +1,62 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/no-define-cc-etc");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 9 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function invalidCode(code, varNames) {
+ if (!Array.isArray(varNames)) {
+ varNames = [varNames];
+ }
+ return {
+ code,
+ errors: varNames.map(name => {
+ return {
+ message: `${name} is now defined in global scope, a separate definition is no longer necessary.`,
+ type: "VariableDeclarator",
+ };
+ }),
+ };
+}
+
+ruleTester.run("no-define-cc-etc", rule, {
+ valid: [
+ "var Cm = Components.manager;",
+ "const CC = Components.Constructor;",
+ "var {Constructor: CC, manager: Cm} = Components;",
+ "const {Constructor: CC, manager: Cm} = Components;",
+ "foo.Cc.test();",
+ "const {bar, ...foo} = obj;",
+ ],
+ invalid: [
+ invalidCode("var Cc;", "Cc"),
+ invalidCode("let Cc;", "Cc"),
+ invalidCode("let Ci;", "Ci"),
+ invalidCode("let Cr;", "Cr"),
+ invalidCode("let Cu;", "Cu"),
+ invalidCode("var Cc = Components.classes;", "Cc"),
+ invalidCode("const {classes: Cc} = Components;", "Cc"),
+ invalidCode("let {classes: Cc, manager: Cm} = Components", "Cc"),
+ invalidCode("const Cu = Components.utils;", "Cu"),
+ invalidCode("var Ci = Components.interfaces, Cc = Components.classes;", [
+ "Ci",
+ "Cc",
+ ]),
+ invalidCode("var {'interfaces': Ci, 'classes': Cc} = Components;", [
+ "Ci",
+ "Cc",
+ ]),
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/no-throw-cr-literal.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/no-throw-cr-literal.js
new file mode 100644
index 0000000000..6750213e72
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/no-throw-cr-literal.js
@@ -0,0 +1,62 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/no-throw-cr-literal");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function invalidCode(code, output, messageId) {
+ return {
+ code,
+ output,
+ errors: [{ messageId, type: "ThrowStatement" }],
+ };
+}
+
+ruleTester.run("no-throw-cr-literal", rule, {
+ valid: [
+ 'throw Components.Exception("", Cr.NS_ERROR_NOT_IMPLEMENTED);',
+ 'throw Components.Exception("", Components.results.NS_ERROR_UNEXPECTED);',
+ 'function t() { throw Components.Exception("", Cr.NS_ERROR_NO_CONTENT); }',
+ // We don't handle combined values, regular no-throw-literal catches them
+ 'throw Components.results.NS_ERROR_UNEXPECTED + "whoops";',
+ ],
+ invalid: [
+ invalidCode(
+ "throw Cr.NS_ERROR_NO_INTERFACE;",
+ 'throw Components.Exception("", Cr.NS_ERROR_NO_INTERFACE);',
+ "bareCR"
+ ),
+ invalidCode(
+ "throw Components.results.NS_ERROR_ABORT;",
+ 'throw Components.Exception("", Components.results.NS_ERROR_ABORT);',
+ "bareComponentsResults"
+ ),
+ invalidCode(
+ "function t() { throw Cr.NS_ERROR_NULL_POINTER; }",
+ 'function t() { throw Components.Exception("", Cr.NS_ERROR_NULL_POINTER); }',
+ "bareCR"
+ ),
+ invalidCode(
+ "throw new Error(Cr.NS_ERROR_ABORT);",
+ 'throw Components.Exception("", Cr.NS_ERROR_ABORT);',
+ "newErrorCR"
+ ),
+ invalidCode(
+ "throw new Error(Components.results.NS_ERROR_ABORT);",
+ 'throw Components.Exception("", Components.results.NS_ERROR_ABORT);',
+ "newErrorComponentsResults"
+ ),
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/no-useless-parameters.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/no-useless-parameters.js
new file mode 100644
index 0000000000..0c9b12f6eb
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/no-useless-parameters.js
@@ -0,0 +1,147 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/no-useless-parameters");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function callError(message) {
+ return [{ message, type: "CallExpression" }];
+}
+
+ruleTester.run("no-useless-parameters", rule, {
+ valid: [
+ "Services.prefs.clearUserPref('browser.search.custom');",
+ "Services.removeObserver('notification name', {});",
+ "Services.io.newURI('http://example.com');",
+ "Services.io.newURI('http://example.com', 'utf8');",
+ "elt.addEventListener('click', handler);",
+ "elt.addEventListener('click', handler, true);",
+ "elt.addEventListener('click', handler, {once: true});",
+ "elt.removeEventListener('click', handler);",
+ "elt.removeEventListener('click', handler, true);",
+ "Services.obs.addObserver(this, 'topic', true);",
+ "Services.obs.addObserver(this, 'topic');",
+ "Services.prefs.addObserver('branch', this, true);",
+ "Services.prefs.addObserver('branch', this);",
+ "array.appendElement(elt);",
+ "Services.obs.notifyObservers(obj, 'topic', 'data');",
+ "Services.obs.notifyObservers(obj, 'topic');",
+ "window.getComputedStyle(elt);",
+ "window.getComputedStyle(elt, ':before');",
+ ],
+ invalid: [
+ {
+ code: "Services.prefs.clearUserPref('browser.search.custom', false);",
+ output: "Services.prefs.clearUserPref('browser.search.custom');",
+ errors: callError("clearUserPref takes only 1 parameter."),
+ },
+ {
+ code: "Services.prefs.clearUserPref('browser.search.custom',\n false);",
+ output: "Services.prefs.clearUserPref('browser.search.custom');",
+ errors: callError("clearUserPref takes only 1 parameter."),
+ },
+ {
+ code: "Services.removeObserver('notification name', {}, false);",
+ output: "Services.removeObserver('notification name', {});",
+ errors: callError("removeObserver only takes 2 parameters."),
+ },
+ {
+ code: "Services.removeObserver('notification name', {}, true);",
+ output: "Services.removeObserver('notification name', {});",
+ errors: callError("removeObserver only takes 2 parameters."),
+ },
+ {
+ code: "Services.io.newURI('http://example.com', null, null);",
+ output: "Services.io.newURI('http://example.com');",
+ errors: callError("newURI's last parameters are optional."),
+ },
+ {
+ code: "Services.io.newURI('http://example.com', 'utf8', null);",
+ output: "Services.io.newURI('http://example.com', 'utf8');",
+ errors: callError("newURI's last parameters are optional."),
+ },
+ {
+ code: "Services.io.newURI('http://example.com', null);",
+ output: "Services.io.newURI('http://example.com');",
+ errors: callError("newURI's last parameters are optional."),
+ },
+ {
+ code: "Services.io.newURI('http://example.com', '', '');",
+ output: "Services.io.newURI('http://example.com');",
+ errors: callError("newURI's last parameters are optional."),
+ },
+ {
+ code: "Services.io.newURI('http://example.com', '');",
+ output: "Services.io.newURI('http://example.com');",
+ errors: callError("newURI's last parameters are optional."),
+ },
+ {
+ code: "elt.addEventListener('click', handler, false);",
+ output: "elt.addEventListener('click', handler);",
+ errors: callError(
+ "addEventListener's third parameter can be omitted when it's false."
+ ),
+ },
+ {
+ code: "elt.removeEventListener('click', handler, false);",
+ output: "elt.removeEventListener('click', handler);",
+ errors: callError(
+ "removeEventListener's third parameter can be omitted when it's" +
+ " false."
+ ),
+ },
+ {
+ code: "Services.obs.addObserver(this, 'topic', false);",
+ output: "Services.obs.addObserver(this, 'topic');",
+ errors: callError(
+ "addObserver's third parameter can be omitted when it's false."
+ ),
+ },
+ {
+ code: "Services.prefs.addObserver('branch', this, false);",
+ output: "Services.prefs.addObserver('branch', this);",
+ errors: callError(
+ "addObserver's third parameter can be omitted when it's false."
+ ),
+ },
+ {
+ code: "array.appendElement(elt, false);",
+ output: "array.appendElement(elt);",
+ errors: callError(
+ "appendElement's second parameter can be omitted when it's false."
+ ),
+ },
+ {
+ code: "Services.obs.notifyObservers(obj, 'topic', null);",
+ output: "Services.obs.notifyObservers(obj, 'topic');",
+ errors: callError("notifyObservers's third parameter can be omitted."),
+ },
+ {
+ code: "Services.obs.notifyObservers(obj, 'topic', '');",
+ output: "Services.obs.notifyObservers(obj, 'topic');",
+ errors: callError("notifyObservers's third parameter can be omitted."),
+ },
+ {
+ code: "window.getComputedStyle(elt, null);",
+ output: "window.getComputedStyle(elt);",
+ errors: callError("getComputedStyle's second parameter can be omitted."),
+ },
+ {
+ code: "window.getComputedStyle(elt, '');",
+ output: "window.getComputedStyle(elt);",
+ errors: callError("getComputedStyle's second parameter can be omitted."),
+ },
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/no-useless-removeEventListener.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/no-useless-removeEventListener.js
new file mode 100644
index 0000000000..9f59c78d05
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/no-useless-removeEventListener.js
@@ -0,0 +1,99 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/no-useless-removeEventListener");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function invalidCode(code) {
+ let message =
+ "use {once: true} instead of removeEventListener " +
+ "as the first instruction of the listener";
+ return { code, errors: [{ message, type: "CallExpression" }] };
+}
+
+ruleTester.run("no-useless-removeEventListener", rule, {
+ valid: [
+ // Listeners that aren't a function are always valid.
+ "elt.addEventListener('click', handler);",
+ "elt.addEventListener('click', handler, true);",
+ "elt.addEventListener('click', handler, {once: true});",
+
+ // Should not fail on empty functions.
+ "elt.addEventListener('click', function() {});",
+
+ // Should not reject when removing a listener for another event.
+ "elt.addEventListener('click', function listener() {" +
+ " elt.removeEventListener('keypress', listener);" +
+ "});",
+
+ // Should not reject when there's another instruction before
+ // removeEventListener.
+ "elt.addEventListener('click', function listener() {" +
+ " elt.focus();" +
+ " elt.removeEventListener('click', listener);" +
+ "});",
+
+ // Should not reject when wantsUntrusted is true.
+ "elt.addEventListener('click', function listener() {" +
+ " elt.removeEventListener('click', listener);" +
+ "}, false, true);",
+
+ // Should not reject when there's a literal and a variable
+ "elt.addEventListener('click', function listener() {" +
+ " elt.removeEventListener(eventName, listener);" +
+ "});",
+
+ // Should not reject when there's 2 different variables
+ "elt.addEventListener(event1, function listener() {" +
+ " elt.removeEventListener(event2, listener);" +
+ "});",
+
+ // Should not fail if this is a different type of event listener function.
+ "myfunc.addEventListener(listener);",
+ ],
+ invalid: [
+ invalidCode(
+ "elt.addEventListener('click', function listener() {" +
+ " elt.removeEventListener('click', listener);" +
+ "});"
+ ),
+ invalidCode(
+ "elt.addEventListener('click', function listener() {" +
+ " elt.removeEventListener('click', listener, true);" +
+ "}, true);"
+ ),
+ invalidCode(
+ "elt.addEventListener('click', function listener() {" +
+ " elt.removeEventListener('click', listener);" +
+ "}, {once: true});"
+ ),
+ invalidCode(
+ "elt.addEventListener('click', function listener() {" +
+ " /* Comment */" +
+ " elt.removeEventListener('click', listener);" +
+ "});"
+ ),
+ invalidCode(
+ "elt.addEventListener('click', function() {" +
+ " elt.removeEventListener('click', arguments.callee);" +
+ "});"
+ ),
+ invalidCode(
+ "elt.addEventListener(eventName, function listener() {" +
+ " elt.removeEventListener(eventName, listener);" +
+ "});"
+ ),
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/no-useless-run-test.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/no-useless-run-test.js
new file mode 100644
index 0000000000..3541467143
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/no-useless-run-test.js
@@ -0,0 +1,124 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/no-useless-run-test");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function invalidCode(code, output) {
+ let message =
+ "Useless run_test function - only contains run_next_test; whole function can be removed";
+ return { code, output, errors: [{ message, type: "FunctionDeclaration" }] };
+}
+
+ruleTester.run("no-useless-run-test", rule, {
+ valid: [
+ "function run_test() {}",
+ "function run_test() {let args = 1; run_next_test();}",
+ "function run_test() {fakeCall(); run_next_test();}",
+ ],
+ invalid: [
+ // Single-line case.
+ invalidCode("function run_test() { run_next_test(); }", ""),
+ // Multiple-line cases
+ invalidCode(
+ `
+function run_test() {
+ run_next_test();
+}`,
+ ``
+ ),
+ invalidCode(
+ `
+foo();
+function run_test() {
+ run_next_test();
+}
+`,
+ `
+foo();
+`
+ ),
+ invalidCode(
+ `
+foo();
+function run_test() {
+ run_next_test();
+}
+bar();
+`,
+ `
+foo();
+bar();
+`
+ ),
+ invalidCode(
+ `
+foo();
+
+function run_test() {
+ run_next_test();
+}
+
+bar();`,
+ `
+foo();
+
+bar();`
+ ),
+ invalidCode(
+ `
+foo();
+
+function run_test() {
+ run_next_test();
+}
+
+// A comment
+bar();
+`,
+ `
+foo();
+
+// A comment
+bar();
+`
+ ),
+ invalidCode(
+ `
+foo();
+
+/**
+ * A useful comment.
+ */
+function run_test() {
+ run_next_test();
+}
+
+// A comment
+bar();
+`,
+ `
+foo();
+
+/**
+ * A useful comment.
+ */
+
+// A comment
+bar();
+`
+ ),
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/prefer-boolean-length-check.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/prefer-boolean-length-check.js
new file mode 100644
index 0000000000..daf3c6f3d9
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/prefer-boolean-length-check.js
@@ -0,0 +1,97 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/prefer-boolean-length-check");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function invalidError() {
+ let message = "Prefer boolean length check";
+ return [{ message, type: "BinaryExpression" }];
+}
+
+ruleTester.run("check-length", rule, {
+ valid: [
+ "if (foo.length && foo.length) {}",
+ "if (!foo.length) {}",
+ "if (foo.value == 0) {}",
+ "if (foo.value > 0) {}",
+ "if (0 == foo.value) {}",
+ "if (0 < foo.value) {}",
+ "var a = !!foo.length",
+ "function bar() { return !!foo.length }",
+ ],
+ invalid: [
+ {
+ code: "if (foo.length == 0) {}",
+ output: "if (!foo.length) {}",
+ errors: invalidError(),
+ },
+ {
+ code: "if (foo.length > 0) {}",
+ output: "if (foo.length) {}",
+ errors: invalidError(),
+ },
+ {
+ code: "if (0 < foo.length) {}",
+ output: "if (foo.length) {}",
+ errors: invalidError(),
+ },
+ {
+ code: "if (0 == foo.length) {}",
+ output: "if (!foo.length) {}",
+ errors: invalidError(),
+ },
+ {
+ code: "if (foo && foo.length == 0) {}",
+ output: "if (foo && !foo.length) {}",
+ errors: invalidError(),
+ },
+ {
+ code: "if (foo.bar.length == 0) {}",
+ output: "if (!foo.bar.length) {}",
+ errors: invalidError(),
+ },
+ {
+ code: "var a = foo.length>0",
+ output: "var a = !!foo.length",
+ errors: invalidError(),
+ },
+ {
+ code: "function bar() { return foo.length>0 }",
+ output: "function bar() { return !!foo.length }",
+ errors: invalidError(),
+ },
+ {
+ code: "if (foo && bar.length>0) {}",
+ output: "if (foo && bar.length) {}",
+ errors: invalidError(),
+ },
+ {
+ code: "while (foo && bar.length>0) {}",
+ output: "while (foo && bar.length) {}",
+ errors: invalidError(),
+ },
+ {
+ code: "x = y && bar.length > 0",
+ output: "x = y && !!bar.length",
+ errors: invalidError(),
+ },
+ {
+ code: "function bar() { return x && foo.length > 0}",
+ output: "function bar() { return x && !!foo.length}",
+ errors: invalidError(),
+ },
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/prefer-formatValues.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/prefer-formatValues.js
new file mode 100644
index 0000000000..0883130f17
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/prefer-formatValues.js
@@ -0,0 +1,72 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/prefer-formatValues");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function error(line, column = undefined) {
+ return {
+ message:
+ "prefer to use a single document.l10n.formatValues call instead " +
+ "of multiple calls to document.l10n.formatValue or document.l10n.formatValues",
+ type: "CallExpression",
+ line,
+ column,
+ };
+}
+
+ruleTester.run("check-length", rule, {
+ valid: [
+ "document.l10n.formatValue('foobar');",
+ "document.l10n.formatValues(['foobar', 'foobaz']);",
+ `if (foo) {
+ document.l10n.formatValue('foobar');
+ } else {
+ document.l10n.formatValue('foobaz');
+ }`,
+ `document.l10n.formatValue('foobaz');
+ if (foo) {
+ document.l10n.formatValue('foobar');
+ }`,
+ `if (foo) {
+ document.l10n.formatValue('foobar');
+ }
+ document.l10n.formatValue('foobaz');`,
+ `if (foo) {
+ document.l10n.formatValue('foobar');
+ }
+ document.l10n.formatValues(['foobaz']);`,
+ ],
+ invalid: [
+ {
+ code: `document.l10n.formatValue('foobar');
+ document.l10n.formatValue('foobaz');`,
+ errors: [error(1, 1), error(2, 14)],
+ },
+ {
+ code: `document.l10n.formatValue('foobar');
+ if (foo) {
+ document.l10n.formatValue('foobiz');
+ }
+ document.l10n.formatValue('foobaz');`,
+ errors: [error(1, 1), error(5, 14)],
+ },
+ {
+ code: `document.l10n.formatValues('foobar');
+ document.l10n.formatValue('foobaz');`,
+ errors: [error(1, 1), error(2, 14)],
+ },
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/reject-chromeutils-import-null.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/reject-chromeutils-import-null.js
new file mode 100644
index 0000000000..6584f728ac
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/reject-chromeutils-import-null.js
@@ -0,0 +1,42 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/reject-chromeutils-import-null");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 8 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function invalidError() {
+ let message =
+ "ChromeUtils.import should not be called with (..., null) to " +
+ "retrieve the JSM global object. Rely on explicit exports instead.";
+ return [{ message, type: "CallExpression" }];
+}
+
+ruleTester.run("reject-chromeutils-import-null", rule, {
+ valid: ['ChromeUtils.import("resource://some/path/to/My.jsm")'],
+ invalid: [
+ {
+ code: 'ChromeUtils.import("resource://some/path/to/My.jsm", null)',
+ errors: invalidError(),
+ },
+ {
+ code: `
+ChromeUtils.import(
+ "resource://some/path/to/My.jsm",
+ null
+);`,
+ errors: invalidError(),
+ },
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/reject-importGlobalProperties.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/reject-importGlobalProperties.js
new file mode 100644
index 0000000000..04c0e0408b
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/reject-importGlobalProperties.js
@@ -0,0 +1,46 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/reject-importGlobalProperties");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 8 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+ruleTester.run("reject-importGlobalProperties", rule, {
+ valid: [
+ {
+ code: "Cu.something();",
+ },
+ {
+ options: ["allownonwebidl"],
+ code: "Cu.importGlobalProperties(['fetch'])",
+ },
+ ],
+ invalid: [
+ {
+ code: "Cu.importGlobalProperties(['fetch'])",
+ options: ["everything"],
+ errors: [{ messageId: "unexpectedCall" }],
+ },
+ {
+ code: "Cu.importGlobalProperties(['TextEncoder'])",
+ options: ["everything"],
+ errors: [{ messageId: "unexpectedCall" }],
+ },
+ {
+ code: "Cu.importGlobalProperties(['TextEncoder'])",
+ options: ["allownonwebidl"],
+ errors: [{ messageId: "unexpectedCallWebIdl" }],
+ },
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/reject-relative-requires.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/reject-relative-requires.js
new file mode 100644
index 0000000000..19f30559ec
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/reject-relative-requires.js
@@ -0,0 +1,58 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/reject-relative-requires");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 8 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function invalidError() {
+ let message = "relative paths are not allowed with require()";
+ return [{ message, type: "CallExpression" }];
+}
+
+ruleTester.run("reject-relative-requires", rule, {
+ valid: [
+ 'require("devtools/absolute/path")',
+ 'require("resource://gre/modules/SomeModule.jsm")',
+ 'loader.lazyRequireGetter(this, "path", "devtools/absolute/path", true)',
+ 'loader.lazyRequireGetter(this, "Path", "devtools/absolute/path")',
+ ],
+ invalid: [
+ {
+ code: 'require("./relative/path")',
+ errors: invalidError(),
+ },
+ {
+ code: 'require("../parent/folder/path")',
+ errors: invalidError(),
+ },
+ {
+ code: 'loader.lazyRequireGetter(this, "path", "./relative/path", true)',
+ errors: invalidError(),
+ },
+ {
+ code:
+ 'loader.lazyRequireGetter(this, "path", "../parent/folder/path", true)',
+ errors: invalidError(),
+ },
+ {
+ code: 'loader.lazyRequireGetter(this, "path", "./relative/path")',
+ errors: invalidError(),
+ },
+ {
+ code: 'loader.lazyRequireGetter(this, "path", "../parent/folder/path")',
+ errors: invalidError(),
+ },
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/reject-some-requires.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/reject-some-requires.js
new file mode 100644
index 0000000000..b56dd2cf96
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/reject-some-requires.js
@@ -0,0 +1,49 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/reject-some-requires");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 8 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function requirePathError(path) {
+ const message = `require(${path}) is not allowed`;
+ return [{ message, type: "CallExpression" }];
+}
+
+const DEVTOOLS_FORBIDDEN_PATH = "^(resource://)?devtools/forbidden";
+
+ruleTester.run("reject-some-requires", rule, {
+ valid: [
+ {
+ code: 'require("devtools/not-forbidden/path")',
+ options: [DEVTOOLS_FORBIDDEN_PATH],
+ },
+ {
+ code: 'require("resource://devtools/not-forbidden/path")',
+ options: [DEVTOOLS_FORBIDDEN_PATH],
+ },
+ ],
+ invalid: [
+ {
+ code: 'require("devtools/forbidden/path")',
+ errors: requirePathError("devtools/forbidden/path"),
+ options: [DEVTOOLS_FORBIDDEN_PATH],
+ },
+ {
+ code: 'require("resource://devtools/forbidden/path")',
+ errors: requirePathError("resource://devtools/forbidden/path"),
+ options: [DEVTOOLS_FORBIDDEN_PATH],
+ },
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/rejects-requires-await.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/rejects-requires-await.js
new file mode 100644
index 0000000000..ea6273a8ee
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/rejects-requires-await.js
@@ -0,0 +1,32 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/rejects-requires-await");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 8 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function invalidCode(code, messageId) {
+ return { code, errors: [{ messageId: "rejectRequiresAwait" }] };
+}
+
+ruleTester.run("reject-requires-await", rule, {
+ valid: [
+ "async() => { await Assert.rejects(foo, /assertion/) }",
+ "async() => { await Assert.rejects(foo, /assertion/, 'msg') }",
+ ],
+ invalid: [
+ invalidCode("Assert.rejects(foo)"),
+ invalidCode("Assert.rejects(foo, 'msg')"),
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/use-cc-etc.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/use-cc-etc.js
new file mode 100644
index 0000000000..7ad729d22b
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/use-cc-etc.js
@@ -0,0 +1,55 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/use-cc-etc");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function invalidCode(code, originalName, newName) {
+ return {
+ code,
+ errors: [
+ {
+ message: `Use ${newName} rather than ${originalName}`,
+ type: "MemberExpression",
+ },
+ ],
+ };
+}
+
+ruleTester.run("use-cc-etc", rule, {
+ valid: ["Components.Constructor();", "let x = Components.foo;"],
+ invalid: [
+ invalidCode(
+ "let foo = Components.classes['bar'];",
+ "Components.classes",
+ "Cc"
+ ),
+ invalidCode(
+ "let bar = Components.interfaces.bar;",
+ "Components.interfaces",
+ "Ci"
+ ),
+ invalidCode(
+ "Components.results.NS_ERROR_ILLEGAL_INPUT;",
+ "Components.results",
+ "Cr"
+ ),
+ invalidCode(
+ "Components.utils.reportError('fake');",
+ "Components.utils",
+ "Cu"
+ ),
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/use-chromeutils-generateqi.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/use-chromeutils-generateqi.js
new file mode 100644
index 0000000000..26c6b350bc
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/use-chromeutils-generateqi.js
@@ -0,0 +1,81 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/use-chromeutils-generateqi");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function callError(message) {
+ return [{ message, type: "CallExpression" }];
+}
+function error(message, type) {
+ return [{ message, type }];
+}
+
+const MSG_NO_JS_QUERY_INTERFACE =
+ "Please use ChromeUtils.generateQI rather than manually creating " +
+ "JavaScript QueryInterface functions";
+
+const MSG_NO_XPCOMUTILS_GENERATEQI =
+ "Please use ChromeUtils.generateQI instead of XPCOMUtils.generateQI";
+
+/* globals nsIFlug */
+function QueryInterface(iid) {
+ if (
+ iid.equals(Ci.nsISupports) ||
+ iid.equals(Ci.nsIMeh) ||
+ iid.equals(nsIFlug) ||
+ iid.equals(Ci.amIFoo)
+ ) {
+ return this;
+ }
+ throw Components.Exception("", Cr.NS_ERROR_NO_INTERFACE);
+}
+
+ruleTester.run("use-chromeutils-generateqi", rule, {
+ valid: [
+ `X.prototype.QueryInterface = ChromeUtils.generateQI(["nsIMeh"]);`,
+ `X.prototype = { QueryInterface: ChromeUtils.generateQI(["nsIMeh"]) }`,
+ ],
+ invalid: [
+ {
+ code: `X.prototype.QueryInterface = XPCOMUtils.generateQI(["nsIMeh"]);`,
+ output: `X.prototype.QueryInterface = ChromeUtils.generateQI(["nsIMeh"]);`,
+ errors: callError(MSG_NO_XPCOMUTILS_GENERATEQI),
+ },
+ {
+ code: `X.prototype = { QueryInterface: XPCOMUtils.generateQI(["nsIMeh"]) };`,
+ output: `X.prototype = { QueryInterface: ChromeUtils.generateQI(["nsIMeh"]) };`,
+ errors: callError(MSG_NO_XPCOMUTILS_GENERATEQI),
+ },
+ {
+ code: `X.prototype = { QueryInterface: ${QueryInterface} };`,
+ output: `X.prototype = { QueryInterface: ChromeUtils.generateQI(["nsIMeh", "nsIFlug", "amIFoo"]) };`,
+ errors: error(MSG_NO_JS_QUERY_INTERFACE, "Property"),
+ },
+ {
+ code: `X.prototype = { ${String(QueryInterface).replace(
+ /^function /,
+ ""
+ )} };`,
+ output: `X.prototype = { QueryInterface: ChromeUtils.generateQI(["nsIMeh", "nsIFlug", "amIFoo"]) };`,
+ errors: error(MSG_NO_JS_QUERY_INTERFACE, "Property"),
+ },
+ {
+ code: `X.prototype.QueryInterface = ${QueryInterface};`,
+ output: `X.prototype.QueryInterface = ChromeUtils.generateQI(["nsIMeh", "nsIFlug", "amIFoo"]);`,
+ errors: error(MSG_NO_JS_QUERY_INTERFACE, "AssignmentExpression"),
+ },
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/use-chromeutils-import.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/use-chromeutils-import.js
new file mode 100644
index 0000000000..635c436233
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/use-chromeutils-import.js
@@ -0,0 +1,80 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/use-chromeutils-import");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function callError(message) {
+ return [{ message, type: "CallExpression" }];
+}
+
+const MESSAGE_IMPORT = "Please use ChromeUtils.import instead of Cu.import";
+const MESSAGE_DEFINE =
+ "Please use ChromeUtils.defineModuleGetter instead of " +
+ "XPCOMUtils.defineLazyModuleGetter";
+
+ruleTester.run("use-chromeutils-import", rule, {
+ valid: [
+ `ChromeUtils.import("resource://gre/modules/Service.jsm");`,
+ `ChromeUtils.import("resource://gre/modules/Service.jsm", this);`,
+ `ChromeUtils.defineModuleGetter(this, "Services",
+ "resource://gre/modules/Service.jsm");`,
+ `XPCOMUtils.defineLazyModuleGetter(this, "Services",
+ "resource://gre/modules/Service.jsm",
+ "Foo");`,
+ `XPCOMUtils.defineLazyModuleGetter(this, "Services",
+ "resource://gre/modules/Service.jsm",
+ undefined, preServicesLambda);`,
+ {
+ options: [{ allowCu: true }],
+ code: `Cu.import("resource://gre/modules/Service.jsm");`,
+ },
+ ],
+ invalid: [
+ {
+ code: `Cu.import("resource://gre/modules/Services.jsm");`,
+ output: `ChromeUtils.import("resource://gre/modules/Services.jsm");`,
+ errors: callError(MESSAGE_IMPORT),
+ },
+ {
+ code: `Cu.import("resource://gre/modules/Services.jsm", this);`,
+ output: `ChromeUtils.import("resource://gre/modules/Services.jsm", this);`,
+ errors: callError(MESSAGE_IMPORT),
+ },
+ {
+ code: `Components.utils.import("resource://gre/modules/Services.jsm");`,
+ output: `ChromeUtils.import("resource://gre/modules/Services.jsm");`,
+ errors: callError(MESSAGE_IMPORT),
+ },
+ {
+ code: `Components.utils.import("resource://gre/modules/Services.jsm");`,
+ output: `ChromeUtils.import("resource://gre/modules/Services.jsm");`,
+ errors: callError(MESSAGE_IMPORT),
+ },
+ {
+ options: [{ allowCu: true }],
+ code: `Components.utils.import("resource://gre/modules/Services.jsm", this);`,
+ output: `ChromeUtils.import("resource://gre/modules/Services.jsm", this);`,
+ errors: callError(MESSAGE_IMPORT),
+ },
+ {
+ code: `XPCOMUtils.defineLazyModuleGetter(this, "Services",
+ "resource://gre/modules/Services.jsm");`,
+ output: `ChromeUtils.defineModuleGetter(this, "Services",
+ "resource://gre/modules/Services.jsm");`,
+ errors: callError(MESSAGE_DEFINE),
+ },
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/use-default-preference-values.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/use-default-preference-values.js
new file mode 100644
index 0000000000..f4ad001a08
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/use-default-preference-values.js
@@ -0,0 +1,41 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/use-default-preference-values");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function invalidCode(code) {
+ let message = "provide a default value instead of using a try/catch block";
+ return { code, errors: [{ message, type: "TryStatement" }] };
+}
+
+let types = ["Bool", "Char", "Float", "Int"];
+let methods = types.map(type => "get" + type + "Pref");
+
+ruleTester.run("use-default-preference-values", rule, {
+ valid: [].concat(
+ methods.map(m => "blah = branch." + m + "('blah', true);"),
+ methods.map(m => "blah = branch." + m + "('blah');"),
+ methods.map(
+ m => "try { canThrow(); blah = branch." + m + "('blah'); } catch(e) {}"
+ )
+ ),
+
+ invalid: [].concat(
+ methods.map(m =>
+ invalidCode("try { blah = branch." + m + "('blah'); } catch(e) {}")
+ )
+ ),
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/use-includes-instead-of-indexOf.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/use-includes-instead-of-indexOf.js
new file mode 100644
index 0000000000..cb1810b305
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/use-includes-instead-of-indexOf.js
@@ -0,0 +1,38 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/use-includes-instead-of-indexOf");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function invalidCode(code) {
+ let message = "use .includes instead of .indexOf";
+ return { code, errors: [{ message, type: "BinaryExpression" }] };
+}
+
+ruleTester.run("use-includes-instead-of-indexOf", rule, {
+ valid: [
+ "let a = foo.includes(bar);",
+ "let a = foo.indexOf(bar) > 0;",
+ "let a = foo.indexOf(bar) != 0;",
+ ],
+ invalid: [
+ invalidCode("let a = foo.indexOf(bar) >= 0;"),
+ invalidCode("let a = foo.indexOf(bar) != -1;"),
+ invalidCode("let a = foo.indexOf(bar) !== -1;"),
+ invalidCode("let a = foo.indexOf(bar) == -1;"),
+ invalidCode("let a = foo.indexOf(bar) === -1;"),
+ invalidCode("let a = foo.indexOf(bar) < 0;"),
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/use-ownerGlobal.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/use-ownerGlobal.js
new file mode 100644
index 0000000000..b08bdf1632
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/use-ownerGlobal.js
@@ -0,0 +1,35 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/use-ownerGlobal");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function invalidCode(code) {
+ let message = "use .ownerGlobal instead of .ownerDocument.defaultView";
+ return { code, errors: [{ message, type: "MemberExpression" }] };
+}
+
+ruleTester.run("use-ownerGlobal", rule, {
+ valid: [
+ "aEvent.target.ownerGlobal;",
+ "this.DOMPointNode.ownerGlobal.getSelection();",
+ "windowToMessageManager(node.ownerGlobal);",
+ ],
+ invalid: [
+ invalidCode("aEvent.target.ownerDocument.defaultView;"),
+ invalidCode("this.DOMPointNode.ownerDocument.defaultView.getSelection();"),
+ invalidCode("windowToMessageManager(node.ownerDocument.defaultView);"),
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/use-returnValue.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/use-returnValue.js
new file mode 100644
index 0000000000..81952452e4
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/use-returnValue.js
@@ -0,0 +1,39 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/use-returnValue");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function invalidCode(code, methodName) {
+ let message = `{Array/String}.${methodName} doesn't modify the instance in-place`;
+ return { code, errors: [{ message, type: "ExpressionStatement" }] };
+}
+
+ruleTester.run("use-returnValue", rule, {
+ valid: [
+ "a = foo.concat(bar)",
+ "b = bar.concat([1,3,4])",
+ "c = baz.concat()",
+ "d = qux.join(' ')",
+ "e = quux.slice(1)",
+ ],
+ invalid: [
+ invalidCode("foo.concat(bar)", "concat"),
+ invalidCode("bar.concat([1,3,4])", "concat"),
+ invalidCode("baz.concat()", "concat"),
+ invalidCode("qux.join(' ')", "join"),
+ invalidCode("quux.slice(1)", "slice"),
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/tests/use-services.js b/tools/lint/eslint/eslint-plugin-mozilla/tests/use-services.js
new file mode 100644
index 0000000000..b8d5338fc4
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/tests/use-services.js
@@ -0,0 +1,40 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// ------------------------------------------------------------------------------
+// Requirements
+// ------------------------------------------------------------------------------
+
+var rule = require("../lib/rules/use-services");
+var RuleTester = require("eslint").RuleTester;
+
+const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
+
+// ------------------------------------------------------------------------------
+// Tests
+// ------------------------------------------------------------------------------
+
+function invalidCode(code, name) {
+ let message = `Use Services.${name} rather than getService().`;
+ return { code, errors: [{ message, type: "CallExpression" }] };
+}
+
+ruleTester.run("use-services", rule, {
+ valid: [
+ 'Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator)',
+ 'Components.classes["@mozilla.org/uuid-generator;1"].getService(Components.interfaces.nsIUUIDGenerator)',
+ "Services.wm.addListener()",
+ ],
+ invalid: [
+ invalidCode(
+ 'Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);',
+ "wm"
+ ),
+ invalidCode(
+ 'Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(Components.interfaces.nsIAppStartup);',
+ "startup"
+ ),
+ ],
+});
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/update.sh b/tools/lint/eslint/eslint-plugin-mozilla/update.sh
new file mode 100755
index 0000000000..d8ee4098ec
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/update.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+# Script to regenerate the npm packages used for eslint-plugin-mozilla by the builders.
+# Requires
+
+# Force the scripts working directory to be projdir/tools/lint/eslint/eslint-plugin-mozilla.
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+cd $DIR
+
+echo "To complete this script you will need the following tokens from https://mozilla-releng.net/tokens"
+echo " - tooltool.upload.public"
+echo " - tooltool.download.public"
+echo ""
+read -p "Are these tokens visible at the above URL (y/n)?" choice
+case "$choice" in
+ y|Y )
+ echo ""
+ echo "1. Go to https://mozilla-releng.net"
+ echo "2. Log in using your Mozilla LDAP account."
+ echo "3. Click on \"Tokens.\""
+ echo "4. Issue a user token with the permissions tooltool.upload.public and tooltool.download.public."
+ echo ""
+ echo "When you click issue you will be presented with a long string. Paste the string into a temporary file called ~/.tooltool-token."
+ echo ""
+ read -rsp $'Press any key to continue...\n' -n 1
+ ;;
+ n|N )
+ echo ""
+ echo "You will need to contact somebody that has these permissions... people most likely to have these permissions are members of the releng, ateam, a sheriff, mratcliffe, or jryans"
+ exit 1
+ ;;
+ * )
+ echo ""
+ echo "Invalid input."
+ continue
+ ;;
+esac
+
+echo ""
+echo "Removing node_modules and package-lock.json..."
+# Move to the top-level directory.
+rm -rf node_modules
+rm package-lock.json
+
+echo "Installing modules for eslint-plugin-mozilla..."
+npm install
+
+echo "Creating eslint-plugin-mozilla.tar.gz..."
+tar cvz -f eslint-plugin-mozilla.tar.gz node_modules
+
+echo "Adding eslint-plugin-mozilla.tar.gz to tooltool..."
+rm -f manifest.tt
+../../../../python/mozbuild/mozbuild/action/tooltool.py add --visibility public --unpack eslint-plugin-mozilla.tar.gz --url="https://tooltool.mozilla-releng.net/"
+
+echo "Uploading eslint-plugin-mozilla.tar.gz to tooltool..."
+../../../../python/mozbuild/mozbuild/action/tooltool.py upload --authentication-file=~/.tooltool-token --message "node_modules folder update for tools/lint/eslint/eslint-plugin-mozilla" --url="https://tooltool.mozilla-releng.net/"
+
+echo "Cleaning up..."
+rm eslint-plugin-mozilla.tar.gz
+
+echo ""
+echo "Update complete, please commit and check in your changes."
diff --git a/tools/lint/eslint/eslint-plugin-spidermonkey-js/LICENSE b/tools/lint/eslint/eslint-plugin-spidermonkey-js/LICENSE
new file mode 100644
index 0000000000..e87a115e46
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-spidermonkey-js/LICENSE
@@ -0,0 +1,363 @@
+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-spidermonkey-js/lib/index.js b/tools/lint/eslint/eslint-plugin-spidermonkey-js/lib/index.js
new file mode 100644
index 0000000000..4fb6e340ed
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-spidermonkey-js/lib/index.js
@@ -0,0 +1,17 @@
+/**
+ * @fileoverview A processor to help parse the spidermonkey js code.
+ * 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";
+
+// ------------------------------------------------------------------------------
+// Plugin Definition
+// ------------------------------------------------------------------------------
+module.exports = {
+ processors: {
+ processor: require("../lib/processors/self-hosted"),
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-spidermonkey-js/lib/processors/self-hosted.js b/tools/lint/eslint/eslint-plugin-spidermonkey-js/lib/processors/self-hosted.js
new file mode 100644
index 0000000000..c7dbf697fa
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-spidermonkey-js/lib/processors/self-hosted.js
@@ -0,0 +1,49 @@
+/**
+ * @fileoverview Remove macros from SpiderMonkey's self-hosted JS.
+ *
+ * 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");
+
+const selfHostedRegex = /js\/src\/(?:builtin|shell)\/.*?\.js$/;
+const macroRegex = /\s*\#(if|ifdef|else|elif|endif|include|define|undef).*/;
+
+module.exports = {
+ preprocess(text, filename) {
+ if (path.win32) {
+ filename = filename.split(path.sep).join("/");
+ }
+ if (!selfHostedRegex.test(filename)) {
+ return [text];
+ }
+
+ let lines = text.split(/\n/);
+ for (let i = 0; i < lines.length; i++) {
+ if (!macroRegex.test(lines[i])) {
+ // No macro here, nothing to do.
+ continue;
+ }
+
+ for (; i < lines.length; i++) {
+ lines[i] = "// " + lines[i];
+
+ // If the line ends with a backslash (\), the next line
+ // is also part of part of the macro.
+ if (!lines[i].endsWith("\\")) {
+ break;
+ }
+ }
+ }
+
+ return [lines.join("\n")];
+ },
+
+ postprocess(messages, filename) {
+ return Array.prototype.concat.apply([], messages);
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-spidermonkey-js/package.json b/tools/lint/eslint/eslint-plugin-spidermonkey-js/package.json
new file mode 100644
index 0000000000..61452d9e96
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-spidermonkey-js/package.json
@@ -0,0 +1,30 @@
+{
+ "name": "eslint-plugin-spidermonkey-js",
+ "version": "0.1.1",
+ "description": "A collection of rules that help enforce JavaScript coding standard in the Mozilla SpiderMonkey project.",
+ "keywords": [
+ "eslint",
+ "eslintplugin",
+ "eslint-plugin",
+ "mozilla",
+ "spidermonkey"
+ ],
+ "bugs": {
+ "url": "https://bugzilla.mozilla.org/enter_bug.cgi?product=Testing&component=Lint"
+ },
+ "homepage": "http://firefox-source-docs.mozilla.org/tools/lint/linters/eslint-plugin-spidermonkey-js.html",
+ "repository": {
+ "type": "hg",
+ "url": "https://hg.mozilla.org/mozilla-central/"
+ },
+ "author": "Mozilla",
+ "main": "lib/index.js",
+ "dependencies": {
+ },
+ "devDependencies": {
+ },
+ "engines": {
+ "node": ">=6.9.1"
+ },
+ "license": "MPL-2.0"
+}
diff --git a/tools/lint/eslint/manifest.tt b/tools/lint/eslint/manifest.tt
new file mode 100644
index 0000000000..e984e43d49
--- /dev/null
+++ b/tools/lint/eslint/manifest.tt
@@ -0,0 +1,10 @@
+[
+ {
+ "algorithm": "sha512",
+ "visibility": "public",
+ "filename": "eslint.tar.gz",
+ "unpack": true,
+ "digest": "ade0ac783a4efd0cff65fac77e8bbdc18189d6a0ba2f7258882d76e2d1a0d20e14bc56eab928353ab9abf15ae42a18eb3cf286787bd824500058d1194b6ca674",
+ "size": 8863963
+ }
+] \ No newline at end of file
diff --git a/tools/lint/eslint/modules.json b/tools/lint/eslint/modules.json
new file mode 100644
index 0000000000..849783fc4d
--- /dev/null
+++ b/tools/lint/eslint/modules.json
@@ -0,0 +1,239 @@
+{
+
+ "Actions.jsm": ["actionTypes", "actionCreators", "actionUtils", "ASRouterActions", "globalImportContext", "UI_CODE", "BACKGROUND_PROCESS", "MAIN_MESSAGE_TYPE", "CONTENT_MESSAGE_TYPE", "PRELOAD_MESSAGE_TYPE"],
+ "ActivityStreamPrefs.jsm": ["DefaultPrefs", "Prefs"],
+ "ActivityStreamStorage.jsm": ["ActivityStreamStorage", "getDefaultOptions"],
+ "addon.js": ["Addon"],
+ "AddonManager.jsm": ["AddonManager", "AddonManagerPrivate"],
+ "addons.js": ["AddonsEngine", "AddonValidator"],
+ "addons.jsm": ["Addon", "STATE_ENABLED", "STATE_DISABLED"],
+ "addonsreconciler.js": ["AddonsReconciler", "CHANGE_INSTALLED", "CHANGE_UNINSTALLED", "CHANGE_ENABLED", "CHANGE_DISABLED"],
+ "AddonTestUtils.jsm": ["AddonTestUtils", "MockAsyncShutdown"],
+ "addonutils.js": ["AddonUtils"],
+ "ajv-4.1.1.js": ["Ajv"],
+ "AlertsHelper.jsm": [],
+ "AppData.jsm": ["makeFakeAppDir"],
+ "AppInfo.jsm": ["newAppInfo", "getAppInfo", "updateAppInfo"],
+ "ASRouterTargeting.jsm": ["ASRouterTargeting", "QueryCache", "CachedTargetingGetter"],
+ "async.js": ["Async"],
+ "AsyncSpellCheckTestHelper.jsm": ["onSpellCheck"],
+ "base-loader.js": ["Loader", "resolveURI", "Module", "Require", "unload"],
+ "bogus_element_type.jsm": [],
+ "bookmarks.js": ["BookmarksEngine", "PlacesItem", "Bookmark", "BookmarkFolder", "BookmarkQuery", "Livemark", "BookmarkSeparator", "BufferedBookmarksEngine"],
+ "bookmarks.jsm": ["PlacesItem", "Bookmark", "Separator", "Livemark", "BookmarkFolder", "DumpBookmarks"],
+ "bookmark_repair.js": ["BookmarkRepairRequestor", "BookmarkRepairResponder"],
+ "bookmark_validator.js": ["BookmarkValidator", "BookmarkProblemData"],
+ "browser-loader.js": ["BrowserLoader"],
+ "browser.js": ["browser", "Context", "WindowState"],
+ "browserid_identity.js": ["BrowserIDManager", "AuthenticationError"],
+ "capabilities.js": ["Capabilities", "PageLoadStrategy", "Proxy", "Timeouts", "UnhandledPromptBehavior"],
+ "cert.js": ["allowAllCerts"],
+ "clients.js": ["ClientEngine", "ClientsRec"],
+ "collection_repair.js": ["getRepairRequestor", "getAllRepairRequestors", "CollectionRepairRequestor", "getRepairResponder", "CollectionRepairResponder"],
+ "collection_validator.js": ["CollectionValidator", "CollectionProblemData"],
+ "Console.jsm": ["console", "ConsoleAPI"],
+ "constants.js": ["WEAVE_VERSION", "SYNC_API_VERSION", "STORAGE_VERSION", "PREFS_BRANCH", "DEFAULT_KEYBUNDLE_NAME", "SYNC_KEY_ENCODED_LENGTH", "SYNC_KEY_DECODED_LENGTH", "NO_SYNC_NODE_INTERVAL", "MAX_ERROR_COUNT_BEFORE_BACKOFF", "MINIMUM_BACKOFF_INTERVAL", "MAXIMUM_BACKOFF_INTERVAL", "HMAC_EVENT_INTERVAL", "MASTER_PASSWORD_LOCKED_RETRY_INTERVAL", "DEFAULT_GUID_FETCH_BATCH_SIZE", "DEFAULT_DOWNLOAD_BATCH_SIZE", "SINGLE_USER_THRESHOLD", "MULTI_DEVICE_THRESHOLD", "SCORE_INCREMENT_SMALL", "SCORE_INCREMENT_MEDIUM", "SCORE_INCREMENT_XLARGE", "SCORE_UPDATE_DELAY", "IDLE_OBSERVER_BACK_DELAY", "URI_LENGTH_MAX", "MAX_HISTORY_UPLOAD", "MAX_HISTORY_DOWNLOAD", "STATUS_OK", "SYNC_FAILED", "LOGIN_FAILED", "SYNC_FAILED_PARTIAL", "CLIENT_NOT_CONFIGURED", "STATUS_DISABLED", "MASTER_PASSWORD_LOCKED", "LOGIN_SUCCEEDED", "SYNC_SUCCEEDED", "ENGINE_SUCCEEDED", "LOGIN_FAILED_NO_USERNAME", "LOGIN_FAILED_NO_PASSPHRASE", "LOGIN_FAILED_NETWORK_ERROR", "LOGIN_FAILED_SERVER_ERROR", "LOGIN_FAILED_INVALID_PASSPHRASE", "LOGIN_FAILED_LOGIN_REJECTED", "METARECORD_DOWNLOAD_FAIL", "VERSION_OUT_OF_DATE", "CREDENTIALS_CHANGED", "ABORT_SYNC_COMMAND", "NO_SYNC_NODE_FOUND", "OVER_QUOTA", "SERVER_MAINTENANCE", "RESPONSE_OVER_QUOTA", "ENGINE_UPLOAD_FAIL", "ENGINE_DOWNLOAD_FAIL", "ENGINE_UNKNOWN_FAIL", "ENGINE_APPLY_FAIL", "ENGINE_BATCH_INTERRUPTED", "kSyncMasterPasswordLocked", "kSyncWeaveDisabled", "kSyncNetworkOffline", "kSyncBackoffNotMet", "kFirstSyncChoiceNotMade", "kSyncNotConfigured", "kFirefoxShuttingDown", "DEVICE_TYPE_DESKTOP", "DEVICE_TYPE_MOBILE", "SQLITE_MAX_VARIABLE_NUMBER"],
+ "Constants.jsm": ["Roles", "Events", "Relations", "Filters", "States", "Prefilters"],
+ "ContactDB.jsm": ["ContactDB", "DB_NAME", "STORE_NAME", "SAVED_GETALL_STORE_NAME", "REVISION_STORE", "DB_VERSION"],
+ "content-process.jsm": ["init"],
+ "content.jsm": ["registerContentFrame"],
+ "ContentCrashHandlers.jsm": ["TabCrashHandler", "SubframeCrashHandler", "UnsubmittedCrashHandler"],
+ "ContentPrefUtils.jsm": ["ContentPref", "cbHandleResult", "cbHandleError", "cbHandleCompletion", "safeCallback", "_methodsCallableFromChild"],
+ "cookies.js": ["Cookies"],
+ "CoverageUtils.jsm": ["CoverageCollector"],
+ "CrashManagerTest.jsm": ["configureLogging", "getManager", "sleep", "TestingCrashManager"],
+ "declined.js": ["DeclinedEngines"],
+ "distribution.js": ["DistributionCustomizer"],
+ "DNSTypes.jsm": ["DNS_QUERY_RESPONSE_CODES", "DNS_AUTHORITATIVE_ANSWER_CODES", "DNS_CLASS_CODES", "DNS_RECORD_TYPES"],
+ "doctor.js": ["Doctor"],
+ "dom.js": ["ContentEventObserverService", "WebElementEventTarget"],
+ "DOMRequestHelper.jsm": ["DOMRequestIpcHelper"],
+ "DownloadCore.jsm": ["Download", "DownloadSource", "DownloadTarget", "DownloadError", "DownloadSaver", "DownloadCopySaver", "DownloadLegacySaver"],
+ "DownloadList.jsm": ["DownloadList", "DownloadCombinedList", "DownloadSummary"],
+ "driver.js": ["GeckoDriver"],
+ "element.js": ["ChromeWebElement", "ContentWebElement", "ContentWebFrame", "ContentWebWindow", "element", "WebElement"],
+ "engines.js": ["EngineManager", "SyncEngine", "Tracker", "Store", "Changeset"],
+ "enginesync.js": ["EngineSynchronizer"],
+ "error.js": ["ElementClickInterceptedError", "ElementNotAccessibleError", "ElementNotInteractableError", "InsecureCertificateError", "InvalidArgumentError", "InvalidCookieDomainError", "InvalidElementStateError", "InvalidSelectorError", "InvalidSessionIDError", "JavaScriptError", "MoveTargetOutOfBoundsError", "NoSuchAlertError", "NoSuchElementError", "NoSuchFrameError", "NoSuchWindowError", "ScriptTimeoutError", "SessionNotCreatedError", "StaleElementReferenceError", "TimeoutError", "UnableToSetCookieError", "UnexpectedAlertOpenError", "UnknownCommandError", "UnknownError", "UnsupportedOperationError", "WebDriverError", "error", "stack"],
+ "evaluate.js": ["evaluate", "sandbox", "Sandboxes"],
+ "event-emitter.js": ["EventEmitter"],
+ "extension-storage.js": ["ExtensionStorageEngine", "EncryptionRemoteTransformer", "KeyRingEncryptionRemoteTransformer"],
+ "Extension.jsm": ["Extension", "ExtensionData"],
+ "ExtensionAPI.jsm": ["ExtensionAPI", "ExtensionAPIs"],
+ "ExtensionXPCShellUtils.jsm": ["ExtensionTestUtils"],
+ "fakeservices.js": ["FakeCryptoService", "FakeFilesystemService", "FakeGUIDService", "fakeSHA256HMAC"],
+ "file_expandosharing.jsm": ["checkFromJSM"],
+ "file_stringencoding.jsm": ["checkFromJSM"],
+ "file_url.jsm": ["checkFromJSM"],
+ "file_worker_url.jsm": ["checkFromJSM"],
+ "Finder.jsm": ["Finder", "GetClipboardSearchString", "SetClipboardSearchString"],
+ "format.js": ["pprint", "truncate"],
+ "formautofill.jsm": ["Address", "CreditCard", "DumpAddresses", "DumpCreditCards"],
+ "FormAutofillHeuristics.jsm": ["FormAutofillHeuristics", "LabelUtils"],
+ "FormAutofillStorage.jsm": ["formAutofillStorage"],
+ "FormAutofillSync.jsm": ["AddressesEngine", "CreditCardsEngine"],
+ "FormAutofillUtils.jsm": ["FormAutofillUtils", "AddressDataLoader"],
+ "forms.js": ["FormEngine", "FormRec", "FormValidator"],
+ "forms.jsm": ["FormData"],
+ "FrameScriptManager.jsm": ["getNewLoaderID"],
+ "fxaccounts.jsm": ["Authentication"],
+ "FxAccounts.jsm": ["fxAccounts", "FxAccounts"],
+ "FxAccountsCommands.js": ["SendTab", "FxAccountsCommands"],
+ "FxAccountsCommon.js": ["log", "logPII", "FXACCOUNTS_PERMISSION", "DATA_FORMAT_VERSION", "DEFAULT_STORAGE_FILENAME", "ASSERTION_LIFETIME", "ASSERTION_USE_PERIOD", "CERT_LIFETIME", "KEY_LIFETIME", "POLL_SESSION", "ONLOGIN_NOTIFICATION", "ONVERIFIED_NOTIFICATION", "ONLOGOUT_NOTIFICATION", "ON_COMMAND_RECEIVED_NOTIFICATION", "ON_DEVICE_CONNECTED_NOTIFICATION", "ON_DEVICE_DISCONNECTED_NOTIFICATION", "ON_PROFILE_UPDATED_NOTIFICATION", "ON_PASSWORD_CHANGED_NOTIFICATION", "ON_PASSWORD_RESET_NOTIFICATION", "ON_VERIFY_LOGIN_NOTIFICATION", "ON_ACCOUNT_DESTROYED_NOTIFICATION", "ON_COLLECTION_CHANGED_NOTIFICATION", "FXA_PUSH_SCOPE_ACCOUNT_UPDATE", "ON_PROFILE_CHANGE_NOTIFICATION", "ON_ACCOUNT_STATE_CHANGE_NOTIFICATION", "ON_NEW_DEVICE_ID", "COMMAND_SENDTAB", "SCOPE_PROFILE", "SCOPE_OLD_SYNC", "UI_REQUEST_SIGN_IN_FLOW", "UI_REQUEST_REFRESH_AUTH", "FX_OAUTH_CLIENT_ID", "WEBCHANNEL_ID", "COMMAND_PAIR_HEARTBEAT", "COMMAND_PAIR_SUPP_METADATA", "COMMAND_PAIR_AUTHORIZE", "COMMAND_PAIR_DECLINE", "COMMAND_PAIR_COMPLETE", "COMMAND_PAIR_PREFERENCES", "COMMAND_PROFILE_CHANGE", "COMMAND_CAN_LINK_ACCOUNT", "COMMAND_LOGIN", "COMMAND_LOGOUT", "COMMAND_DELETE", "COMMAND_SYNC_PREFERENCES", "COMMAND_CHANGE_PASSWORD", "COMMAND_FXA_STATUS", "PREF_LAST_FXA_USER", "PREF_REMOTE_PAIRING_URI", "ERRNO_ACCOUNT_ALREADY_EXISTS", "ERRNO_ACCOUNT_DOES_NOT_EXIST", "ERRNO_INCORRECT_PASSWORD", "ERRNO_UNVERIFIED_ACCOUNT", "ERRNO_INVALID_VERIFICATION_CODE", "ERRNO_NOT_VALID_JSON_BODY", "ERRNO_INVALID_BODY_PARAMETERS", "ERRNO_MISSING_BODY_PARAMETERS", "ERRNO_INVALID_REQUEST_SIGNATURE", "ERRNO_INVALID_AUTH_TOKEN", "ERRNO_INVALID_AUTH_TIMESTAMP", "ERRNO_MISSING_CONTENT_LENGTH", "ERRNO_REQUEST_BODY_TOO_LARGE", "ERRNO_TOO_MANY_CLIENT_REQUESTS", "ERRNO_INVALID_AUTH_NONCE", "ERRNO_ENDPOINT_NO_LONGER_SUPPORTED", "ERRNO_INCORRECT_LOGIN_METHOD", "ERRNO_INCORRECT_KEY_RETRIEVAL_METHOD", "ERRNO_INCORRECT_API_VERSION", "ERRNO_INCORRECT_EMAIL_CASE", "ERRNO_ACCOUNT_LOCKED", "ERRNO_ACCOUNT_UNLOCKED", "ERRNO_UNKNOWN_DEVICE", "ERRNO_DEVICE_SESSION_CONFLICT", "ERRNO_SERVICE_TEMP_UNAVAILABLE", "ERRNO_PARSE", "ERRNO_NETWORK", "ERRNO_UNKNOWN_ERROR", "OAUTH_SERVER_ERRNO_OFFSET", "ERRNO_UNKNOWN_CLIENT_ID", "ERRNO_INCORRECT_CLIENT_SECRET", "ERRNO_INCORRECT_REDIRECT_URI", "ERRNO_INVALID_FXA_ASSERTION", "ERRNO_UNKNOWN_CODE", "ERRNO_INCORRECT_CODE", "ERRNO_EXPIRED_CODE", "ERRNO_OAUTH_INVALID_TOKEN", "ERRNO_INVALID_REQUEST_PARAM", "ERRNO_INVALID_RESPONSE_TYPE", "ERRNO_UNAUTHORIZED", "ERRNO_FORBIDDEN", "ERRNO_INVALID_CONTENT_TYPE", "ERROR_ACCOUNT_ALREADY_EXISTS", "ERROR_ACCOUNT_DOES_NOT_EXIST", "ERROR_ACCOUNT_LOCKED", "ERROR_ACCOUNT_UNLOCKED", "ERROR_ALREADY_SIGNED_IN_USER", "ERROR_DEVICE_SESSION_CONFLICT", "ERROR_ENDPOINT_NO_LONGER_SUPPORTED", "ERROR_INCORRECT_API_VERSION", "ERROR_INCORRECT_EMAIL_CASE", "ERROR_INCORRECT_KEY_RETRIEVAL_METHOD", "ERROR_INCORRECT_LOGIN_METHOD", "ERROR_INVALID_EMAIL", "ERROR_INVALID_AUDIENCE", "ERROR_INVALID_AUTH_TOKEN", "ERROR_INVALID_AUTH_TIMESTAMP", "ERROR_INVALID_AUTH_NONCE", "ERROR_INVALID_BODY_PARAMETERS", "ERROR_INVALID_PASSWORD", "ERROR_INVALID_VERIFICATION_CODE", "ERROR_INVALID_REFRESH_AUTH_VALUE", "ERROR_INVALID_REQUEST_SIGNATURE", "ERROR_INTERNAL_INVALID_USER", "ERROR_MISSING_BODY_PARAMETERS", "ERROR_MISSING_CONTENT_LENGTH", "ERROR_NO_TOKEN_SESSION", "ERROR_NO_SILENT_REFRESH_AUTH", "ERROR_NOT_VALID_JSON_BODY", "ERROR_OFFLINE", "ERROR_PERMISSION_DENIED", "ERROR_REQUEST_BODY_TOO_LARGE", "ERROR_SERVER_ERROR", "ERROR_SYNC_DISABLED", "ERROR_TOO_MANY_CLIENT_REQUESTS", "ERROR_SERVICE_TEMP_UNAVAILABLE", "ERROR_UI_ERROR", "ERROR_UI_REQUEST", "ERROR_PARSE", "ERROR_NETWORK", "ERROR_UNKNOWN", "ERROR_UNKNOWN_DEVICE", "ERROR_UNVERIFIED_ACCOUNT", "ERROR_UNKNOWN_CLIENT_ID", "ERROR_INCORRECT_CLIENT_SECRET", "ERROR_INCORRECT_REDIRECT_URI", "ERROR_INVALID_FXA_ASSERTION", "ERROR_UNKNOWN_CODE", "ERROR_INCORRECT_CODE", "ERROR_EXPIRED_CODE", "ERROR_OAUTH_INVALID_TOKEN", "ERROR_INVALID_REQUEST_PARAM", "ERROR_INVALID_RESPONSE_TYPE", "ERROR_UNAUTHORIZED", "ERROR_FORBIDDEN", "ERROR_INVALID_CONTENT_TYPE", "ERROR_NO_ACCOUNT", "ERROR_AUTH_ERROR", "ERROR_INVALID_PARAMETER", "ERROR_CODE_METHOD_NOT_ALLOWED", "ERROR_MSG_METHOD_NOT_ALLOWED", "DERIVED_KEYS_NAMES", "FXA_PWDMGR_PLAINTEXT_FIELDS", "FXA_PWDMGR_SECURE_FIELDS", "FXA_PWDMGR_MEMORY_FIELDS", "FXA_PWDMGR_REAUTH_WHITELIST", "FXA_PWDMGR_HOST", "FXA_PWDMGR_REALM", "SERVER_ERRNO_TO_ERROR", "ERROR_TO_GENERAL_ERROR_CLASS"],
+ "FxAccountsOAuthGrantClient.jsm": ["FxAccountsOAuthGrantClient", "FxAccountsOAuthGrantClientError"],
+ "FxAccountsProfileClient.jsm": ["FxAccountsProfileClient", "FxAccountsProfileClientError"],
+ "FxAccountsPush.js": ["FxAccountsPushService"],
+ "FxAccountsStorage.jsm": ["FxAccountsStorageManagerCanStoreField", "FxAccountsStorageManager"],
+ "FxAccountsWebChannel.jsm": ["EnsureFxAccountsWebChannel"],
+ "fxa_utils.js": ["initializeIdentityWithTokenServerResponse"],
+ "Geometry.jsm": ["Point", "Rect"],
+ "Gestures.jsm": ["GestureSettings", "GestureTracker"],
+ "GMPInstallManager.jsm": ["GMPInstallManager", "GMPExtractor", "GMPDownloader", "GMPAddon"],
+ "GMPProvider.jsm": [],
+ "GMPUtils.jsm": ["GMP_PLUGIN_IDS", "GMPPrefs", "GMPUtils", "OPEN_H264_ID", "WIDEVINE_ID"],
+ "hawkclient.js": ["HawkClient"],
+ "hawkrequest.js": ["HAWKAuthenticatedRESTRequest", "deriveHawkCredentials"],
+ "helper.js": ["workerHelper"],
+ "HelperApps.jsm": ["App", "HelperApps"],
+ "history.js": ["HistoryEngine", "HistoryRec"],
+ "history.jsm": ["HistoryEntry", "DumpHistory"],
+ "Http.jsm": ["httpRequest", "percentEncode"],
+ "httpd.js": ["HTTP_400", "HTTP_401", "HTTP_402", "HTTP_403", "HTTP_404", "HTTP_405", "HTTP_406", "HTTP_407", "HTTP_408", "HTTP_409", "HTTP_410", "HTTP_411", "HTTP_412", "HTTP_413", "HTTP_414", "HTTP_415", "HTTP_417", "HTTP_500", "HTTP_501", "HTTP_502", "HTTP_503", "HTTP_504", "HTTP_505", "HttpError", "HttpServer"],
+ "import_module.jsm": ["MODULE_IMPORTED", "MODULE_URI", "SUBMODULE_IMPORTED", "same_scope", "SUBMODULE_IMPORTED_TO_SCOPE"],
+ "import_sub_module.jsm": ["SUBMODULE_IMPORTED", "test_obj"],
+ "InlineSpellChecker.jsm": ["InlineSpellChecker", "SpellCheckHelper"],
+ "jsdebugger.jsm": ["addDebuggerToGlobal", "addSandboxedDebuggerToGlobal"],
+ "jsesc.js": ["jsesc"],
+ "json2.js": ["JSON"],
+ "keys.js": ["BulkKeyBundle", "SyncKeyBundle"],
+ "kinto-http-client.js": ["KintoHttpClient"],
+ "kinto-offline-client.js": ["Kinto"],
+ "kinto-storage-adapter.js": ["FirefoxAdapter"],
+ "kvstore.jsm": ["KeyValueService"],
+ "L10nRegistry.jsm": ["L10nRegistry", "FileSource", "IndexedFileSource"],
+ "Launcher.jsm": ["BrowserToolboxLauncher"],
+ "loader-plugin-raw.jsm": ["requireRawId"],
+ "loader.js": ["WorkerDebuggerLoader", "worker"],
+ "Loader.jsm": ["DevToolsLoader", "require", "loader"],
+ "log.js": ["Log"],
+ "logger.jsm": ["Logger"],
+ "logging.js": ["getTestLogger", "initTestLogging"],
+ "LoginRecipes.jsm": ["LoginRecipesContent", "LoginRecipesParent"],
+ "logmanager.js": ["LogManager"],
+ "lz4.js": ["Lz4"],
+ "lz4_internal.js": ["Primitives"],
+ "main.js": ["Weave"],
+ "Manifest.jsm": ["Manifests"],
+ "MatchURLFilters.jsm": ["MatchURLFilters"],
+ "mcc_iso3166_table.jsm": ["MCC_ISO3166_TABLE"],
+ "message.js": ["Command", "Message", "MessageOrigin", "Response"],
+ "MessagePort.jsm": ["MessagePort", "MessageListener"],
+ "Messaging.jsm": ["sendMessageToJava", "Messaging", "EventDispatcher"],
+ "MigrationUtils.jsm": ["MigrationUtils", "MigratorPrototype"],
+ "MulticastDNSAndroid.jsm": ["MulticastDNS"],
+ "NativeMessaging.jsm": ["NativeApp"],
+ "NotificationDB.jsm": [],
+ "nsFormAutoCompleteResult.jsm": ["FormAutoCompleteResult"],
+ "observers.js": ["Observers"],
+ "offlineAppCache.jsm": ["OfflineAppCacheHelper"],
+ "OrientationChangeHandler.jsm": [],
+ "osfile.jsm": ["OS", "require"],
+ "osfile_async_front.jsm": ["OS"],
+ "osfile_native.jsm": ["read"],
+ "osfile_shared_allthreads.jsm": ["LOG", "clone", "Config", "Constants", "Type", "HollowStructure", "OSError", "Library", "declareFFI", "declareLazy", "declareLazyFFI", "normalizeBufferArgs", "projectValue", "isArrayBuffer", "isTypedArray", "defineLazyGetter", "OS"],
+ "osfile_unix_allthreads.jsm": ["declareFFI", "libc", "Error", "AbstractInfo", "AbstractEntry", "Type", "POS_START", "POS_CURRENT", "POS_END"],
+ "osfile_win_allthreads.jsm": ["declareFFI", "libc", "Error", "AbstractInfo", "AbstractEntry", "Type", "POS_START", "POS_CURRENT", "POS_END"],
+ "ospath_unix.jsm": ["basename", "dirname", "join", "normalize", "split", "toFileURI", "fromFileURI"],
+ "ospath_win.jsm": ["basename", "dirname", "join", "normalize", "split", "winGetDrive", "winIsAbsolute", "toFileURI", "fromFileURI"],
+ "OutputGenerator.jsm": ["UtteranceGenerator", "BrailleGenerator"],
+ "packets.js": ["RawPacket", "Packet", "JSONPacket", "BulkPacket"],
+ "PageMenu.jsm": ["PageMenuParent", "PageMenuChild"],
+ "PageThumbs.jsm": ["PageThumbs", "PageThumbsStorage"],
+ "passwords.js": ["PasswordEngine", "LoginRec", "PasswordValidator"],
+ "passwords.jsm": ["Password", "DumpPasswords"],
+ "PdfJsNetwork.jsm": ["NetworkManager"],
+ "PhoneNumberMetaData.jsm": ["PHONE_NUMBER_META_DATA"],
+ "PluginProvider.jsm": [],
+ "PointerAdapter.jsm": ["PointerRelay", "PointerAdapter"],
+ "policies.js": ["ErrorHandler", "SyncScheduler"],
+ "PreferenceExperiments.jsm": ["PreferenceExperiments", "migrateStorage"],
+ "prefs.js": ["Branch", "MarionettePrefs"],
+ "prefs.js": ["PrefsEngine", "PrefRec"],
+ "prefs.jsm": ["Preference"],
+ "pretty-fast.js": ["prettyFast"],
+ "profiler_get_symbols.js": ["wasm_bindgen"],
+ "PromiseWorker.jsm": ["BasePromiseWorker"],
+ "PushCrypto.jsm": ["PushCrypto", "concatArray"],
+ "quit.js": ["goQuitApplication"],
+ "record.js": ["WBORecord", "RecordManager", "CryptoWrapper", "CollectionKeyManager", "Collection"],
+ "recursive_importA.jsm": ["foo", "bar"],
+ "recursive_importB.jsm": ["baz", "qux"],
+ "Reducers.jsm": ["reducers", "INITIAL_STATE", "insertPinned", "TOP_SITES_DEFAULT_ROWS", "TOP_SITES_MAX_SITES_PER_ROW"],
+ "Redux.jsm": ["redux"],
+ "reflect.jsm": ["Reflect"],
+ "remote-settings.js": ["RemoteSettings", "jexlFilterFunc", "remoteSettingsBroadcastHandler"],
+ "RemotePageManagerChild.jsm": ["ChildMessagePort"],
+ "RemotePageManagerParent.jsm": ["RemotePages", "RemotePageManager"],
+ "resource.js": ["AsyncResource", "Resource"],
+ "resource://services-common/utils.js": ["CommonUtils"],
+ "resource://services-crypto/utils.js": ["CryptoUtils"],
+ "resource://testing-common/services/sync/utils.js": ["AccountState", "MockFxaStorageManager", "SyncTestingInfrastructure", "configureFxAccountIdentity", "configureIdentity", "encryptPayload", "makeFxAccountsInternalMock", "makeIdentityConfig", "promiseNamedTimer", "promiseZeroTimer", "sumHistogram", "syncTestLogging", "waitForZeroTimer"],
+ "rest.js": ["RESTRequest", "RESTResponse", "TokenAuthenticatedRESTRequest"],
+ "rotaryengine.js": ["RotaryEngine", "RotaryRecord", "RotaryStore", "RotaryTracker"],
+ "Schemas.jsm": ["SchemaRoot", "Schemas"],
+ "SearchShortcuts.jsm": ["checkHasSearchEngine", "getSearchProvider", "SEARCH_SHORTCUTS", "CUSTOM_SEARCH_SHORTCUTS", "SEARCH_SHORTCUTS_EXPERIMENT", "SEARCH_SHORTCUTS_SEARCH_ENGINES_PREF", "SEARCH_SHORTCUTS_HAVE_PINNED_PREF"],
+ "SectionsManager.jsm": ["SectionsFeed", "SectionsManager"],
+ "service.js": ["Service"],
+ "SharedPromptUtils.jsm": ["PromptUtils", "EnableDelayHelper"],
+ "ShortURL.jsm": ["shortURL", "getETLD"],
+ "ShutdownLeaksCollector.jsm": ["ContentCollector"],
+ "SignInToWebsite.jsm": ["SignInToWebsiteController"],
+ "SiteClassifier.jsm": ["classifySite"],
+ "Social.jsm": ["Social", "OpenGraphBuilder", "DynamicResizeWatcher", "sizeSocialPanelToContent"],
+ "SpecialPowersObserver.jsm": ["SpecialPowersObserver", "SpecialPowersObserverFactory"],
+ "StateMachineHelper.jsm": ["State", "CommandType"],
+ "status.js": ["Status"],
+ "storageserver.js": ["ServerBSO", "StorageServerCallback", "StorageServerCollection", "StorageServer", "storageServerForUsers"],
+ "stream-utils.js": ["StreamUtils"],
+ "StructuredLog.jsm": ["StructuredLogger", "StructuredFormatter"],
+ "StyleEditorUtil.jsm": ["getString", "assert", "log", "text", "wire", "showFilePicker"],
+ "subprocess_common.jsm": ["BaseProcess", "PromiseWorker", "SubprocessConstants"],
+ "subprocess_shared.js": ["Library", "SubprocessConstants"],
+ "subprocess_shared_unix.js": ["libc"],
+ "subprocess_shared_win.js": ["LIBC", "Win", "createPipe", "libc"],
+ "subprocess_unix.jsm": ["SubprocessImpl"],
+ "subprocess_win.jsm": ["SubprocessImpl"],
+ "subprocess_worker_common.js": ["BasePipe", "BaseProcess", "debug"],
+ "sync.js": ["executeSoon", "DebounceCallback", "IdlePromise", "MessageManagerDestroyedPromise", "PollPromise", "Sleep", "TimedPromise", "waitForEvent", "waitForMessage", "waitForObserverTopic"],
+ "sync.jsm": ["Authentication"],
+ "SyncedBookmarksMirror.jsm": ["SyncedBookmarksMirror"],
+ "tabs.js": ["TabEngine", "TabSetRecord"],
+ "tabs.jsm": ["BrowserTabs"],
+ "tcpsocket_test.jsm": ["createSocket", "createServer", "enablePrefsAndPermissions", "socketCompartmentInstanceOfArrayBuffer"],
+ "telemetry.js": ["SyncTelemetry"],
+ "test.jsm": ["Foo"],
+ "test2.jsm": ["Bar"],
+ "test_bug883784.jsm": ["Test"],
+ "Timer.jsm": ["setTimeout", "setTimeoutWithTarget", "clearTimeout", "setInterval", "setIntervalWithTarget", "clearInterval", "requestIdleCallback", "cancelIdleCallback"],
+ "TippyTopProvider.jsm": ["TippyTopProvider", "getDomain"],
+ "Tokenize.jsm": ["tokenize", "toksToTfIdfVector"],
+ "tokenserverclient.js": ["TokenServerClient", "TokenServerClientError", "TokenServerClientNetworkError", "TokenServerClientServerError"],
+ "tps.jsm": ["ACTIONS", "Addons", "Addresses", "Bookmarks", "CreditCards", "Formdata", "History", "Passwords", "Prefs", "Tabs", "TPS", "Windows"],
+ "Translation.jsm": ["Translation", "TranslationTelemetry"],
+ "Traversal.jsm": ["TraversalRules", "TraversalHelper"],
+ "UpdateTelemetry.jsm": ["AUSTLMY"],
+ "UpdateTopLevelContentWindowIDHelper.jsm": ["trackBrowserWindow"],
+ "uptake-telemetry.js": ["UptakeTelemetry"],
+ "UrlbarUtils.jsm": ["UrlbarQueryContext", "UrlbarMuxer", "UrlbarProvider", "UrlbarUtils"],
+ "util.js": ["getChromeWindow", "Utils", "Svc", "SerializableSet"],
+ "utils.js": ["encryptPayload", "makeIdentityConfig", "makeFxAccountsInternalMock", "configureFxAccountIdentity", "configureIdentity", "SyncTestingInfrastructure", "waitForZeroTimer", "MockFxaStorageManager", "AccountState", "sumHistogram", "CommonUtils", "CryptoUtils", "TestingUtils", "promiseZeroTimer", "promiseNamedTimer", "getLoginTelemetryScalar", "syncTestLogging"],
+ "Utils.jsm": ["Utils", "Logger", "PivotContext", "PrefCache"],
+ "VariablesView.jsm": ["VariablesView", "escapeHTML"],
+ "version.jsm": ["VERSION"],
+ "vtt.jsm": ["WebVTT"],
+ "WebChannel.jsm": ["WebChannel", "WebChannelBroker"],
+ "windows.jsm": ["BrowserWindows"],
+ "WindowsJumpLists.jsm": ["WinTaskbarJumpList"],
+ "WindowsPreviewPerTab.jsm": ["AeroPeek"],
+ "xul-app.jsm": ["XulApp"]
+}
diff --git a/tools/lint/eslint/setup_helper.py b/tools/lint/eslint/setup_helper.py
new file mode 100644
index 0000000000..24fd8808b9
--- /dev/null
+++ b/tools/lint/eslint/setup_helper.py
@@ -0,0 +1,408 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# 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/.
+
+import json
+import os
+import platform
+import re
+import subprocess
+import sys
+from distutils.version import LooseVersion
+from filecmp import dircmp
+
+from mozbuild.nodeutil import (
+ find_node_executable,
+ find_npm_executable,
+ NPM_MIN_VERSION,
+ NODE_MIN_VERSION,
+)
+from mozbuild.util import ensure_subprocess_env
+from mozfile.mozfile import remove as mozfileremove
+
+
+NODE_MACHING_VERSION_NOT_FOUND_MESSAGE = """
+Could not find Node.js executable later than %s.
+
+Executing `mach bootstrap --no-system-changes` should
+install a compatible version in ~/.mozbuild on most platforms.
+""".strip()
+
+NPM_MACHING_VERSION_NOT_FOUND_MESSAGE = """
+Could not find npm executable later than %s.
+
+Executing `mach bootstrap --no-system-changes` should
+install a compatible version in ~/.mozbuild on most platforms.
+""".strip()
+
+NODE_NOT_FOUND_MESSAGE = """
+nodejs is either not installed or is installed to a non-standard path.
+
+Executing `mach bootstrap --no-system-changes` should
+install a compatible version in ~/.mozbuild on most platforms.
+""".strip()
+
+NPM_NOT_FOUND_MESSAGE = """
+Node Package Manager (npm) is either not installed or installed to a
+non-standard path.
+
+Executing `mach bootstrap --no-system-changes` should
+install a compatible version in ~/.mozbuild on most platforms.
+""".strip()
+
+
+VERSION_RE = re.compile(r"^\d+\.\d+\.\d+$")
+CARET_VERSION_RANGE_RE = re.compile(r"^\^((\d+)\.\d+\.\d+)$")
+
+project_root = None
+
+
+def eslint_maybe_setup():
+ """Setup ESLint only if it is needed."""
+ has_issues, needs_clobber = eslint_module_needs_setup()
+
+ if has_issues:
+ eslint_setup(needs_clobber)
+
+
+def eslint_setup(should_clobber=False):
+ """Ensure eslint is optimally configured.
+
+ This command will inspect your eslint configuration and
+ guide you through an interactive wizard helping you configure
+ eslint for optimal use on Mozilla projects.
+ """
+ package_setup(get_project_root(), "eslint", should_clobber=should_clobber)
+
+
+def package_setup(
+ package_root,
+ package_name,
+ should_update=False,
+ should_clobber=False,
+ no_optional=False,
+):
+ """Ensure `package_name` at `package_root` is installed.
+
+ When `should_update` is true, clobber, install, and produce a new
+ "package-lock.json" file.
+
+ This populates `package_root/node_modules`.
+
+ """
+ orig_project_root = get_project_root()
+ orig_cwd = os.getcwd()
+
+ if should_update:
+ should_clobber = True
+
+ try:
+ set_project_root(package_root)
+ sys.path.append(os.path.dirname(__file__))
+
+ # npm sometimes fails to respect cwd when it is run using check_call so
+ # we manually switch folders here instead.
+ project_root = get_project_root()
+ os.chdir(project_root)
+
+ if should_clobber:
+ node_modules_path = os.path.join(project_root, "node_modules")
+ print("Clobbering %s..." % node_modules_path)
+ if sys.platform.startswith("win") and have_winrm():
+ process = subprocess.Popen(["winrm", "-rf", node_modules_path])
+ process.wait()
+ else:
+ mozfileremove(node_modules_path)
+
+ npm_path, _ = find_npm_executable()
+ if not npm_path:
+ return 1
+
+ node_path, _ = find_node_executable()
+ if not node_path:
+ return 1
+
+ extra_parameters = ["--loglevel=error"]
+
+ if no_optional:
+ extra_parameters.append("--no-optional")
+
+ package_lock_json_path = os.path.join(get_project_root(), "package-lock.json")
+
+ if should_update:
+ cmd = [npm_path, "install"]
+ mozfileremove(package_lock_json_path)
+ else:
+ cmd = [npm_path, "ci"]
+
+ # On non-Windows, ensure npm is called via node, as node may not be in the
+ # path.
+ if platform.system() != "Windows":
+ cmd.insert(0, node_path)
+
+ # Ensure that bare `node` and `npm` in scripts, including post-install scripts, finds the
+ # binary we're invoking with. Without this, it's easy for compiled extensions to get
+ # mismatched versions of the Node.js extension API.
+ extra_parameters.append("--scripts-prepend-node-path")
+
+ cmd.extend(extra_parameters)
+
+ print('Installing %s for mach using "%s"...' % (package_name, " ".join(cmd)))
+ result = call_process(package_name, cmd)
+
+ if not result:
+ return 1
+
+ bin_path = os.path.join(
+ get_project_root(), "node_modules", ".bin", package_name
+ )
+
+ print("\n%s installed successfully!" % package_name)
+ print("\nNOTE: Your local %s binary is at %s\n" % (package_name, bin_path))
+
+ finally:
+ set_project_root(orig_project_root)
+ os.chdir(orig_cwd)
+
+
+def call_process(name, cmd, cwd=None, append_env={}):
+ env = dict(os.environ)
+ env.update(ensure_subprocess_env(append_env))
+
+ try:
+ with open(os.devnull, "w") as fnull:
+ subprocess.check_call(cmd, cwd=cwd, stdout=fnull, env=env)
+ except subprocess.CalledProcessError:
+ if cwd:
+ print("\nError installing %s in the %s folder, aborting." % (name, cwd))
+ else:
+ print("\nError installing %s, aborting." % name)
+
+ return False
+
+ return True
+
+
+def expected_eslint_modules():
+ # Read the expected version of ESLint and external modules
+ expected_modules_path = os.path.join(get_project_root(), "package.json")
+ with open(expected_modules_path, "r", encoding="utf-8") as f:
+ sections = json.load(f)
+ expected_modules = sections.get("dependencies", {})
+ expected_modules.update(sections.get("devDependencies", {}))
+
+ # Also read the in-tree ESLint plugin mozilla information, to ensure the
+ # dependencies are up to date.
+ mozilla_json_path = os.path.join(
+ get_eslint_module_path(), "eslint-plugin-mozilla", "package.json"
+ )
+ with open(mozilla_json_path, "r", encoding="utf-8") as f:
+ expected_modules.update(json.load(f).get("dependencies", {}))
+
+ # Also read the in-tree ESLint plugin spidermonkey information, to ensure the
+ # dependencies are up to date.
+ mozilla_json_path = os.path.join(
+ get_eslint_module_path(), "eslint-plugin-spidermonkey-js", "package.json"
+ )
+ with open(mozilla_json_path, "r", encoding="utf-8") as f:
+ expected_modules.update(json.load(f).get("dependencies", {}))
+
+ return expected_modules
+
+
+def check_eslint_files(node_modules_path, name):
+ def check_file_diffs(dcmp):
+ # Diff files only looks at files that are different. Not for files
+ # that are only present on one side. This should be generally OK as
+ # new files will need to be added in the index.js for the package.
+ if dcmp.diff_files and dcmp.diff_files != ["package.json"]:
+ return True
+
+ result = False
+
+ # Again, we only look at common sub directories for the same reason
+ # as above.
+ for sub_dcmp in dcmp.subdirs.values():
+ result = result or check_file_diffs(sub_dcmp)
+
+ return result
+
+ dcmp = dircmp(
+ os.path.join(node_modules_path, name),
+ os.path.join(get_eslint_module_path(), name),
+ )
+
+ return check_file_diffs(dcmp)
+
+
+def eslint_module_needs_setup():
+ has_issues = False
+ needs_clobber = False
+ node_modules_path = os.path.join(get_project_root(), "node_modules")
+
+ for name, expected_data in expected_eslint_modules().items():
+ # expected_eslint_modules returns a string for the version number of
+ # dependencies for installation of eslint generally, and an object
+ # for our in-tree plugins (which contains the entire module info).
+ if "version" in expected_data:
+ version_range = expected_data["version"]
+ else:
+ version_range = expected_data
+
+ path = os.path.join(node_modules_path, name, "package.json")
+
+ if not os.path.exists(path):
+ print("%s v%s needs to be installed locally." % (name, version_range))
+ has_issues = True
+ continue
+ data = json.load(open(path, encoding="utf-8"))
+
+ if version_range.startswith("file:"):
+ # We don't need to check local file installations for versions, as
+ # these are symlinked, so we'll always pick up the latest.
+ continue
+
+ if name == "eslint" and LooseVersion("4.0.0") > LooseVersion(data["version"]):
+ print("ESLint is an old version, clobbering node_modules directory")
+ needs_clobber = True
+ has_issues = True
+ continue
+
+ if not version_in_range(data["version"], version_range):
+ print("%s v%s should be v%s." % (name, data["version"], version_range))
+ has_issues = True
+ continue
+
+ return has_issues, needs_clobber
+
+
+def version_in_range(version, version_range):
+ """
+ Check if a module version is inside a version range. Only supports explicit versions and
+ caret ranges for the moment, since that's all we've used so far.
+ """
+ if version == version_range:
+ return True
+
+ version_match = VERSION_RE.match(version)
+ if not version_match:
+ raise RuntimeError("mach eslint doesn't understand module version %s" % version)
+ version = LooseVersion(version)
+
+ # Caret ranges as specified by npm allow changes that do not modify the left-most non-zero
+ # digit in the [major, minor, patch] tuple. The code below assumes the major digit is
+ # non-zero.
+ range_match = CARET_VERSION_RANGE_RE.match(version_range)
+ if range_match:
+ range_version = range_match.group(1)
+ range_major = int(range_match.group(2))
+
+ range_min = LooseVersion(range_version)
+ range_max = LooseVersion("%d.0.0" % (range_major + 1))
+
+ return range_min <= version < range_max
+
+ return False
+
+
+def get_possible_node_paths_win():
+ """
+ Return possible nodejs paths on Windows.
+ """
+ if platform.system() != "Windows":
+ return []
+
+ return list(
+ {
+ "%s\\nodejs" % os.environ.get("SystemDrive"),
+ os.path.join(os.environ.get("ProgramFiles"), "nodejs"),
+ os.path.join(os.environ.get("PROGRAMW6432"), "nodejs"),
+ os.path.join(os.environ.get("PROGRAMFILES"), "nodejs"),
+ }
+ )
+
+
+def get_version(path):
+ try:
+ version_str = subprocess.check_output(
+ [path, "--version"], stderr=subprocess.STDOUT, universal_newlines=True
+ )
+ return version_str
+ except (subprocess.CalledProcessError, OSError):
+ return None
+
+
+def set_project_root(root=None):
+ """Sets the project root to the supplied path, or works out what the root
+ is based on looking for 'mach'.
+
+ Keyword arguments:
+ root - (optional) The path to set the root to.
+ """
+ global project_root
+
+ if root:
+ project_root = root
+ return
+
+ file_found = False
+ folder = os.getcwd()
+
+ while folder:
+ if os.path.exists(os.path.join(folder, "mach")):
+ file_found = True
+ break
+ else:
+ folder = os.path.dirname(folder)
+
+ if file_found:
+ project_root = os.path.abspath(folder)
+
+
+def get_project_root():
+ """Returns the absolute path to the root of the project, see set_project_root()
+ for how this is determined.
+ """
+ global project_root
+
+ if not project_root:
+ set_project_root()
+
+ return project_root
+
+
+def get_eslint_module_path():
+ return os.path.join(get_project_root(), "tools", "lint", "eslint")
+
+
+def check_node_executables_valid():
+ node_path, version = find_node_executable()
+ if not node_path:
+ print(NODE_NOT_FOUND_MESSAGE)
+ return False
+ if not version:
+ print(NODE_MACHING_VERSION_NOT_FOUND_MESSAGE % NODE_MIN_VERSION)
+ return False
+
+ npm_path, version = find_npm_executable()
+ if not npm_path:
+ print(NPM_NOT_FOUND_MESSAGE)
+ return False
+ if not version:
+ print(NPM_MACHING_VERSION_NOT_FOUND_MESSAGE % NPM_MIN_VERSION)
+ return False
+
+ return True
+
+
+def have_winrm():
+ # `winrm -h` should print 'winrm version ...' and exit 1
+ try:
+ p = subprocess.Popen(
+ ["winrm.exe", "-h"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT
+ )
+ return p.wait() == 1 and p.stdout.read().startswith("winrm")
+ except Exception:
+ return False
diff --git a/tools/lint/eslint/update.sh b/tools/lint/eslint/update.sh
new file mode 100755
index 0000000000..3367a599e0
--- /dev/null
+++ b/tools/lint/eslint/update.sh
@@ -0,0 +1,71 @@
+#!/bin/sh
+# Script to regenerate the npm packages used for ESLint by the builders.
+# Requires
+
+# Force the scripts working directory to be projdir/tools/lint/eslint.
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+cd $DIR
+
+echo "To complete this script you will need the following tokens from https://mozilla-releng.net/tokens"
+echo " - tooltool.upload.public"
+echo " - tooltool.download.public"
+echo ""
+read -p "Are these tokens visible at the above URL (y/n)?" choice
+case "$choice" in
+ y|Y )
+ echo ""
+ echo "1. Go to https://mozilla-releng.net"
+ echo "2. Log in using your Mozilla LDAP account."
+ echo "3. Click on \"Tokens.\""
+ echo "4. Issue a user token with the permissions tooltool.upload.public and tooltool.download.public."
+ echo ""
+ echo "When you click issue you will be presented with a long string. Paste the string into a temporary file called ~/.tooltool-token."
+ echo ""
+ read -rsp $'Press any key to continue...\n' -n 1
+ ;;
+ n|N )
+ echo ""
+ echo "You will need to contact somebody that has these permissions... people most likely to have these permissions are members of the releng, ateam, a sheriff, mratcliffe, or jryans"
+ exit 1
+ ;;
+ * )
+ echo ""
+ echo "Invalid input."
+ continue
+ ;;
+esac
+
+echo ""
+echo "Removing node_modules and package-lock.json..."
+# Move to the top-level directory.
+cd ../../../
+rm -rf node_modules/
+rm -rf tools/lint/eslint/eslint-plugin-mozilla/node_modules
+rm package-lock.json
+
+echo "Installing eslint and external plugins..."
+# ESLint and all _external_ plugins are listed in this directory's package.json,
+# so a regular `npm install` will install them at the specified versions.
+# The in-tree eslint-plugin-mozilla is kept out of this tooltool archive on
+# purpose so that it can be changed by any developer without requiring tooltool
+# access to make changes.
+npm install
+
+echo "Creating eslint.tar.gz..."
+tar cvz --exclude=eslint-plugin-mozilla --exclude=eslint-plugin-spidermonkey-js -f eslint.tar.gz node_modules
+
+echo "Adding eslint.tar.gz to tooltool..."
+rm tools/lint/eslint/manifest.tt
+./python/mozbuild/mozbuild/action/tooltool.py add --visibility public --unpack eslint.tar.gz
+
+echo "Uploading eslint.tar.gz to tooltool..."
+./python/mozbuild/mozbuild/action/tooltool.py upload --authentication-file=~/.tooltool-token --message "node_modules folder update for tools/lint/eslint"
+
+echo "Cleaning up..."
+mv manifest.tt tools/lint/eslint/manifest.tt
+rm eslint.tar.gz
+
+cd $DIR
+
+echo ""
+echo "Update complete, please commit and check in your changes."