3 ms·
I think the benefits of linting are similar to writing tests. Initially the practice is detestable, especially if you've already developed some hard-fought cod
by shuckster 6y ago
I think the benefits of linting are similar to writing tests.
Initially the practice is detestable, especially if you've already developed some hard-fought coding chops without them. But after some time the practice itself influences your ability to write better code to start with, and successive tests become terser and more useful.
I think the same is true for linting. I found being involved in projects that enforce linting rules on commit to be insufferable, so I installed Prettier and configured it to format on save. Over time the auto-formatter did less because of the habits I was picking up.
I did have to confront the idea of being less precious and attached to my own coding-style, but frankly I still have pretty strong opinions despite having an automaton do my thinking for me in some of the projects I work on.
Of course, neither tests nor linting are a panacea, but so long as you give a hoot to start with you won't be able to avoid writing better code after using them.
- 11010010001101 6y ago> Over time the auto-formatter did less because of the habits I was picking up. Indeed, making you more robot for "how things should be done". Just one example: I like my code to be readable, and one of the things I apply for that is the use of white space. Between my functions/methods I have at least 3 lines of white space. It's a lie that this is not "how things should be done", and there is no way to tell prettier to accept that because it is meant to be opinionated. These tools have a place for some teams and junior devs, but I try to stay away from the ugly code it spits out.
- shuckster 6y agoGood point on teams, but I'm not convinced that linting is a great tool for juniors in the same way. Frustration is an instrument for learning, but adhering to linting rules forces that energy in the wrong direction for those still going through the basics. On the point of being a robot, in what way are we not already "robots" by stubbornly sticking to what we think of as best? Are you not already a robot by limiting yourself to a narrow-range of what you consider "readable"? I also find it annoying to occasionally lose white-space to Prettier. But I've learned my way around it: By either adding short comments or by decomposing single-lines into multiple ones, which ends up improving readability anyway.