Set up a code formatter
- Dominant language
- Pug
- Stars
- 9
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
In my opinion, there are too many extra whitespaces and long lines in our code.
Maybe we should set up a code formatter like [Prettier](https://prettier.io/docs/en/install.html).
Prettier also integrates well with eslint: https://prettier.io/docs/en/install.html#eslint-and-other-linters
It can take over some of it's rules and do it better.
Prettier has a [configuration option](https://prettier.io/docs/en/options.html), that does not match any eslint rules.
### printWidth
Specify the line length that the printer will wrap on.
With eslint we used 100 for max-len, but unlike in eslint this option is not a hard limit. Prettier might make a bit longer lines than this.
In my opinion, we should go with the default value, which is 80.
### trailingComma
> Print trailing commas wherever possible in multi-line comma-separated syntactic structures. (A single-line array, for example, never gets trailing commas.)
> Valid options:
>
> - "es5" - Trailing commas where valid in ES5 (objects, arrays, etc.). No trailing commas in type parameters in TypeScript.
> - "none" - No trailing commas.
> - "all" - Trailing commas wherever possible (including function parameters and calls). To run, JavaScript code formatted this way needs an engine that supports ES2017 (Node.js 8+ or a modern browser) or downlevel compilation. This also enables trailing commas in type parameters in TypeScript (supported since TypeScript 2.7 released in January 2018).
Currently, we are using no commas.
Because of this when we append a new property to a multi-line structure, a line change will occur in the upper line.
```diff
const obj = {
- foo: 'bar'
+ foo: 'bar',
+ bar: 'foo'
}
```
This makes the git changelog bloated.
We are probably not using trailing commas because the JSON format does not support it, however, JSON was designed for data transfer and code.
Currently, we are using no commas, but I think we should switch to "es5" to avoid line changes.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.