UNPKG

twreporter-react

Version:

React-Redux site for The Reporter Foundation in Taiwan

34 lines (25 loc) 897 B
'use strict'; var getExports = require('../core/getExports').get; module.exports = function (context) { function checkSpecifiers(key, type, node) { if (node.source == null) return; // local export, ignore if (!node.specifiers.some(function (im) { return im.type === type; })) { return; // no named imports/exports } var imports = getExports(node.source.value, context); if (imports == null) return; var names = imports.named; node.specifiers.forEach(function (im) { if (im.type !== type) return; if (!names.has(im[key].name)) { context.report(im[key], im[key].name + ' not found in \'' + node.source.value + '\''); } }); } return { 'ImportDeclaration': checkSpecifiers.bind(null, 'imported', 'ImportSpecifier'), 'ExportNamedDeclaration': checkSpecifiers.bind(null, 'local', 'ExportSpecifier') }; };