'use strict'; var _resolve = require('eslint-module-utils/resolve'); var _resolve2 = _interopRequireDefault(_resolve); var _staticRequire = require('../core/staticRequire'); var _staticRequire2 = _interopRequireDefault(_staticRequire); var _docsUrl = require('../docsUrl'); var _docsUrl2 = _interopRequireDefault(_docsUrl); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function isImportingSelf(context, node, requireName) { const filePath = context.getFilename(); // If the input is from stdin, this test can't fail if (filePath !== '' && filePath === (0, _resolve2.default)(requireName, context)) { context.report({ node, message: 'Module imports itself.' }); } } /** * @fileOverview Forbids a module from importing itself * @author Gio d'Amelio */ module.exports = { meta: { docs: { description: 'Forbid a module from importing itself', recommended: true, url: (0, _docsUrl2.default)('no-self-import') }, schema: [] }, create: function (context) { return { ImportDeclaration(node) { isImportingSelf(context, node, node.source.value); }, CallExpression(node) { if ((0, _staticRequire2.default)(node)) { isImportingSelf(context, node, node.arguments[0].value); } } }; } }; //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL25vLXNlbGYtaW1wb3J0LmpzIl0sIm5hbWVzIjpbImlzSW1wb3J0aW5nU2VsZiIsImNvbnRleHQiLCJub2RlIiwicmVxdWlyZU5hbWUiLCJmaWxlUGF0aCIsImdldEZpbGVuYW1lIiwicmVwb3J0IiwibWVzc2FnZSIsIm1vZHVsZSIsImV4cG9ydHMiLCJtZXRhIiwiZG9jcyIsImRlc2NyaXB0aW9uIiwicmVjb21tZW5kZWQiLCJ1cmwiLCJzY2hlbWEiLCJjcmVhdGUiLCJJbXBvcnREZWNsYXJhdGlvbiIsInNvdXJjZSIsInZhbHVlIiwiQ2FsbEV4cHJlc3Npb24iLCJhcmd1bWVudHMiXSwibWFwcGluZ3MiOiI7O0FBS0E7Ozs7QUFDQTs7OztBQUNBOzs7Ozs7QUFFQSxTQUFTQSxlQUFULENBQXlCQyxPQUF6QixFQUFrQ0MsSUFBbEMsRUFBd0NDLFdB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