no-named-export.js 4.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. 'use strict';var _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_docsUrl);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { 'default': obj };}
  2. module.exports = {
  3. meta: {
  4. type: 'suggestion',
  5. docs: { url: (0, _docsUrl2['default'])('no-named-export') },
  6. schema: [] },
  7. create: function () {function create(context) {
  8. // ignore non-modules
  9. if (context.parserOptions.sourceType !== 'module') {
  10. return {};
  11. }
  12. var message = 'Named exports are not allowed.';
  13. return {
  14. ExportAllDeclaration: function () {function ExportAllDeclaration(node) {
  15. context.report({ node: node, message: message });
  16. }return ExportAllDeclaration;}(),
  17. ExportNamedDeclaration: function () {function ExportNamedDeclaration(node) {
  18. if (node.specifiers.length === 0) {
  19. return context.report({ node: node, message: message });
  20. }
  21. var someNamed = node.specifiers.some(function (specifier) {return (specifier.exported.name || specifier.exported.value) !== 'default';});
  22. if (someNamed) {
  23. context.report({ node: node, message: message });
  24. }
  25. }return ExportNamedDeclaration;}() };
  26. }return create;}() };
  27. //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1uYW1lZC1leHBvcnQuanMiXSwibmFtZXMiOlsibW9kdWxlIiwiZXhwb3J0cyIsIm1ldGEiLCJ0eXBlIiwiZG9jcyIsInVybCIsInNjaGVtYSIsImNyZWF0ZSIsImNvbnRleHQiLCJwYXJzZXJPcHRpb25zIiwic291cmNlVHlwZSIsIm1lc3NhZ2UiLCJFeHBvcnRBbGxEZWNsYXJhdGlvbiIsIm5vZGUiLCJyZXBvcnQiLCJFeHBvcnROYW1lZERlY2xhcmF0aW9uIiwic3BlY2lmaWVycyIsImxlbmd0aCIsInNvbWVOYW1lZCIsInNvbWUiLCJzcGVjaWZpZXIiLCJleHBvcnRlZCIsIm5hbWUiLCJ2YWx1ZSJdLCJtYXBwaW5ncy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