'use strict';

var _getExports = require('../core/getExports');

var _getExports2 = _interopRequireDefault(_getExports);

var _importDeclaration = require('../importDeclaration');

var _importDeclaration2 = _interopRequireDefault(_importDeclaration);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

module.exports = function (context) {
  function checkDefault(nameKey, defaultSpecifier) {
    var declaration = (0, _importDeclaration2.default)(context);

    var imports = _getExports2.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;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL25vLW5hbWVkLWFzLWRlZmF1bHQuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQTs7OztBQUNBOzs7Ozs7QUFFQSxPQUFPLE9BQVAsR0FBaUIsVUFBVSxPQUFWLEVBQW1CO0FBQ2xDLFdBQVMsWUFBVCxDQUFzQixPQUF0QixFQUErQixnQkFBL0IsRUFBaUQ7QUFDL0MsUUFBSSxjQUFjLGlDQUFrQixPQUFsQixDQUFsQjs7QUFFQSxRQUFJLFVBQVUscUJBQVEsR0FBUixDQUFZLFlBQVksTUFBWixDQUFtQixLQUEvQixFQUFzQyxPQUF0QyxDQUFkO0FBQ0EsUUFBSSxXQUFXLElBQWYsRUFBcUI7O0FBRXJCLFFBQUksUUFBUSxNQUFSLENBQWUsTUFBbkIsRUFBMkI7QUFDekIsY0FBUSxZQUFSLENBQXFCLE9BQXJCLEVBQThCLFdBQTlCO0FBQ0E7QUFDRDs7QUFFRCxRQUFJLFFBQVEsR0FBUixDQUFZLFNBQVosS0FDQ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