39 lines
4.3 KiB
JavaScript
39 lines
4.3 KiB
JavaScript
'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: {
|
|
category: 'Style guide',
|
|
description: 'Forbid named exports.',
|
|
url: (0, _docsUrl2['default'])('no-named-export') },
|
|
|
|
schema: [] },
|
|
|
|
|
|
create: function () {function create(context) {
|
|
// ignore non-modules
|
|
if (context.parserOptions.sourceType !== 'module') {
|
|
return {};
|
|
}
|
|
|
|
var message = 'Named exports are not allowed.';
|
|
|
|
return {
|
|
ExportAllDeclaration: function () {function ExportAllDeclaration(node) {
|
|
context.report({ node: node, message: message });
|
|
}return ExportAllDeclaration;}(),
|
|
|
|
ExportNamedDeclaration: function () {function ExportNamedDeclaration(node) {
|
|
if (node.specifiers.length === 0) {
|
|
return context.report({ node: node, message: message });
|
|
}
|
|
|
|
var someNamed = node.specifiers.some(function (specifier) {return (specifier.exported.name || specifier.exported.value) !== 'default';});
|
|
if (someNamed) {
|
|
context.report({ node: node, message: message });
|
|
}
|
|
}return ExportNamedDeclaration;}() };
|
|
|
|
}return create;}() };
|
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1uYW1lZC1leHBvcnQuanMiXSwibmFtZXMiOlsibW9kdWxlIiwiZXhwb3J0cyIsIm1ldGEiLCJ0eXBlIiwiZG9jcyIsImNhdGVnb3J5IiwiZGVzY3JpcHRpb24iLCJ1cmwiLCJzY2hlbWEiLCJjcmVhdGUiLCJjb250ZXh0IiwicGFyc2VyT3B0aW9ucyIsInNvdXJjZVR5cGUiLCJtZXNzYWdlIiwiRXhwb3J0QWxsRGVjbGFyYXRpb24iLCJub2RlIiwicmVwb3J0IiwiRXhwb3J0TmFtZWRE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