Bug 1788671 - Document how to add Services to eslint. r=Standard8 DONTBUILD

Differential Revision: https://phabricator.services.mozilla.com/D158753
This commit is contained in:
Simon Friedberger 2022-10-07 18:11:17 +00:00
parent f74b117c2d
commit 81ebfde770
3 changed files with 10 additions and 0 deletions

View file

@ -2,6 +2,8 @@ valid-services
==============
Ensures that accesses of the ``Services`` object are valid.
``Services`` are defined in ``tools/lint/eslint/eslint-plugin-mozilla/lib/services.json`` and can be added by copying from
``<objdir>/xpcom/components/services.json`` after a build.
Examples of incorrect code for this rule:
-----------------------------------------

View file

@ -49,6 +49,12 @@ My editor doesn't understand a new global I've just added (e.g. to a content fil
* Restarting your editor should pick up the new globals.
* You can always double check via ``./mach lint --linter eslint <file path>`` on the command line.
I am getting a linter error "Unknown Services member property"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Make sure to add any new Services to ``tools/lint/eslint/eslint-plugin-mozilla/lib/services.json``. For example by copying from
``<objdir>/xpcom/components/services.json`` after a build.
I'm adding tests, how do I set up the right configuration?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -210,6 +210,8 @@ Now update the :code:`moz.build` to point to it.
]
It is probably worth reading over :ref:`defining_xpcom_components`, but the following config will be sufficient to hook up our component to the :code:`Services` object.
Services should also be added to ``tools/lint/eslint/eslint-plugin-mozilla/lib/services.json``.
The easiest way to do that is to copy from ``<objdir>/xpcom/components/services.json``.
.. code:: python