node-red / nrlint

Node-RED Flow Linter
Apache License 2.0
36 stars 15 forks source link

function-eslint doesn't know about Buffer, util and modules imported in functionExternalModules #37

Open pauldeng opened 2 years ago

pauldeng commented 2 years ago

Current Behavior

Similar to issue https://github.com/node-red/nrlint/issues/22.

The function-eslint rule complains if a function node references Buffer, util and modules imported in functionExternalModules - saying they are not defined.

Expected Behavior

Any built-in object the Function node provides should not cause lint errors.

Modules added to the Setup page of function should not cause lint errors.

Steps To Reproduce

No response

Example flow

[{"id":"c6aa1fb9b985ec0c","type":"inject","z":"2c71e369871e1bf1","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":300,"y":200,"wires":[["f3c126edd67f2eab"]]},{"id":"f3c126edd67f2eab","type":"function","z":"2c71e369871e1bf1","name":"function 1","func":"msg.payload = Buffer.from('010203', 'hex');\n\nmsg.print = sprintfJs.sprintf(\"hello world %d\", 1234);\n\nmsg.hello = util.format('%s:%s', 'foo', 'bar');\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[{"var":"sprintfJs","module":"sprintf-js"}],"x":500,"y":200,"wires":[["f13d7e94ed4589f2"]]},{"id":"f13d7e94ed4589f2","type":"debug","z":"2c71e369871e1bf1","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":720,"y":200,"wires":[]}]

Environment