web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
4.3 KiB

  1. 'use strict';
  2. var _resolve = require('eslint-module-utils/resolve');var _resolve2 = _interopRequireDefault(_resolve);
  3. var _staticRequire = require('../core/staticRequire');var _staticRequire2 = _interopRequireDefault(_staticRequire);
  4. var _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_docsUrl);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
  5. function isImportingSelf(context, node, requireName) {
  6. const filePath = context.getFilename();
  7. // If the input is from stdin, this test can't fail
  8. if (filePath !== '<text>' && filePath === (0, _resolve2.default)(requireName, context)) {
  9. context.report({
  10. node,
  11. message: 'Module imports itself.' });
  12. }
  13. } /**
  14. * @fileOverview Forbids a module from importing itself
  15. * @author Gio d'Amelio
  16. */module.exports = { meta: {
  17. type: 'problem',
  18. docs: {
  19. description: 'Forbid a module from importing itself',
  20. recommended: true,
  21. url: (0, _docsUrl2.default)('no-self-import') },
  22. schema: [] },
  23. create: function (context) {
  24. return {
  25. ImportDeclaration(node) {
  26. isImportingSelf(context, node, node.source.value);
  27. },
  28. CallExpression(node) {
  29. if ((0, _staticRequire2.default)(node)) {
  30. isImportingSelf(context, node, node.arguments[0].value);
  31. }
  32. } };
  33. } };
  34. //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1zZWxmLWltcG9ydC5qcyJdLCJuYW1lcyI6WyJpc0ltcG9ydGluZ1NlbGYiLCJjb250ZXh0Iiwibm9kZSIsInJlcXVpcmVOYW1lIiwiZmlsZVBhdGgiLCJnZXRGaWxlbmFtZSIsInJlcG9ydCIsIm1lc3NhZ2UiLCJtb2R1bGUiLCJleHBvcnRzIiwibWV0YSIsInR5cGUiLCJkb2NzIiwiZGVzY3JpcHRpb24iLCJyZWNvbW1lbmRlZCIsInVybCIsInN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