mirror of
https://github.com/joelwmale/webhook-action.git
synced 2024-12-02 04:15:23 +01:00
43 lines
No EOL
4.8 KiB
JavaScript
43 lines
No EOL
4.8 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 () {function create(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') };
|
|
|
|
}return create;}() };
|
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1uYW1lZC1hcy1kZWZhdWx0LmpzIl0sIm5hbWVzIjpbIm1vZHVsZSIsImV4cG9ydHMiLCJtZXRhIiwidHlwZSIsImRvY3MiLCJ1c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