refactor(core): Remove linting exceptions in nodes-base (no-changelog) (#4944)

This commit is contained in:
Michael Kret
2023-01-13 19:11:56 +02:00
committed by GitHub
parent d7732ea150
commit 6608e69457
254 changed files with 2687 additions and 2675 deletions

View File

@@ -1,3 +1,4 @@
import { NodeVM, NodeVMOptions } from 'vm2';
import { IExecuteFunctions } from 'n8n-core';
import {
deepCopy,
@@ -9,8 +10,6 @@ import {
NodeOperationError,
} from 'n8n-workflow';
const { NodeVM } = require('vm2');
export class Function implements INodeType {
description: INodeTypeDescription = {
displayName: 'Function',
@@ -148,21 +147,24 @@ return items;`,
const mode = this.getMode();
const options = {
const options: NodeVMOptions = {
console: mode === 'manual' ? 'redirect' : 'inherit',
sandbox,
require: {
external: false as boolean | { modules: string[] },
external: false as boolean | { modules: string[]; transitive: boolean },
builtin: [] as string[],
},
};
if (process.env.NODE_FUNCTION_ALLOW_BUILTIN) {
if (process.env.NODE_FUNCTION_ALLOW_BUILTIN && typeof options.require === 'object') {
options.require.builtin = process.env.NODE_FUNCTION_ALLOW_BUILTIN.split(',');
}
if (process.env.NODE_FUNCTION_ALLOW_EXTERNAL) {
options.require.external = { modules: process.env.NODE_FUNCTION_ALLOW_EXTERNAL.split(',') };
if (process.env.NODE_FUNCTION_ALLOW_EXTERNAL && typeof options.require === 'object') {
options.require.external = {
modules: process.env.NODE_FUNCTION_ALLOW_EXTERNAL.split(','),
transitive: false,
};
}
const vm = new NodeVM(options);