default.js 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. 'use strict';var _ExportMap = require('../ExportMap');var _ExportMap2 = _interopRequireDefault(_ExportMap);
  2. var _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_docsUrl);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { 'default': obj };}
  3. module.exports = {
  4. meta: {
  5. type: 'problem',
  6. docs: {
  7. url: (0, _docsUrl2['default'])('default') },
  8. schema: [] },
  9. create: function () {function create(context) {
  10. function checkDefault(specifierType, node) {
  11. var defaultSpecifier = node.specifiers.find(
  12. function (specifier) {return specifier.type === specifierType;});
  13. if (!defaultSpecifier) return;
  14. var imports = _ExportMap2['default'].get(node.source.value, context);
  15. if (imports == null) return;
  16. if (imports.errors.length) {
  17. imports.reportErrors(context, node);
  18. } else if (imports.get('default') === undefined) {
  19. context.report({
  20. node: defaultSpecifier,
  21. message: 'No default export found in imported module "' + String(node.source.value) + '".' });
  22. }
  23. }
  24. return {
  25. 'ImportDeclaration': checkDefault.bind(null, 'ImportDefaultSpecifier'),
  26. 'ExportNamedDeclaration': checkDefault.bind(null, 'ExportDefaultSpecifier') };
  27. }return create;}() };
  28. //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9kZWZhdWx0LmpzIl0sIm5hbWVzIjpbIm1vZHVsZSIsImV4cG9ydHMiLCJtZXRhIiwidHlwZSIsImRvY3MiLCJ1cmwiLCJzY2hlbWEiLCJjcmVhdGUiLCJjb250ZXh0IiwiY2hlY2tEZWZhdWx0Iiwic3BlY2lmaWVyVHlwZSIsIm5vZGUiLCJkZWZhdWx0U3BlY2lmaWVyIiwic3BlY2lmaWVycyIsImZpbmQiLCJzcGVjaWZpZXIiLCJpbXBvcnRzIiwiRXhwb3J0cyIsImdldCIsInNvdXJjZSIsInZhbHVlIiwiZXJyb3JzIiwibGVuZ3RoIiwicmVwb3J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