1234567891011121314151617181920212223242526272829303132333435363738394041 |
- '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-default-export') },
- schema: [] },
- create(context) {
- // ignore non-modules
- if (context.parserOptions.sourceType !== 'module') {
- return {};
- }
- const preferNamed = 'Prefer named exports.';
- const noAliasDefault = (_ref) => {let local = _ref.local;return (
- `Do not alias \`${local.name}\` as \`default\`. Just export ` +
- `\`${local.name}\` itself instead.`);};
- return {
- ExportDefaultDeclaration(node) {
- context.report({ node, message: preferNamed });
- },
- ExportNamedDeclaration(node) {
- node.specifiers.forEach(specifier => {
- if (specifier.type === 'ExportDefaultSpecifier' &&
- specifier.exported.name === 'default') {
- context.report({ node, message: preferNamed });
- } else if (specifier.type === 'ExportSpecifier' &&
- specifier.exported.name === 'default') {
- context.report({ node, message: noAliasDefault(specifier) });
- }
- });
- } };
- } };
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1kZWZhdWx0LWV4cG9ydC5qcyJdLCJuYW1lcyI6WyJtb2R1bGUiLCJleHBvcnRzIiwibWV0YSIsInR5cGUiLCJkb2NzIiwidXJsIiwic2NoZW1hIiwiY3JlYXRlIiwiY29udGV4dCIsInBhcnNlck9wdGlvbnMiLCJzb3VyY2VUeXBlIiwicHJlZmVyTmFtZWQiLCJub0FsaWFzRGVmYXVsdCIsImxvY2FsIiwibmFtZSIsIkV4cG9ydERlZmF1bHREZWNsYXJhdGlvbiIsIm5vZGUiLCJyZXBvcnQiLCJtZXNzYWdlIiwiRXhwb3J0TmFtZWREZWNsYXJhdGlvbiIsInNwZWNpZmllcnMiLCJmb3JFYWNoIiwic3BlY2lmaWVyIiwiZXhwb3J0ZWQiXSwibWFwc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