mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
refactor(core): Remove linting exceptions in nodes-base (no-changelog) (#4944)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/no-loop-func */
|
||||
import { NodeVM, NodeVMOptions, VMRequire } from 'vm2';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
import {
|
||||
deepCopy,
|
||||
@@ -10,8 +11,6 @@ import {
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
const { NodeVM } = require('vm2');
|
||||
|
||||
export class FunctionItem implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Function Item',
|
||||
@@ -156,26 +155,28 @@ return item;`,
|
||||
const dataProxy = this.getWorkflowDataProxy(itemIndex);
|
||||
Object.assign(sandbox, dataProxy);
|
||||
|
||||
const options = {
|
||||
const options: NodeVMOptions = {
|
||||
console: mode === 'manual' ? 'redirect' : 'inherit',
|
||||
sandbox,
|
||||
require: {
|
||||
external: false as boolean | { modules: string[] },
|
||||
builtin: [] as string[],
|
||||
external: false,
|
||||
builtin: [],
|
||||
},
|
||||
};
|
||||
|
||||
const vmRequire = options.require as VMRequire;
|
||||
if (process.env.NODE_FUNCTION_ALLOW_BUILTIN) {
|
||||
options.require.builtin = process.env.NODE_FUNCTION_ALLOW_BUILTIN.split(',');
|
||||
vmRequire.builtin = process.env.NODE_FUNCTION_ALLOW_BUILTIN.split(',');
|
||||
}
|
||||
|
||||
if (process.env.NODE_FUNCTION_ALLOW_EXTERNAL) {
|
||||
options.require.external = {
|
||||
vmRequire.external = {
|
||||
modules: process.env.NODE_FUNCTION_ALLOW_EXTERNAL.split(','),
|
||||
transitive: false,
|
||||
};
|
||||
}
|
||||
|
||||
const vm = new NodeVM(options);
|
||||
const vm = new NodeVM(options as unknown as NodeVMOptions);
|
||||
|
||||
if (mode === 'manual') {
|
||||
vm.on('console.log', this.sendMessageToUI);
|
||||
|
||||
Reference in New Issue
Block a user