reject-scriptableunicodeconverter.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. * @fileoverview Reject calls into Ci.nsIScriptableUnicodeConverter. We're phasing this out in
  3. * favour of TextEncoder or TextDecoder.
  4. *
  5. * This Source Code Form is subject to the terms of the Mozilla Public
  6. * License, v. 2.0. If a copy of the MPL was not distributed with this
  7. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  8. */
  9. "use strict";
  10. function isIdentifier(node, id) {
  11. return node && node.type === "Identifier" && node.name === id;
  12. }
  13. module.exports = {
  14. meta: {
  15. docs: {
  16. url:
  17. "https://firefox-source-docs.mozilla.org/code-quality/lint/linters/eslint-plugin-mozilla/reject-scriptableunicodeconverter.html",
  18. },
  19. type: "problem",
  20. },
  21. create(context) {
  22. return {
  23. MemberExpression(node) {
  24. if (
  25. isIdentifier(node.object, "Ci") &&
  26. isIdentifier(node.property, "nsIScriptableUnicodeConverter")
  27. ) {
  28. context.report(
  29. node,
  30. "Ci.nsIScriptableUnicodeConverter is deprecated. You should use TextEncoder or TextDecoder instead."
  31. );
  32. }
  33. },
  34. };
  35. },
  36. };