"'payload' is declared but its value is never read.(6133)", but as image shows, it complains about "payload" not being used, but it is used directly below in return object.
Same with formatting, when pasting stuff it auto-formats code in a separate step. Can ctrl+z to revert it, but annoying when pasting row after row of a long json, to ctrl+z after every paste / ctrl+v.
This is normally configured in configuration files. Would love to get my hand on those. For example prettier:
I would like to but I can't reproduce it anymore. I didn't change anything. I switched between the master and 4.0.5 versions and now I don't have any more errors, just the warning.
11 Nov 12:14:28 - [info] Node-RED version: v4.0.5
11 Nov 12:14:28 - [info] Node.js version: v20.18.0
11 Nov 12:14:28 - [info] Linux 6.6.51+rpt-rpi-2712 arm64 LE
11 Nov 12:14:28 - [info] Loading palette nodes
11 Nov 12:14:30 - [info] Settings file : /data/settings.js
11 Nov 12:14:30 - [info] Context store : 'default' [module=localfilesystem]
11 Nov 12:14:30 - [info] User directory : /data
11 Nov 12:14:30 - [info] Projects directory: /data/projects
11 Nov 12:14:30 - [info] Server now running at http://127.0.0.1:1880/
11 Nov 12:14:30 - [info] Active project : ktp-a
11 Nov 12:14:30 - [info] Flows file : /data/projects/ktp-a/flows.json
11 Nov 12:14:30 - [warn] Using unencrypted credentials
11 Nov 12:14:30 - [info] Starting flows
11 Nov 12:14:30 - [info] Started flows
Source code:
const data = msg.payload;
const date = new Date();
date.setMilliseconds(0);
if (data && typeof data === 'object') {
const payload = {
ts: date.getTime(),
values: data
};
return {payload: payload};
}
node.error("Payload field is missing or not an object", msg);
return null;
What I do to trigger the lint warning is to ctrl-click the last payload in "return {payload: payload}" to go to source / definition. Then the lightbulb and warning tooltip triggers.
Great! Looks like you can ignore a bunch of linter rules which is useful. Can you add also? If so, no undertaking at all, linting seems to be configurable. Thanks for pointing me in the right direction.
Wouldn't the same be possible for formatting also, using monaco config in settings.js?
Thanks, makes a lot of sense! I'm not in the mood to go some off-road route with custom eslint added on top of monaco. What about current formatting behavior, is that some hardcoded monaco default?
Thanks again, great documentation there. I realize it has quite a lot of options, but limited for more fine-grained details. Stumbled over this description of flow linter - nrlint:
Looks promising:
But it doesn't look like it is included by default, so must be installed manually?
Edit: Tried it out, amazing! Might even add eslint rules there.
Played around with nrlint a bit. One thing I didn't understand, the guide has a command to generate a default config file:
.nrlintrc.js
Editing this file doesn't seem to change anything in node red, so presumably this is for CLI only? But where is the config file stored for the rules used in node red? I can edit rules in node red editor, but can't find anywhere it is stored. Is it hidden deep inside npm folders somewhere (.npm or node_modules)?
Whatever you see or don't see in VSCode is configurable in eslint or in parts vs code settings.json, no? In my experience, you can take control and choose what and how is displayed.
After some thought I think it makes a lot of sense to have nrlint rules in user settings. Because they ought to be configured individually. The main rules in the nrlint file is then used for CD/CI pipeline as normal.