mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-29 03:45:15 +00:00
38 lines
4.1 KiB
JavaScript
38 lines
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1zZWxmLWltcG9ydC5qcyJdLCJuYW1lcyI6WyJpc0ltcG9ydGluZ1NlbGYiLCJjb250ZXh0Iiwibm9kZSIsInJlcXVpcmVOYW1lIiwiZmlsZVBhdGgiLCJnZXRQaHlzaWNhbEZpbGVuYW1lIiwiZ2V0RmlsZW5hbWUiLCJyZXBvcnQiLCJtZ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