summaryrefslogtreecommitdiffstats
path: root/docs/code-quality/lint/linters/eslint-plugin-mozilla/use-cc-etc.rst
blob: 902b4a630c95932e14103066cc1798673cf1006a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use-cc-etc
======================

This requires using ``Cc`` rather than ``Components.classes``, and the same for
``Components.interfaces``, ``Components.results`` and ``Components.utils``.
This has a slight performance advantage by avoiding the use of the dot.

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

.. code-block:: js

    let foo = Components.classes['bar'];
    let bar = Components.interfaces.bar;
    Components.results.NS_ERROR_ILLEGAL_INPUT;
    Components.utils.reportError('fake');

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

.. code-block:: js

    let foo = Cc['bar'];
    let bar = Ci.bar;
    Cr.NS_ERROR_ILLEGAL_INPUT;
    Cu.reportError('fake');