mirror of
https://github.com/joelwmale/webhook-action.git
synced 2024-08-25 08:08:00 +00:00
1ada95e04a
- Convert project to Javascript/Typescript - Allow custom headers to be passed in (optional) - Allow body to be optional
58 lines
5.8 KiB
JavaScript
58 lines
5.8 KiB
JavaScript
'use strict';var _slicedToArray = function () {function sliceIterator(arr, i) {var _arr = [];var _n = true;var _d = false;var _e = undefined;try {for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {_arr.push(_s.value);if (i && _arr.length === i) break;}} catch (err) {_d = true;_e = err;} finally {try {if (!_n && _i["return"]) _i["return"]();} finally {if (_d) throw _e;}}return _arr;}return function (arr, i) {if (Array.isArray(arr)) {return arr;} else if (Symbol.iterator in Object(arr)) {return sliceIterator(arr, i);} else {throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}();var _staticRequire = require('../core/staticRequire');var _staticRequire2 = _interopRequireDefault(_staticRequire);
|
|
var _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_docsUrl);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
|
|
|
|
const DEFAULT_MAX = 10;
|
|
|
|
const countDependencies = (dependencies, lastNode, context) => {var _ref =
|
|
context.options[0] || { max: DEFAULT_MAX };const max = _ref.max;
|
|
|
|
if (dependencies.size > max) {
|
|
context.report(
|
|
lastNode,
|
|
`Maximum number of dependencies (${max}) exceeded.`);
|
|
|
|
}
|
|
};
|
|
|
|
module.exports = {
|
|
meta: {
|
|
type: 'suggestion',
|
|
docs: {
|
|
url: (0, _docsUrl2.default)('max-dependencies') },
|
|
|
|
|
|
schema: [
|
|
{
|
|
'type': 'object',
|
|
'properties': {
|
|
'max': { 'type': 'number' } },
|
|
|
|
'additionalProperties': false }] },
|
|
|
|
|
|
|
|
|
|
create: context => {
|
|
const dependencies = new Set(); // keep track of dependencies
|
|
let lastNode; // keep track of the last node to report on
|
|
|
|
return {
|
|
ImportDeclaration(node) {
|
|
dependencies.add(node.source.value);
|
|
lastNode = node.source;
|
|
},
|
|
|
|
CallExpression(node) {
|
|
if ((0, _staticRequire2.default)(node)) {var _node$arguments = _slicedToArray(
|
|
node.arguments, 1);const requirePath = _node$arguments[0];
|
|
dependencies.add(requirePath.value);
|
|
lastNode = node;
|
|
}
|
|
},
|
|
|
|
'Program:exit': function () {
|
|
countDependencies(dependencies, lastNode, context);
|
|
} };
|
|
|
|
} };
|
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9tYXgtZGVwZW5kZW5jaWVzLmpzIl0sIm5hbWVzIjpbIkRFRkFVTFRfTUFYIiwiY291bnREZXBlbmRlbmNpZXMiLCJkZXBlbmRlbmNpZXMiLCJsYXN0Tm9kZSIsImNvbnRleHQiLCJvcHRpb25zIiwibWF4Iiwic2l6ZSIsInJlcG9ydCIsIm1vZHVsZSIsImV4cG9ydHMiLCJtZXRhIiwidHlwZSIsImRvY3MiLCJ1cmwiLCJzY2hlbWEiLCJjcmVhdGUiLCJTZXQiLCJJbXBvcnREZWNsYXJhdGlvbiIsIm5vZGUiLCJhZGQiLCJzb3VyY2UiLCJ2YWx1ZSIsIkNhbGxFeHByZXNzaW9uIiwiYXJndW1lbnRzIiwicmVxdWlyZVBhdGgiXSwibWFwcGluZ3MiOiJxb0JBQUEsc0Q7QUFDQSxxQzs7QUFFQSxNQUFNQSxjQUFjLEVBQXBCOztBQUVBLE1BQU1DLG9CQUFvQixDQUFDQyxZQUFELEVBQWVDLFFBQWYsRUFBeUJDLE9BQXpCLEtBQXFDO0FBQy9DQSxVQUFRQyxPQUFSLENBQWdCLENBQWhCLEtBQXNCLEVBQUVDLEtBQUtOLFdBQVAsRUFEeUIsT0FDdERNLEdBRHNELFFBQ3REQSxHQURzRDs7QUFHN0QsTUFBSUosYUFBYUssSUFBYixHQUFvQkQsR0FBeEIsRUFBNkI7QUFDM0JGLFlBQVFJLE1BQVI7QUFDRUwsWUF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