github-pages-deploy-action/node_modules/eslint-plugin-import/lib/rules/no-amd.js
2020-03-06 22:45:40 -05:00

46 lines
4.1 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 (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}().`);
}
};
}
}; /**
* @fileoverview Rule to prefer imports to AMD
* @author Jamund Ferguson
*/
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1hbWQuanMiXSwibmFtZXMiOlsibW9kdWxlIiwiZXhwb3J0cyIsIm1ldGEiLCJ0eXBlIiwiZG9jcyIsInVybCIsInNjaGVtYSIsImNyZWF0ZSIsImNvbnRleHQiLCJub2RlIiwiZ2V0U2NvcGUiLCJjYWxsZWUiLCJuYW1lIiwiYXJndW1lbnRzIiwibGVuZ3RoIiwibW9kdWxlcyIsInJlcG9ydCJdLCJtYXBwaW5ncyI6Ijs7QUFLQTs7Ozs7O0FBRUE7QUFDQTtBQUNBOztBQUVBQSxPQUFPQyxPQUFQLEdBQWlCO0FBQ2ZDLFFBQU07QUFDSkMsVUFBTSxZQURGO0FBRUpDLFVBQU07QUFDSkMsV0FBSyx1QkFBUSxRQUFSO0FBREQsS0FGRjtBQUtKQyxZQUFRO0FBTEosR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