# Request for ideas: Linter rules

**URL:** <https://discourse.nodered.org/t/request-for-ideas-linter-rules/45932>\
**Category:** Core Development\
**Created:** [19 May 2021 16:09 UTC](https://discourse.nodered.org/t/request-for-ideas-linter-rules/45932 "2021-05-19T16:09:40Z")\
**Posts on this page:** 17\
**Page:** 2

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [20 May 2021 09:14 UTC](https://discourse.nodered.org/t/request-for-ideas-linter-rules/45932/21 "2021-05-20T09:14:24Z")

</div>

> [@greenembrace](#):
>
> old-version - Warning for not using the latest version of node.

I'd add to that, using any unsupported version - e.g. one that is too new as well.

And, throw in using an old version of Node-RED as well.

> [@BartButenaers](#):
>
> So it is advised to use only 1 wire on the output of those nodes, since multiple wires cause cloning

I already mentioned that one.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [20 May 2021 09:15 UTC](https://discourse.nodered.org/t/request-for-ideas-linter-rules/45932/22 "2021-05-20T09:15:47Z")

</div>

Please keep in mind this is doing static analysis of your flow JSON. The version of Node-RED you are using is _not_ in scope here.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [20 May 2021 09:16 UTC](https://discourse.nodered.org/t/request-for-ideas-linter-rules/45932/23 "2021-05-20T09:16:47Z")

</div>

Something for another process improvement then 😉

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [20 May 2021 10:11 UTC](https://discourse.nodered.org/t/request-for-ideas-linter-rules/45932/24 "2021-05-20T10:11:28Z")

</div>

> [@TotallyInformation](#):
>
> > [@BartButenaers](#):
> >
> > So it is advised to use only 1 wire on the output of those nodes, since multiple wires cause cloning
> 
> I already mentioned that one.

Julian,  
I was assuming that multiple wires on a single output isn't really a problem in most cases, unless you really want to avoid cloning on only a few of the nodes in a flow. But that required that the linter was able to determine shomehow to determine which outputs needs this restriction. Because I personally don't need this restrictions on most of my nodes, only a few ones that do video processing.  
But I'm totally aware that a linter might never have enough information to make this distinction! Just mentioning the use case...

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [20 May 2021 15:56 UTC](https://discourse.nodered.org/t/request-for-ideas-linter-rules/45932/25 "2021-05-20T15:56:51Z")

</div>

Hi Bart, as the linter "just" checks the flows json file, I think that the easiest solution is to have it report any/all nodes with \>1 wire on an output. That way you can review for yourself and if you are satisfied, turn off the rule again.

I would see it as probably something I would use periodically. As you say it is generally not an issue anyway.

---

<div class="post-metadata">

**Author:** ![Hypnos](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hypnos/32/7566_2.png) [@Hypnos](https://discourse.nodered.org/u/Hypnos)\
**Post date:** [20 May 2021 16:11 UTC](https://discourse.nodered.org/t/request-for-ideas-linter-rules/45932/26 "2021-05-20T16:11:17Z")

</div>

One more

- all nodes should be inside a group

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [20 May 2021 16:12 UTC](https://discourse.nodered.org/t/request-for-ideas-linter-rules/45932/27 "2021-05-20T16:12:22Z")

</div>

That was already covered.

---

<div class="post-metadata">

**Author:** ![Hypnos](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hypnos/32/7566_2.png) [@Hypnos](https://discourse.nodered.org/u/Hypnos)\
**Post date:** [20 May 2021 18:26 UTC](https://discourse.nodered.org/t/request-for-ideas-linter-rules/45932/28 "2021-05-20T18:26:27Z")

</div>

There was

> If it were possible, a check for nodes that overlap a group box but are not actually part of the group.

But I request that are **all** nodes should be inside a group, it doesn't matter if they are somewhere alone or overlap a group box.

---

<div class="post-metadata">

**Author:** ![stevenaeola](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevenaeola/32/9337_2.png) [@stevenaeola](https://discourse.nodered.org/u/stevenaeola)\
**Post date:** [21 May 2021 09:42 UTC](https://discourse.nodered.org/t/request-for-ideas-linter-rules/45932/29 "2021-05-21T09:42:05Z")

</div>

Hi there,  
would it be possible to generalise the http-in-response rule to allow nodes to define a "required upstream" and "required downstream", presumably as a property in the .html file? This could be refined to include "forbidden upstream" etc. Specifying a list would say "requires A or B" or "forbids A and B".

So in RED.nodes.registerType('http in' ...

you would include the property

"required upstream": "http response"

and then the linter would do its magic

For my node-red-contrib-music supercollider node I would have

"required upstream": ["synth", "looper"]

and for the synth node I would have

"forbidden upstream": "soundfx"

It might be nice to have a more general type system on messages, but that's probably too complex.

Thanks,

Steven

---

<div class="post-metadata">

**Author:** ![augjoh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/augjoh/32/26464_2.png) [@augjoh](https://discourse.nodered.org/u/augjoh)\
**Post date:** [23 May 2021 05:56 UTC](https://discourse.nodered.org/t/request-for-ideas-linter-rules/45932/30 "2021-05-23T05:56:28Z")

</div>

There are issues, that can be at the flow level:

1. All flow links are connected

And there are issues at the node level:

1. Http in node protects parameters in the path with regexs

Would be great, if the nodes itself can contribute their own rules (and linters).

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [23 May 2021 21:49 UTC](https://discourse.nodered.org/t/request-for-ideas-linter-rules/45932/31 "2021-05-23T21:49:43Z")

</div>

A few rules that would help in my style of development are:  
`Missing Otherwise rule in Switch node` - warns if a `switch` node does not have an `otherwise` rule.  
`Debug node configuration` - warns if a `debug` node is not configured to a user specified pattern (that is, for enabled/disabled, Output:complete message object/msg./JSONata, and To:debug window/system console/node status).  
`Missing connection` - warns if a node has no input connection or has an output port with no connection.

The linter would be helpful if it runs from the command line and takes a static look at the flow file, but it would be much better if it ran live in the editor and could reflect changes in the flow as they are deployed and also allow the user to change the rules on the fly. Depending on how and where the linter output is shown on the editor, it would be nice to be able to clear warnings from specific nodes without having to disable the rule completely.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [23 May 2021 22:01 UTC](https://discourse.nodered.org/t/request-for-ideas-linter-rules/45932/32 "2021-05-23T22:01:49Z")

</div>

> [@drmibell](#):
>
> The linter would be helpful if it runs from the command line and takes a static look at the flow file, but it would be much better if it ran live in the editor and could reflect changes in the flow as they are deployed

Yes, that's the plan. As I said at the start:

> It will run either as a command-line tool on flow json files, or in the editor reporting back in realtime as you edit your flows.

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [23 May 2021 22:05 UTC](https://discourse.nodered.org/t/request-for-ideas-linter-rules/45932/33 "2021-05-23T22:05:45Z")

</div>

Thanks. I saw that but wasn't sure whether "realtime" meant you could change, enable/disable, add/delete rules on the fly or clear warnings from individual nodes. Sounds like a good plan.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [23 May 2021 22:09 UTC](https://discourse.nodered.org/t/request-for-ideas-linter-rules/45932/34 "2021-05-23T22:09:16Z")

</div>

Still working through how you'd be able to mark a particular warning as "Okay in this case" for a given node without disabling the rule for the whole set of flows. Most likely approach is we'd add a comment to the node's info property (the description box in the editor) with some markup the linter can recognise to turn off a particular rule for that node.

I'm also working the the UI side of configuring the rules. At the moment it expects a static configuration in your settings file, but we'll have a way to edit the settings in the editor.

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [23 May 2021 22:20 UTC](https://discourse.nodered.org/t/request-for-ideas-linter-rules/45932/35 "2021-05-23T22:20:45Z")

</div>

It sounds like the rule set is "universal." Why not associate it with the flow.json file? Then different rules could be applied to different projects, starting from a default set. Also, the `rules` file could contain instructions to ignore certain rules for certain nodes.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [23 May 2021 22:34 UTC](https://discourse.nodered.org/t/request-for-ideas-linter-rules/45932/36 "2021-05-23T22:34:03Z")

</div>

> [@drmibell](#):
>
> Why not associate it with the flow.json file?

Not ruling that out, just not starting from that point.

A user will be able to have their own set of linting rules that are associated with the runtime via the settings file. I think it is far more common that once a user has got their preferred set of rules (that could just be the defaults we set), they want to stick with that for consistency across the projects they work on.

If they are using the Projects feature, then their linting rules could be included in the project repository - so if they have that connected to some CI system (like GitHub Actions) they could run the linter automatically whenever changes were pushed.

As I mentioned, I'm still thinking through how a rule could be disabled for a given node - a very common facility of code linters. Adding a comment to the node's info property (or the flow/subflow/group/whatever) is the best way to do that. And that would go beyond disabling rules - it would allow rules to be tweaked on a case by case basis.

How much of that customisation will be there with v1, I don't know. But we don't have to do everything on day 1.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [22 July 2021 22:34 UTC](https://discourse.nodered.org/t/request-for-ideas-linter-rules/45932/37 "2021-07-22T22:34:33Z")

</div>

Closed on 22 July 2021 22:34 UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.

[Previous page](https://discourse.nodered.org/t/request-for-ideas-linter-rules/45932.md?page=1)
