Flow Linter error

hi,
today I installed Flow Linter and have been reported many errors ...
I fixed most of them but I have 3 errors pending ...

1° error

[msg] Parsing error: Unexpected token

I have this error in all the function where I use
setTimeout(() => { node.send([output[0]]) }, 2000);
like this:

const output = [null];
output[0] = { reset: true };
setTimeout(() => { node.send([output[0]]) }, 2000);

2° error

[msg] Do not access Object.prototype method 'hasOwnProperty' from target object.

this is the function:

if (msg.hasOwnProperty('ui_control') && msg.ui_control.callback === "renderComplete") {
    var msgOut = {
        payload: {
            command: "selectRow",
            arguments: [1],
            returnPromise: false
        }
    }
    return msgOut;
}

3* error

[msg] 'suncalc' is not defined

and this is the function:

function sunData() {
    return suncalc.getSunTimes(new Date(), 43.690419, 10.816769);
}
function moonData() {
    return suncalc.getMoonData(new Date(), 43.690419, 10.816769);
}

Can you help me to fix these errors?

version 4.0.3
node.js v20.15.0
Linux 6.1.21-v8+ arm LE
Dashborad version 3.6.5
Dashboard 2.0 v1.8.1
Raspberry Pi4 - SO raspberry

Hi @Giamma

I think you've hit some areas the flow linter doesn't handle well today and is in need of some updates.

Issue 1 - I think this is because you're using => functions which is newer syntax than the version of eslint bundled in the flow linter supports.

Issue 2 - This is actually a genuine warning. Rather than use msg.hasOwnProperty('ui_control'), the better syntax is Object.hasOwn(msg, 'ui_control')

Issue 3 - The linter doesn't know about the additional modules being imported into the function node (ie suncalc). The linter needs updating to handle that properly.

So, other than issue 2 which you can address yourself, the others are issues with the linter itself.

Ok, thank you very much .....

In setting.js I commented this line:

module.exports {
    nrlint: require("./.nrlintrc.js"),
}

and re-start node red but I always have the linter sidebar available in my editor,
how can I delete it?

Did you have refreshed your browser?

Yes I do ...

And removed the dependency?

cd .node-red
npm remove nrlint

Can be done in Palette Manager too.

Ok, I removed nrlint, thank you ....