github-pages-deploy-action/node_modules/eslint-plugin-import/lib/rules/no-default-export.js

39 lines
4.1 KiB
JavaScript
Raw Normal View History

2020-03-07 11:45:40 +08:00
'use strict';
module.exports = {
meta: {
type: 'suggestion',
docs: {},
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1kZWZhdWx0LWV4cG9ydC5qcyJdLCJuYW1lcyI6WyJtb2R1bGUiLCJleHBvcnRzIiwibWV0YSIsInR5cGUiLCJkb2NzIiwic2NoZW1hIiwiY3JlYXRlIiwiY29udGV4dCIsInBhcnNlck9wdGlvbnMiLCJzb3VyY2VUeXBlIiwicHJlZmVyTmFtZWQiLCJub0FsaWFzRGVmYXVsdCIsImxvY2FsIiwibmFtZSIsIkV4cG9ydERlZmF1bHREZWNsYXJhdGlvbiIsIm5vZGUiLCJyZXBvcnQiLCJtZXNzYWdlIiwiRXhwb3J0TmFtZWREZWNsYXJhdGlvbiIsInNwZWNpZmllcnMiLCJmb3JFYWNoIiwic3BlY2lmaWVyIiwiZXhwb3J0ZWQiXSwibWFwcGluZ3MiOiI7O0FBQUFBLE9BQU9DLE9BQVAsR0FBaUI7QUFDZkMsUUFBTTtBQUNKQyxVQUFNLFlBREY7QUFFSkMsVUFB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