зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1846758 - Automatically mark *.worker.?js files as belonging to the worker environment. r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D185321
This commit is contained in:
Родитель
d7b5956390
Коммит
98a950aa76
|
@ -20,6 +20,24 @@ ESLint also supports the ``--fix`` option to autofix most errors raised from mos
|
|||
|
||||
See the `Usage guide`_ for more options.
|
||||
|
||||
Custom Configurations
|
||||
---------------------
|
||||
|
||||
Our ESLint configuration has a number of custom configurations that define
|
||||
globals and rules for various code based on the pattern file path and names.
|
||||
|
||||
Using the correct patterns helps ESLint to know about the correct details, so
|
||||
that you don't get warnings about undefined or unused variables.
|
||||
|
||||
* ``.mjs`` - A module file.
|
||||
* ``.sys.mjs`` - A system module, this is typically a singleton in the process it is loaded into.
|
||||
* ``.worker.(m)js`` - A file that is a web worker.
|
||||
|
||||
* Workers that use ctypes should use ``/* eslint-env mozilla/chrome-worker */``
|
||||
|
||||
* Test files, see the section on :ref:`adding tests <adding-tests>`
|
||||
|
||||
|
||||
Understanding Rules and Errors
|
||||
------------------------------
|
||||
|
||||
|
@ -85,14 +103,6 @@ this is `difficult for ESLint to handle`_. Currently this may cause:
|
|||
* Extra definitions for globals in tests which means that the no undefined variables
|
||||
rule does not get triggered in some cases.
|
||||
|
||||
I'm using an ES module
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
* Use a ``.mjs`` extension for the file. ESLint will pick this up and automatically
|
||||
treat it as a module.
|
||||
* If it is a system module (e.g. component definition or other non-frontend code),
|
||||
use a ``.sys.mjs`` extension.
|
||||
|
||||
This code should neither be linted nor formatted
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
@ -124,11 +134,6 @@ I have valid code that is failing the ``no-undef`` rule or can't be parsed
|
|||
|
||||
* ``/* eslint-env mozilla/frame-script */``
|
||||
|
||||
* If you are writing a worker, then you may need to use the worker or chrome-worker environment:
|
||||
|
||||
* ``/* eslint-env worker */``
|
||||
* ``/* eslint-env mozilla/chrome-worker */``
|
||||
|
||||
* I use ``Services.scriptloader.loadSubScript``:
|
||||
|
||||
* ``/* import-globals-from relative/path/to/file.js``
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
* 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/. */
|
||||
|
||||
/* eslint-env mozilla/chrome-worker */
|
||||
|
||||
/**
|
||||
* A worker dedicated to Remote Settings.
|
||||
*/
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* 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/. */
|
||||
|
||||
/* eslint-env commonjs, mozilla/chrome-worker */
|
||||
/* eslint-env commonjs */
|
||||
|
||||
/**
|
||||
* A wrapper around `self` with extended capabilities designed
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/. */
|
||||
|
||||
/* eslint-env mozilla/chrome-worker */
|
||||
|
||||
/* import-globals-from /toolkit/components/workerloader/require.js */
|
||||
importScripts("resource://gre/modules/workers/require.js");
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/. */
|
||||
|
||||
/* eslint-env mozilla/chrome-worker */
|
||||
|
||||
/* import-globals-from /toolkit/components/workerloader/require.js */
|
||||
importScripts("resource://gre/modules/workers/require.js");
|
||||
|
||||
|
|
|
@ -106,6 +106,13 @@ module.exports = {
|
|||
"mozilla/reject-importGlobalProperties": "off",
|
||||
},
|
||||
},
|
||||
{
|
||||
env: {
|
||||
browser: false,
|
||||
worker: true,
|
||||
},
|
||||
files: ["**/*.worker.js", "**/*.worker.mjs"],
|
||||
},
|
||||
],
|
||||
|
||||
parserOptions: {
|
||||
|
|
Загрузка…
Ссылка в новой задаче