summaryrefslogtreecommitdiffstats
path: root/docs/code-quality/lint/linters
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
commit40a355a42d4a9444dc753c04c6608dade2f06a23 (patch)
tree871fc667d2de662f171103ce5ec067014ef85e61 /docs/code-quality/lint/linters
parentAdding upstream version 124.0.1. (diff)
downloadfirefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz
firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'docs/code-quality/lint/linters')
-rw-r--r--docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/import-headjs-globals.rst1
-rw-r--r--docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/no-more-globals.rst20
-rw-r--r--docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/reject-mixing-eager-and-lazy.rst11
-rw-r--r--docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/reject-relative-requires.rst2
-rw-r--r--docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/valid-lazy.rst10
-rw-r--r--docs/code-quality/lint/linters/ignorefile.rst45
6 files changed, 78 insertions, 11 deletions
diff --git a/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/import-headjs-globals.rst b/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/import-headjs-globals.rst
index df8ef81300..51ec8eeb62 100644
--- a/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/import-headjs-globals.rst
+++ b/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/import-headjs-globals.rst
@@ -19,7 +19,6 @@ If path does not exist because it is generated e.g.
The following patterns are supported:
-- ``Cu.import("resource://devtools/client/shared/widgets/ViewHelpers.jsm");``
- ``loader.lazyRequireGetter(this, "name2"``
- ``loader.lazyServiceGetter(this, "name3"``
- ``loader.lazyGetter(this, "toolboxStrings"``
diff --git a/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/no-more-globals.rst b/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/no-more-globals.rst
new file mode 100644
index 0000000000..2cbe7e82ab
--- /dev/null
+++ b/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/no-more-globals.rst
@@ -0,0 +1,20 @@
+no-more-globals
+===============
+
+This rule is used to discourage people from adding ever more global variables to
+files where the rule is run.
+
+For any file ``example.js`` where the rule is applied, the rule will read
+an allowlist of globals from a sibling ``example.js.globals`` file. The rule
+will warn for any globals defined in ``example.js`` that are not listed in the
+``globals`` file, and will also warn for any items on the allowlist in
+the ``globals`` file that are no longer present in ``example.js``, encouraging
+people to remove them from the ``globals`` list.
+
+If you see errors from this rule about new globals, **do not just add items to
+the allowlist**. Instead, work to find a way to run your code so that it does
+not add to the list of globals.
+
+If you see errors when removing globals, simply remove them from the allowlist
+to make sure it is up-to-date and things do not inadvertently end up getting
+put back in.
diff --git a/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/reject-mixing-eager-and-lazy.rst b/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/reject-mixing-eager-and-lazy.rst
index 51524f4e14..1b7c165036 100644
--- a/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/reject-mixing-eager-and-lazy.rst
+++ b/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/reject-mixing-eager-and-lazy.rst
@@ -9,9 +9,10 @@ Examples of incorrect code for this rule:
.. code-block:: js
- const { SomeProp } = ChromeUtils.import("resource://gre/modules/Foo.jsm");
- ChromeUtils.defineLazyModuleGetters(lazy, {
- OtherProp: "resource://gre/modules/Foo.jsm",
+ const { SomeProp } =
+ ChromeUtils.importESModule("resource://gre/modules/Foo.sys.mjs");
+ ChromeUtils.defineESModuleGetters(lazy, {
+ OtherProp: "resource://gre/modules/Foo.sys.mjs",
});
Examples of correct code for this rule:
@@ -19,4 +20,6 @@ Examples of correct code for this rule:
.. code-block:: js
- const { SomeProp, OtherProp } = ChromeUtils.import("resource://gre/modules/Foo.jsm");
+ const { SomeProp, OtherProp } = ChromeUtils.importESModule(
+ "resource://gre/modules/Foo.sys.mjs"
+ );
diff --git a/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/reject-relative-requires.rst b/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/reject-relative-requires.rst
index 4387041b26..c3ec0cfed8 100644
--- a/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/reject-relative-requires.rst
+++ b/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/reject-relative-requires.rst
@@ -18,5 +18,5 @@ Examples of correct code for this rule:
.. code-block:: js
require("devtools/absolute/path")
- require("resource://gre/modules/SomeModule.jsm")
+ require("resource://gre/modules/SomeModule.sys.mjs")
loader.lazyRequireGetter(this, "path", "devtools/absolute/path", true)
diff --git a/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/valid-lazy.rst b/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/valid-lazy.rst
index a7edeeb5fc..e7f6706d5b 100644
--- a/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/valid-lazy.rst
+++ b/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/valid-lazy.rst
@@ -19,10 +19,10 @@ Examples of incorrect code for this rule:
.. code-block:: js
const lazy = {};
- ChromeUtils.defineLazyGetter(lazy, "foo", "foo.jsm");
+ ChromeUtils.defineESModuleGetters(lazy, { foo: "foo.sys.mjs"});
// Duplicate symbol foo being added to lazy.
- ChromeUtils.defineLazyGetter(lazy, "foo", "foo1.jsm");
+ ChromeUtils.defineLazyGetter(lazy, "foo", () => {});
if (x) {
lazy.foo3.bar();
}
@@ -31,12 +31,12 @@ Examples of incorrect code for this rule:
const lazy = {};
// Unused lazy property foo
- ChromeUtils.defineLazyGetter(lazy, "foo", "foo.jsm");
+ ChromeUtils.defineESModuleGetters(lazy, { foo: "foo.sys.mjs"});
.. code-block:: js
const lazy = {};
- ChromeUtils.defineLazyGetter(lazy, "foo", "foo.jsm");
+ ChromeUtils.defineESModuleGetters(lazy, { foo: "foo.sys.mjs"});
// Used at top-level unconditionally.
lazy.foo.bar();
@@ -47,7 +47,7 @@ Examples of correct code for this rule:
const lazy = {};
ChromeUtils.defineLazyGetter(lazy, "foo1", () => {});
- XPCOMUtils.defineLazyModuleGetters(lazy, { foo2: "foo2.jsm" });
+ ChromeUtils.defineESModuleGetters(lazy, { foo2: "foo2.sys.mjs"});
if (x) {
lazy.foo1.bar();
diff --git a/docs/code-quality/lint/linters/ignorefile.rst b/docs/code-quality/lint/linters/ignorefile.rst
new file mode 100644
index 0000000000..506ea5de51
--- /dev/null
+++ b/docs/code-quality/lint/linters/ignorefile.rst
@@ -0,0 +1,45 @@
+Ignorefile Lint
+===============
+
+Ignorefile lint is a linter for ``.gitignore`` and ``.hgignore`` files,
+to verify those files have equivalent entries.
+
+Each pattern is roughly compared, ignoring punctuations, to absorb the
+syntax difference.
+
+Run Locally
+-----------
+
+The mozlint integration of ignorefile linter can be run using mach:
+
+.. parsed-literal::
+
+ $ mach lint --linter ignorefile
+
+
+Special syntax
+--------------
+
+The following special comment can be used to ignore the pattern in the next line.
+
+.. parsed-literal::
+
+ # lint-ignore-next-line: git-only
+ # lint-ignore-next-line: hg-only
+
+The next line exists only in ``.gitignore``. or ``.hgignore``.
+
+.. parsed-literal::
+ # lint-ignore-next-line: syntax-difference
+
+The next line's pattern needs to be represented differently between
+``.gitignore`` and ``.hgignore``.
+This can be used when the ``.hgignore`` uses complex pattern which cannot be
+represented in single pattern in ``.gitignore``.
+
+
+Sources
+-------
+
+* :searchfox:`Configuration (YAML) <tools/lint/ignorefile.yml>`
+* :searchfox:`Source <tools/lint/ignorefile/__init__.py>`