mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-29 03:45:15 +00:00
46 lines
4.3 KiB
JavaScript
46 lines
4.3 KiB
JavaScript
'use strict';
|
|
|
|
|
|
|
|
|
|
var _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_docsUrl);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { 'default': obj };}
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Rule Definition
|
|
//------------------------------------------------------------------------------
|
|
|
|
module.exports = {
|
|
meta: {
|
|
type: 'suggestion',
|
|
docs: {
|
|
url: (0, _docsUrl2['default'])('no-amd') },
|
|
|
|
schema: [] },
|
|
|
|
|
|
create: function () {function create(context) {
|
|
return {
|
|
'CallExpression': function () {function CallExpression(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;
|
|
|
|
var 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 ' + String(node.callee.name) + '().');
|
|
}return CallExpression;}() };
|
|
|
|
|
|
}return create;}() }; /**
|
|
* @fileoverview Rule to prefer imports to AMD
|
|
* @author Jamund Ferguson
|
|
*/
|
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1hbWQuanMiXSwibmFtZXMiOlsibW9kdWxlIiwiZXhwb3J0cyIsIm1ldGEiLCJ0eXBlIiwiZG9jcyIsInVybCIsInNjaGVtYSIsImNyZWF0ZSIsImNvbnRleHQiLCJub2RlIiwiZ2V0U2NvcGUiLCJjYWxsZWUiLCJuYW1lIiwiYXJndW1lbnRzIiwibGVuZ3RoIiwibW9k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