Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
msdsk31793y
-
Well, two-space indents but also spaces padding parentheses and brackets.
His eval addiction certainly is just another symptom of a way bigger problem... -
@Oktokolo agreeing with everything except two-space indentation (come on, just have consistency across certain codebase - lile it or not, but IDE can handle it).
-
@msdsk BTW: The JS file where I took this snippet from contained 50% PHP, but at this point nothing can shock me anymore. 😄
-
@vintprox
It wasn't about two-space indents - but two-space indents combined with space-padded parenthesis and brackets.
Go for low amounts of non-syntax whitespace or high amounts - but not both at the same time. -
@Oktokolo true that. Never understood why people decorate code with long ass-spaced comments, for example, but don't automate the formatting.
-
@vintprox
Even using JetBrains IDEs i never found auto-formatting configurable enough to not get in the way too often.
The formatting is for making the code more human-redable.
It therefore has to be adjustable by humans.
Auto-reformatting entire blocks of code definitely is an option for real dirty code at the start of major refactoring tasks though. -
@Oktokolo I'd entrust this task to language server that was designed solely for formatting (like Prettier) instead of IDE. Not only because IDE may limit the options galore, but also because command line interface is most compatible with VCS tooling, which ensures that garbage doesn't slip into commit regardless of editor.
-
@vintprox
Wow, did not expect such a thing to even exist. I honestly never thought about formatting code as an extra step - i just write my code in the correct format.
But i definitely see the use of such a tool for large-scale projects and as the first action when starting the refactoring of a rotten code base... -
@Oktokolo Oh... but there is more!
What's extra neat in this is that boilerplate generators for small and big plugins can utilize this same tooling (which takes into consideration a formatter configuration of project) - to generate code valid for your dev needs from the get-go.
One of good examples would be:
- to start a SvelteKit project,
- then configure Prettier to your liking (don't like tabs/spaces? easy-squeazy switch),
- then use adders/addons/plugins like https://github.com/svelte-add/... that put the additional boilerplate through Prettier.
It's just the workflow that I'm not feeling ashamed of to present to any novice or pro. It's just that considerate. -
@vintprox
I am running a strict no boilerplates policy.
If a lib needs boilerplates for regular use, it gets wrapped in a convenience layer that eliminates that need.
I am also somewhat against code generators - but am also not drawing UML before starting to code (making the one use case where code generation really shines not happen in my workflow).
Code generators tend to generate the most ugly code by default and normally don't feature full style customization though.
So i definitely see the benefit of automatic format sanitization in that use cases. -
@Oktokolo I'm talking more about configuration files for according frameworks - it is simply convenient to have those instead of one bloated file (oh TFW someone dirties package.json with their nasty inflexible configs).
I agree, one shouldn't be turning a blind eye on any new files and embrace some separation. -
I once worked on a project where they tortured Camunda, a BPMN software, to perform routing, make API calls to microservices and things way worse than that.
It wasn't built for any of this. They even repurposed some blocks to allow developers to write "server side JavaScript".
They'd export the BPMN diagram in an XML file and run a string eval on all those fields.
I've never seen a solution so frightening yet impressive -
lotd79223yI have "legacy SPA" apps where js uses XMLHttpRequest to post at Ajax.php for some raw JS to run with eval.
Usually some jQuery Dom mutations.
Developers who use JavaScript "eval(...)" deserve a normal place in hell.
Developers who use JavaScript eval() within eval() deserve the most special place in hell. 🔥
rant
legacy shit
javascript
eval