1
nururururu
313d

In comes the new developer messing the repository with unreadable two space indentation in our backend codebase. I can understand it being useful to keep code within the horizontal editor "viewport" for stuff like JSX, but otherwise it's really fucking ugly and feels like the code is not indented at all

We're not using any tools for automatically standardizing code style yet, what do you recommend? If it's at all relevant, our codebase is in TypeScript.

Comments
  • 2
    Use such tools. Set up a set of rules in the IDE, check them in into the repo and you can always hit reformat code an be happy. It's not like 1982 anymore.
  • 2
    depends.

    eslint makes most sense.

    Though I'd recommend looking at e.g. editorconfig / checkstyle or similar alternatives to define a cross language configuration.

    It will make stuff easier long-term.
  • 1
    I get yelled at for using 8 space indents in private projects because people apparently can't use their arrow keys anymore, so I've got the same problem in the other direction. I usually solve it by changing it to 8 \t's per indent, and let their editor handle it. it's no longer my problem.
  • 1
    I keep forgetting that this is one of the major things I love about Go. We use tabs. As in the actual tab character. The thing that was designed for indentation. It's always consistent and everyone can set the width to their liking. I honestly don't know why the fuck every language changed to this multiple spaces bullshit. Back in the C days tabs where way more common.

    Also Go comes with a build-in formatter so it's super easy to correct and reject wrongly formatted code.
  • 1
    For formatting TS you can use "prettier"
    We have it set up as an error in the PR on violation so it can never be merged.
    For GitHub you can use https://github.com/marketplace/...

    We use gitlab so need to integrate it differently but it's all fairly simple.
  • 0
    Get those precommit hooks running. And whenever possible in a language: enforce tabs instead of spaces since those are easily configurable inside IDEs as mentioned before.
Add Comment