reject-import-system-module-from-non-system.js 939 B

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  5. */
  6. "use strict";
  7. module.exports = {
  8. meta: {
  9. docs: {
  10. url:
  11. "https://firefox-source-docs.mozilla.org/code-quality/lint/linters/eslint-plugin-mozilla/reject-import-system-module-from-non-system.html",
  12. },
  13. messages: {
  14. rejectStaticImportSystemModuleFromNonSystem:
  15. "System modules (*.sys.mjs) can be imported with static import declaration only from system modules.",
  16. },
  17. type: "problem",
  18. },
  19. create(context) {
  20. return {
  21. ImportDeclaration(node) {
  22. if (!node.source.value.endsWith(".sys.mjs")) {
  23. return;
  24. }
  25. context.report({
  26. node,
  27. messageId: "rejectStaticImportSystemModuleFromNonSystem",
  28. });
  29. },
  30. };
  31. },
  32. };