no-named-export.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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: {
  6. category: 'Style guide',
  7. description: 'Forbid named exports.',
  8. url: (0, _docsUrl2['default'])('no-named-export') },
  9. schema: [] },
  10. create: function () {function create(context) {
  11. // ignore non-modules
  12. if (context.parserOptions.sourceType !== 'module') {
  13. return {};
  14. }
  15. var message = 'Named exports are not allowed.';
  16. return {
  17. ExportAllDeclaration: function () {function ExportAllDeclaration(node) {
  18. context.report({ node: node, message: message });
  19. }return ExportAllDeclaration;}(),
  20. ExportNamedDeclaration: function () {function ExportNamedDeclaration(node) {
  21. if (node.specifiers.length === 0) {
  22. return context.report({ node: node, message: message });
  23. }
  24. var someNamed = node.specifiers.some(function (specifier) {return (specifier.exported.name || specifier.exported.value) !== 'default';});
  25. if (someNamed) {
  26. context.report({ node: node, message: message });
  27. }
  28. }return ExportNamedDeclaration;}() };
  29. }return create;}() };
  30. //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1uYW1lZC1leHBvcnQuanMiXSwibmFtZXMiOlsibW9kdWxlIiwiZXhwb3J0cyIsIm1ldGEiLCJ0eXBlIiwiZG9jcyIsImNhdGVnb3J5IiwiZGVzY3JpcHRpb24iLCJ1cmwiLCJzY2hlbWEiLCJjcmVhdGUiLCJjb250ZXh0IiwicGFyc2VyT3B0aW9ucyIsInNvdXJjZVR5cGUiLCJtZXNzYWdlIiwiRXhwb3J0QWxsRGVjbGFyYXRpb24iLCJub2RlIiwicmVwb3J0IiwiRXhwb3J0TmFtZWREZWNsYXJhdGlvbiIsInNwZWNpZmllcnMiLCJsZW5ndGgiLCJzb21lTmFtZWQiLCJ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