Skip to content

Commit 4fcdb0f

Browse files
committed
prettier config
[Prettier][1] is an up-to date code formatter for JavaScript ecosystem. For settings we rely on [EditorConfig][2] for things like tab style and size (with added bonus that the code editor with an EditorConfig plugin does some automated code formatting on file save for you). Unfortunately, Prettier's Glob handling isn't great: 1. `*.{ts,js,json}` has no effect 2. Similarly, in a list of globs `*.ts,*.js,*.json` only the first glob has an effect, the rest are ignored. That's why the file looks the way it does. The only other setting we change is line width. [Lukas][3] suggested we use 100 instead of 80, because that's what Rustfmt is using. [1]: https://prettier.io [2]: https://editorconfig.org [3]: https://github.com/Veykril
1 parent 7e95c14 commit 4fcdb0f

File tree

6 files changed

+72
-0
lines changed

6 files changed

+72
-0
lines changed

.editorconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# https://EditorConfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
trim_trailing_whitespace = true
7+
end_of_line = lf
8+
insert_final_newline = true
9+
indent_style = space
10+
11+
[*.{rs,toml}]
12+
indent_size = 4
13+
14+
[*.ts]
15+
indent_size = 4
16+
[*.js]
17+
indent_size = 4
18+
[*.json]
19+
indent_size = 4

editors/code/.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module.exports = {
33
"es6": true,
44
"node": true
55
},
6+
"extends": ["prettier"],
67
"parser": "@typescript-eslint/parser",
78
"parserOptions": {
89
"project": "tsconfig.eslint.json",

editors/code/.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
.vscode-test
3+
out

editors/code/.prettierrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
// use 100 because it's Rustfmt's default
3+
// https://rust-lang.github.io/rustfmt/?version=v1.4.38&search=#max_width
4+
printWidth: 100,
5+
};

editors/code/package-lock.json

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

editors/code/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
"cross-env": "^7.0.3",
4949
"esbuild": "^0.14.27",
5050
"eslint": "^8.11.0",
51+
"eslint-config-prettier": "^8.5.0",
52+
"prettier": "^2.6.2",
5153
"tslib": "^2.3.0",
5254
"typescript": "^4.6.3",
5355
"typescript-formatter": "^7.2.2",

0 commit comments

Comments
 (0)