bigint-crypto-utils/node_modules/eslint-plugin-import/lib/rules/no-default-export.js

38 lines
4.1 KiB
JavaScript

'use strict';
module.exports = {
meta: {
type: 'suggestion',
docs: {}
},
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1kZWZhdWx0LWV4cG9ydC5qcyJdLCJuYW1lcyI6WyJtb2R1bGUiLCJleHBvcnRzIiwibWV0YSIsInR5cGUiLCJkb2NzIiwiY3JlYXRlIiwiY29udGV4dCIsInBhcnNlck9wdGlvbnMiLCJzb3VyY2VUeXBlIiwicHJlZmVyTmFtZWQiLCJub0FsaWFzRGVmYXVsdCIsImxvY2FsIiwibmFtZSIsIkV4cG9ydERlZmF1bHREZWNsYXJhdGlvbiIsIm5vZGUiLCJyZXBvcnQiLCJtZXNzYWdlIiwiRXhwb3J0TmFtZWREZWNsYXJhdGlvbiIsInNwZWNpZmllcnMiLCJmb3JFYWNoIiwic3BlY2lmaWVyIiwiZXhwb3J0ZWQiXSwibWFwcGluZ3MiOiI7O0FBQUFBLE9BQU9DLE9BQVAsR0FBaUI7QUFDZkMsUUFBTTtBQUNKQyxVQUFNLFlBREY7QUFFSkMsVUFBTTtBQUZGLEdBRFM7O0FBTWZDLFNBQU9DLE9BQVAsRUF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