mirror of
https://github.com/joelwmale/webhook-action.git
synced 2024-12-02 04:15:23 +01:00
38 lines
No EOL
4.1 KiB
JavaScript
38 lines
No EOL
4.1 KiB
JavaScript
'use strict';
|
|
|
|
|
|
|
|
|
|
var _resolve = require('eslint-module-utils/resolve');var _resolve2 = _interopRequireDefault(_resolve);
|
|
var _moduleVisitor = require('eslint-module-utils/moduleVisitor');var _moduleVisitor2 = _interopRequireDefault(_moduleVisitor);
|
|
var _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_docsUrl);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { 'default': obj };}
|
|
|
|
function isImportingSelf(context, node, requireName) {
|
|
var filePath = context.getPhysicalFilename ? context.getPhysicalFilename() : 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: 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 () {function create(context) {
|
|
return (0, _moduleVisitor2['default'])(function (source, node) {
|
|
isImportingSelf(context, node, source.value);
|
|
}, { commonjs: true });
|
|
}return create;}() };
|
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1zZWxmLWltcG9ydC5qcyJdLCJuYW1lcyI6WyJpc0ltcG9ydGluZ1NlbGYiLCJjb250ZXh0Iiwibm9kZSIsInJlcXVpcmVOYW1lIiwiZmlsZVBhdGgiLCJnZXRQaHlzaWNhbEZpbGVuYW1lIiwiZ2V0RmlsZW5hbWUiLCJyZXB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