TUfast_TUD icon indicating copy to clipboard operation
TUfast_TUD copied to clipboard

Consistent code style

Open A-K-O-R-A opened this issue 5 months ago • 6 comments

I would like to suggest specifying the code style of this repository by using a consistent fromatter like Prettier which will enforce the same indentation rules for every file. This would make it easier for new contributors to not mess with the existing code formatting and will also highlight issues like orphaned closing tags in HTML files.

A-K-O-R-A avatar Jan 16 '24 13:01 A-K-O-R-A

Yes, I agree. It is good to have consistent formatting.

When I started the repo I only used ESLint. I am somewhat aware that this is not the same. Should we remove ESlint specifications then, or is it safe / recommended to have both?

@C0ntroller

OliEfr avatar Jan 16 '24 14:01 OliEfr

I think it would still be useful to keep ESLint with the rules you already defined. Depending on what rules are specified and what formatter is used there can be conflicts between the two. In the case of prettier there is a ESLint plugin called eslint-config-prettier that resolves those conflicts.

A-K-O-R-A avatar Jan 16 '24 15:01 A-K-O-R-A

Well, I'm a bit torn on this. There are arguments for both sides.

With eslint we currently have styling hints for the typescript. And the other file-types - html and vue - are not edited often. Also, in my experience, it makes it harder for beginners to contribute as it is an additional thing which need to be considered before contributing.

When enforcing code style, prettier seems to be a better choice. ~~But I don't think having eslint and prettiert is a good solution (even if it works). It should just be one. Having multiple formatters is just confusing.~~

C0ntroller avatar Jan 18 '24 13:01 C0ntroller

I am pro prettier because a consistent code style is more professional and its good for anyone to learn to use a prettier. We need to make sure to include a proper description of how to use it in the CONTRIBUTING.md file.

Linter and prettier also have distinct functionalities, and from what I've seen after googling they can and, in most cases should, be used together. Actually, most sources recommend using eslint-config-pretties: source 1 source 2 source 3 source 4

OliEfr avatar Jan 18 '24 15:01 OliEfr

You are right. Stuff like unused vars cannot be caught by prettier. So both then?

C0ntroller avatar Jan 18 '24 15:01 C0ntroller

#135

OliEfr avatar Jan 24 '24 17:01 OliEfr