mirror of
https://github.com/joelwmale/webhook-action.git
synced 2024-08-25 08:08:00 +00:00
49 lines
5.1 KiB
JavaScript
49 lines
5.1 KiB
JavaScript
'use strict';var _importType = require('../core/importType');var _importType2 = _interopRequireDefault(_importType);
|
|
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 };}
|
|
|
|
function reportIfMissing(context, node, allowed, name) {
|
|
if (allowed.indexOf(name) === -1 && (0, _importType2.default)(name, context) === 'builtin') {
|
|
context.report(node, 'Do not import Node.js builtin module "' + name + '"');
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
meta: {
|
|
type: 'suggestion',
|
|
docs: {
|
|
url: (0, _docsUrl2.default)('no-nodejs-modules') },
|
|
|
|
schema: [
|
|
{
|
|
type: 'object',
|
|
properties: {
|
|
allow: {
|
|
type: 'array',
|
|
uniqueItems: true,
|
|
items: {
|
|
type: 'string' } } },
|
|
|
|
|
|
|
|
additionalProperties: false }] },
|
|
|
|
|
|
|
|
|
|
create: function (context) {
|
|
const options = context.options[0] || {};
|
|
const allowed = options.allow || [];
|
|
|
|
return {
|
|
ImportDeclaration: function handleImports(node) {
|
|
reportIfMissing(context, node, allowed, node.source.value);
|
|
},
|
|
CallExpression: function handleRequires(node) {
|
|
if ((0, _staticRequire2.default)(node)) {
|
|
reportIfMissing(context, node, allowed, node.arguments[0].value);
|
|
}
|
|
} };
|
|
|
|
} };
|
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1ub2RlanMtbW9kdWxlcy5qcyJdLCJuYW1lcyI6WyJyZXBvcnRJZk1pc3NpbmciLCJjb250ZXh0Iiwibm9kZSIsImFsbG93ZWQiLCJuYW1lIiwiaW5kZXhPZiIsInJ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