no-named-export.js
3.46 KB
'use strict';var _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_docsUrl);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
module.exports = {
meta: {
type: 'suggestion',
docs: { url: (0, _docsUrl2.default)('no-named-export') },
schema: [] },
create(context) {
// ignore non-modules
if (context.parserOptions.sourceType !== 'module') {
return {};
}
const message = 'Named exports are not allowed.';
return {
ExportAllDeclaration(node) {
context.report({ node, message });
},
ExportNamedDeclaration(node) {
if (node.specifiers.length === 0) {
return context.report({ node, message });
}
const someNamed = node.specifiers.some(specifier => specifier.exported.name !== 'default');
if (someNamed) {
context.report({ node, message });
}
} };
} };
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1uYW1lZC1leHBvcnQuanMiXSwibmFtZXMiOlsibW9kdWxlIiwiZXhwb3J0cyIsIm1ldGEiLCJ0eXBlIiwiZG9jcyIsInVybCIsInNjaGVtYSIsImNyZWF0ZSIsImNvbnRleHQiLCJwYXJzZXJPcHRpb25zIiwic291cmNlVHlwZSIsIm1lc3NhZ2UiLCJFeHBvcnRBbGxEZWNsYXJhdGlvbiIsIm5vZGUiLCJyZXBvcnQiLCJFeHBvcnROYW1lZERlY2xhcmF0aW9uIiwic3BlY2lmaWVycyIsImxlbmd0aCIsInNvbWVOYW1lZCIsInNvbWUiLCJzcGVjaWZpZXIiLCJleHBvcnRlZCIsIm5hbWUiXSwibWFwcGluZ3MiOiJhQUFBLHFDOztBQUVBQSxPQUFPQyxPQUFQLEdBQWlCO0FBQ2ZDLFFBQU07QUFDSkMsVUFBTSxZQURGO0FBRUpDLFVBQU0sRUFBRUMsS0FBSyx1QkFBUSxpQkFBUixDQUFQLEVBRkY7QUFHSkMsWUFBUSxFQUhKLEVBRFM7OztBQU9mQyxTQUFPQyxPQUFQLEVBQWdCO0FBQ2Q7QUFDQSxRQUFJQ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