jagenjo / litegraph.js

A graph node engine and editor written in Javascript similar to PD or UDK Blueprints, comes with its own editor in HTML5 Canvas2D. The engine can run client side or server side using Node. It allows to export graphs as JSONs to be included in applications independently.
MIT License
5.32k stars 602 forks source link

Eslint and/or prettier run #429

Open dotJack opened 6 months ago

dotJack commented 6 months ago

I am running into some issues with inconsistent styling and would like to request that the recommended eslint / prettier formatting is done on the whole project. I don't really have a preference as to which format / style is used and I leave that up to the maintainer. I can change my workflow to accommodate any consistent style. I don't want to step on any toes but it makes sense to me to have the whole project saved in the same styling, whatever that styling may be.

Since I don't know what your editor's rules are, I'd like to request that the js files get a 'Format Document' or 'Format Document With' and one of the suggested vs code extension implementations run on them.

If there's some specific styling preference that parts of the code are formatted in one way and other parts are formatted in a specific but different way, then it's fine and you can close this issue.

Personally, it's a lot of mental overhead to manually align the mixed use of only tabs, only spaces and tabs and spaces since I rely on formatting for readability, ease of development and staying in flow.

Again, if it's some specific reasoning and it's just a hassle to deal with this, feel free to close this issue. <3

jagenjo commented 6 months ago

Hi Jack:

I always had my own styling but it was pretty flexible. But some years ago one user did a PR with a full linting of the code and I accepted it because I thought it could make it more coherent, but the truth is that the ruleset applied made the code way less readable so I decided to reformat it manually in some parts, I guess thats the problem with the current ruleset.

But feel free to lint it and do a PR, Im always willing to check it, I lack the experience you have probably.

0xdevalias commented 5 months ago

In the JS-world of things, prettier is fairly standard, and there are a few little things that can be tweaked within it to align closer to desired standards:


From a quick skim of the issues, I think this may have been where the 'undesired style changes' were previously mentioned:

Hey @NateScarlet just wanted to thank you for your help, it is nice that somebody besides me pushes this project, but please, do not launch the process that "beauytifies" the code again, most of the changes are against my way of working, specially one line ifs, and ifs where the condition touches the parenthesis.

My eye-sight is not so good and having all cramped in one line makes it hard for me to read it. Can that be configured somehow? otherwise I have to go line by line fixing it.

Originally posted by @jagenjo in https://github.com/jagenjo/litegraph.js/issues/68#issuecomment-488628639

per https://github.com/prettier/prettier/issues/4125 it seems bracket is needed to avoid single line if by prettier but eslint seems has a rule match your need: https://eslint.org/docs/rules/curly i will try configure it with eslint

Originally posted by @NateScarlet in https://github.com/jagenjo/litegraph.js/issues/68#issuecomment-488632574


Related: