webhook-action/node_modules/eslint-plugin-import/lib/rules/no-self-import.js

45 lines
4.3 KiB
JavaScript
Raw Normal View History

'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 !== '<text>' && 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: {
type: 'problem',
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1zZWxmLWltcG9ydC5qcyJdLCJuYW1lcyI6WyJpc0ltcG9ydGluZ1NlbGYiLCJjb250ZXh0Iiwibm9kZSIsInJlcXVpcmVOYW1lIiwiZmlsZVBhdGgiLCJnZXRGaWxlbmFtZSIsInJlcG9ydCIsIm1lc3NhZ2UiLCJtb2R1bGUiLCJleHBvcnRzIiwibWV0YSIsInR5cGUiLCJkb2NzIiwiZGVzY3JpcHRpb24iLCJyZWNvbW1lbmRlZCIsInVybCIsInNjaGVtYSIsImNyZWF0ZSIsIkltcG9ydERlY2xhcmF0aW9uIiwic291cmNlIiwidmFsdWUiLCJDYWxsRXhwcmVzc2lvbiIsImFyZ3VtZW50cyJdLCJtYX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