node-red / nrlint

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

Backslash in code with no-useless-escape rule enabled does not work #38

Closed fibrinogen closed 1 year ago

fibrinogen commented 1 year ago

Current Behavior

When using nrlint with no-useless-escape rule enabled and code that containes lines like:

toFormat('yyyy-MM-dd\'T'HH:mm:ss') or msg.payload = JSON.stringify(payload, null, '\t');

Then there is no output generated. When disabling the rule, the lint output in the sidebar is genrated.

Expected Behavior

nrlint should work with backslashes anywhere in the code.

Steps To Reproduce

Add a function node and paste this:

const myneverused = 1; msg.payload = JSON.stringify(payload, null, '\t');

into the function. Save and reload the UI. There is no output generated. Coment the second line containing the backslash. Save and reload the UI. There is output generated.

Example flow

[ { "id": "b8407210dbb78eb6", "type": "tab", "label": "test", "disabled": false, "info": "", "env": [] }, { "id": "85c9c63fa034dee2", "type": "function", "z": "b8407210dbb78eb6", "name": "function 1", "func": "const myneverused = 1;\n//msg.payload = JSON.stringify(payload, null, '\t');", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 440, "y": 180, "wires": [ [] ] } ]

Environment

knolleary commented 1 year ago

I believe this is the same as #36

It is a reproducible upstream bug with the browser packaged version of eslint we use. Unfortunately the upstream project appears abandoned so we don't currently have a good way forward to resolve it.

fibrinogen commented 1 year ago

May be for now it would be good to disable this rule to avoid frustration?