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

51 lines
4.3 KiB
JavaScript

'use strict';
var _ExportMap = require('../ExportMap');
var _ExportMap2 = _interopRequireDefault(_ExportMap);
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)('default')
}
},
create: function (context) {
function checkDefault(specifierType, node) {
// poor man's Array.find
let defaultSpecifier;
node.specifiers.some(n => {
if (n.type === specifierType) {
defaultSpecifier = n;
return true;
}
});
if (!defaultSpecifier) return;
var imports = _ExportMap2.default.get(node.source.value, context);
if (imports == null) return;
if (imports.errors.length) {
imports.reportErrors(context, node);
} else if (imports.get('default') === undefined) {
context.report(defaultSpecifier, 'No default export found in module.');
}
}
return {
'ImportDeclaration': checkDefault.bind(null, 'ImportDefaultSpecifier'),
'ExportNamedDeclaration': checkDefault.bind(null, 'ExportDefaultSpecifier')
};
}
};
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9kZWZhdWx0LmpzIl0sIm5hbWVzIjpbIm1vZHVsZSIsImV4cG9ydHMiLCJtZXRhIiwidHlwZSIsImRvY3MiLCJ1cmwiLCJjcmVhdGUiLCJjb250ZXh0IiwiY2hlY2tEZWZhdWx0Iiwic3BlY2lmaWVyVHlwZSIsIm5vZGUiLCJkZWZhdWx0U3BlY2lmaWVyIiwic3BlY2lmaWVycyIsInNvbWUiLCJuIiwiaW1wb3J0cyIsIkV4cG9ydHMiLCJnZXQiLCJzb3VyY2UiLCJ2YWx1ZSIsImVycm9ycyIsImxlbmd0aCIsInJlcG9ydEVycm9ycyIsInVuZGVmaW5lZCIsInJlcG9ydCIsImJpbmQiXSwibWFwcGluZ3MiOiI7O0FBQUE7Ozs7QUFDQTs7Ozs7O0FBR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