no-named-export.js 3.5 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(context) {
  8. // ignore non-modules
  9. if (context.parserOptions.sourceType !== 'module') {
  10. return {};
  11. }
  12. const message = 'Named exports are not allowed.';
  13. return {
  14. ExportAllDeclaration(node) {
  15. context.report({ node, message });
  16. },
  17. ExportNamedDeclaration(node) {
  18. if (node.specifiers.length === 0) {
  19. return context.report({ node, message });
  20. }
  21. const someNamed = node.specifiers.some(specifier => specifier.exported.name !== 'default');
  22. if (someNamed) {
  23. context.report({ node, message });
  24. }
  25. } };
  26. } };
  27. //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1uYW1lZC1leHBvcnQuanMiXSwibmFtZXMiOlsibW9kdWxlIiwiZXhwb3J0cyIsIm1ldGEiLCJ0eXBlIiwiZG9jcyIsInVybCIsInNjaGVtYSIsImNyZWF0ZSIsImNvbnRleHQiLCJwYXJzZXJPcHRpb25zIiwic291cmNlVHlwZSIsIm1lc3NhZ2UiLCJFeHBvcnRBbGxEZWNsYXJhdGlvbiIsIm5vZGUiLCJyZXBvcnQiLCJFeHBvcnROYW1lZERlY2xhcmF0aW9uIiwic3BlY2lmaWVycyIsImxlbmd0aCIsInNvbWVOYW1lZCIsInNvbWUiLCJzcGVjaWZpZXIiLCJleHBvcnRlZCIsIm5hbWUiXSwibWFwcGluZ3MiOiJhQUFBLHFDOztBQUVBQSxPQUFPQyxPQUFQLEdBQWlCO0FBQ2ZDLFFBQU07QUFDSkMsVUFBTSxZQURGO0FBRUpDLFVBQU0sRUFBRUMsS0FBSyx1QkFBU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