odin-default-js-exercises/node_modules/eslint-plugin-import/lib/rules/no-webpack-loader-syntax.js

33 lines
3.1 KiB
JavaScript
Raw Normal View History

2017-12-15 18:56:14 +00:00
'use strict';
var _staticRequire = require('../core/staticRequire');
var _staticRequire2 = _interopRequireDefault(_staticRequire);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function reportIfNonStandard(context, node, name) {
if (name.indexOf('!') !== -1) {
context.report(node, `Unexpected '!' in '${name}'. ` + 'Do not use import syntax to configure webpack loaders.');
}
}
module.exports = {
meta: {
docs: {}
},
create: function (context) {
return {
ImportDeclaration: function handleImports(node) {
reportIfNonStandard(context, node, node.source.value);
},
CallExpression: function handleRequires(node) {
if ((0, _staticRequire2.default)(node)) {
reportIfNonStandard(context, node, node.arguments[0].value);
}
}
};
}
};
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL25vLXdlYnBhY2stbG9hZGVyLXN5bnRheC5qcyJdLCJuYW1lcyI6WyJyZXBvcnRJZk5vblN0YW5kYXJkIiwiY29udGV4dCIsIm5vZGUiLCJuYW1lIiwiaW5kZXhPZiIsInJlcG9ydCIsIm1vZHVsZSIsImV4cG9ydHMiLCJtZXRhIiwiZG9jcyIsImNyZWF0ZSIsIkltcG9ydERlY2xhcmF0aW9uIiwiaGFuZGxlSW1wb3J0cyIsInNvdXJjZSIsInZhbHVlIiwiQ2FsbEV4cHJlc3Npb24iLCJoYW5kbGVSZXF1aXJlcyIsImFyZ3VtZW50cyJdLCJtYXBwaW5ncyI6Ijs7QUFBQTs7Ozs7O0FBRUEsU0FBU0EsbUJBQVQsQ0FBNkJDLE9BQTdCLEVBQXNDQyxJQUF0QyxFQUE0Q0MsSUFBNUMsRUFBa0Q7QUFDaEQsTUFBSUEsS0FBS0MsT0FBTCxDQUFhLEdBQWIsTUFBc0IsQ0FBQyxDQUEzQixFQUE4QjtBQUM1QkgsWUFBUUksTUFBUixD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