1
0
Fork 0
firefox/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/use-chromeutils-generateqi.rst
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

33 lines
980 B
ReStructuredText

use-chromeutils-generateqi
==========================
Reject use of ``XPCOMUtils.generateQI`` and JS-implemented QueryInterface
methods in favor of ``ChromeUtils``.
Examples of incorrect code for this rule:
-----------------------------------------
.. code-block:: js
X.prototype.QueryInterface = XPCOMUtils.generateQI(["nsIMeh"]);
X.prototype = { QueryInterface: XPCOMUtils.generateQI(["nsIMeh"]) };
X.prototype = { QueryInterface: function QueryInterface(iid) {
if (
iid.equals(Ci.nsISupports) ||
iid.equals(Ci.nsIMeh) ||
iid.equals(nsIFlug) ||
iid.equals(Ci.amIFoo)
) {
return this;
}
throw Components.Exception("", Cr.NS_ERROR_NO_INTERFACE);
} };
Examples of correct code for this rule:
---------------------------------------
.. code-block:: js
X.prototype.QueryInterface = ChromeUtils.generateQI(["nsIMeh"]);
X.prototype = { QueryInterface: ChromeUtils.generateQI(["nsIMeh"]) }