'use strict'; /** * @fileoverview Rule to prefer imports to AMD * @author Jamund Ferguson */ //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ module.exports = { meta: { docs: {} }, create: function (context) { return { 'CallExpression': function (node) { if (context.getScope().type !== 'module') return; if (node.callee.type !== 'Identifier') return; if (node.callee.name !== 'require' && node.callee.name !== 'define') return; // todo: capture define((require, module, exports) => {}) form? if (node.arguments.length !== 2) return; const modules = node.arguments[0]; if (modules.type !== 'ArrayExpression') return; // todo: check second arg type? (identifier or callback) context.report(node, `Expected imports instead of AMD ${node.callee.name}().`); } }; } }; //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInJ1bGVzL25vLWFtZC5qcyJdLCJuYW1lcyI6WyJtb2R1bGUiLCJleHBvcnRzIiwibWV0YSIsImRvY3MiLCJjcmVhdGUiLCJjb250ZXh0Iiwibm9kZSIsImdldFNjb3BlIiwidHlwZSIsImNhbGxlZSIsIm5hbWUiLCJhcmd1bWVudHMiLCJsZW5ndGgiLCJtb2R1bGVzIiwicmVwb3J0Il0sIm1hcHBpbmdzIjoiOztBQUFBOzs7OztBQUtBO0FBQ0E7QUFDQTs7QUFFQUEsT0FBT0MsT0FBUCxHQUFpQjtBQUNiQyxVQUFNO0FBQ0ZDLGNBQU07QUFESixLQURPOztBQUtiQyxZQUFRLFVBQVVDLE9BQVYsRUFBbUI7O0FBRXZCLGVBQU87O0FBRUgsOEJBQWtCLFVBQVVDLElBQVYsRUFBZ0I7QUFDcEMsb0JBQUlELFFBQVFFLFFBQVIsR0FBbUJDLElBQW5CLEtBQTRCLFFBQWhDLEVBQTBDOztBQUUxQyxvQkFBSUYsS0FBS0csTUFBTCxDQUFZRCxJQUFaLEtBQXFCLFlBQXpCLEVBQXVDO0FBQ3ZDLG9CQUFJRixLQUFLRyxNQUFMLENBQVlDLElBQVosS0FBcUIsU0FBckIsSUFDQUosS0FBS0csTUFBTCxDQUFZQyxJQUFaL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