mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
52 lines
4.6 KiB
JavaScript
52 lines
4.6 KiB
JavaScript
'use strict';
|
|
|
|
var _ExportMap = require('../ExportMap');
|
|
|
|
var _ExportMap2 = _interopRequireDefault(_ExportMap);
|
|
|
|
var _importDeclaration = require('../importDeclaration');
|
|
|
|
var _importDeclaration2 = _interopRequireDefault(_importDeclaration);
|
|
|
|
var _docsUrl = require('../docsUrl');
|
|
|
|
var _docsUrl2 = _interopRequireDefault(_docsUrl);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
module.exports = {
|
|
meta: {
|
|
type: 'problem',
|
|
docs: {
|
|
url: (0, _docsUrl2.default)('no-named-as-default')
|
|
},
|
|
schema: []
|
|
},
|
|
|
|
create: function (context) {
|
|
function checkDefault(nameKey, defaultSpecifier) {
|
|
// #566: default is a valid specifier
|
|
if (defaultSpecifier[nameKey].name === 'default') return;
|
|
|
|
var declaration = (0, _importDeclaration2.default)(context);
|
|
|
|
var imports = _ExportMap2.default.get(declaration.source.value, context);
|
|
if (imports == null) return;
|
|
|
|
if (imports.errors.length) {
|
|
imports.reportErrors(context, declaration);
|
|
return;
|
|
}
|
|
|
|
if (imports.has('default') && imports.has(defaultSpecifier[nameKey].name)) {
|
|
|
|
context.report(defaultSpecifier, 'Using exported name \'' + defaultSpecifier[nameKey].name + '\' as identifier for default export.');
|
|
}
|
|
}
|
|
return {
|
|
'ImportDefaultSpecifier': checkDefault.bind(null, 'local'),
|
|
'ExportDefaultSpecifier': checkDefault.bind(null, 'exported')
|
|
};
|
|
}
|
|
};
|
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1uYW1lZC1hcy1kZWZhdWx0LmpzIl0sIm5hbWVzIjpbIm1vZHVsZSIsImV4cG9ydHMiLCJtZXRhI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