I have met linters and formatters before. It was terrible.
Prettier
In one of projects I worked on prettier was a requirement that wouldn't let you commit unless it says your formatting is okay. Sounds reasonable, however it wasn't a great experience.
Rant incoming
Just imagine. You're okay, you're contributing, figuring things out, being useful. You're ready to save your changes and send them to git, but..! Oh no...
FEAR. PANIC. CONFUSION.
How did I fuck everything up to make SO MANY errors? What does it even want? What is that left/right arrow sign?
Yea, sure, now I know it didn't like my tabs, or spaces, or other small things... The problem I still have with prettier is how the project has its own style[1]. Your IDE has its own style[2]. And you install prettier (cause apparently that's what you gotta do..) and not it also has its own style[3]! There's a settings for your VSCode, there's a config for prettier, and in the end, if the project checks your formatting before commiting, why doesn't it fix it up to its standard itself? It was a pain figuring out how many spaces a project wants. Was it because I didn't know what I was doing? Sure. But do formatting rules have to be so much pain?
Rant over
Anyway, prettier is a very important tool for programmers from different backgrounds and with different tastes to come together and be able to understand each other without being triggered. At least with prettier they can be mad at prettier, not at each other's bracket style.
ESLint
I understand what a linter does in theory, however in practice I am unsure. It's supposed to point out questionable things in your code, which I feel like an IDE already does. Perhaps it just has a higher standard. It seems to make sense to use one, I just haven't seen it be useful yet.
Specific settings
I first tried to set strict rules, so that I can always be sure it's consistent, however I then realised it will bring more pain than good. Mostly to myself. Because whenever I have those errors, I'm not sure why exactly. And when I have a rule that I set up that I don't like, I'm not sure how to change it.
I will list some of my formatting decisions I will always go for if I have to enforce it.
I know for sure I want to have double quotes for strings, since it makes sense from C. Single quotes are for single characters 'q'
, while double quotes are for character strings, which means multiple characters "string"
. Makes sense, right? Single quotes - single letter.
I have decided to choose Linux line endings wherever I can, just because CRLF
is more long than LF
and because usually Linux people are more mad at Windows people rather than the other way around.
And IDK why, but I want to have 4 tab width instead of 2.
Experience
I keep feeling like extra fancy rules, formatters, scripts make it really challenging to contribute for noobs such as myself. I understand how it is necessairy for a large project, however I would always choose to go without them if possible.
I have also noticed I prefer to run my tools through the command line, rather than setting up an auto save fix. It gives more control when I feel unsure about my settings I have set up. As a contributor however, auto save formatting seems best once you figure out specific rules the project uses.
Top comments (0)