summaryrefslogtreecommitdiffstats
path: root/docs/code-quality/lint/linters/eslint-plugin-mozilla/use-services.rst
blob: 1a57e3da108f889c11e92e17b5559ca74de03dcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use-services
============

Requires the use of ``Services`` rather than ``Cc[].getService()`` where a
service is already defined in ``Services``.

Examples of incorrect code for this rule:
-----------------------------------------

.. code-block:: js

    Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
    Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(Components.interfaces.nsIAppStartup);

Examples of correct code for this rule:
---------------------------------------

.. code-block:: js

    Services.wm.addListener()
    Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator)