Skip to content

Commit 15ffb6b

Browse files
authored
Format also .svelte files with prettier (#35)
1 parent f0f77fa commit 15ffb6b

File tree

7 files changed

+276
-8
lines changed

7 files changed

+276
-8
lines changed

.github/workflows/format.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ jobs:
1414
node-version: "18"
1515
- name: Check formatting
1616
run: |
17-
npm i -g prettier
18-
prettier . --check
17+
npm ci
18+
npm run format:check
1919
pycodestyle:
2020
runs-on: ubuntu-latest
2121
steps:

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
node_modules/
2+
out
13
__pycache__
24
*.pyc
35
server.db
4-
out
56

67
.terraform*
78
terraform.tfstate*

.prettierrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"plugins": ["prettier-plugin-svelte"],
3+
"overrides": [
4+
{
5+
"files": "*.svelte",
6+
"options": {
7+
"parser": "svelte"
8+
}
9+
}
10+
]
11+
}

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,18 @@ tofu fmt -check -recursive
4040

4141
This repository uses [Prettier](https://prettier.io/) to format code with its default settings.
4242

43-
To install Prettier, ensure you have Nodejs and npm installed and run `sudo npm i -g prettier`. This install prettier globally to your system.
43+
To install Prettier, ensure you have Nodejs and npm installed and run `npm ci`. This installs prettier to `node_modules` in this directory.
4444

4545
Format code by running:
4646

4747
```sh
48-
prettier . --write
48+
npm run format
4949
```
5050

5151
Check formatting by running:
5252

5353
```sh
54-
prettier . --check
54+
npm run format:check
5555
```
5656

5757
## Run acceptance tests

front-end/src/lib/BarChart.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@
1313
{#each choices as choice}
1414
<div class="row" title={choice.title}>
1515
<span>{choice.label}</span>
16-
<div class="bar" style="width: {summary.values[String(choice.value)] / summary.count_non_null * 100}%"
17-
></div>
16+
<div
17+
class="bar"
18+
style="width: {(summary.values[String(choice.value)] /
19+
summary.count_non_null) *
20+
100}%"
21+
></div>
1822
<span>{summary.values[String(choice.value)]}</span>
1923
</div>
2024
{/each}

package-lock.json

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

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"scripts": {
3+
"format": "prettier --write .",
4+
"format:check": "prettier --check ."
5+
},
6+
"devDependencies": {
7+
"prettier": "^3.5.3",
8+
"prettier-plugin-svelte": "^3.3.3"
9+
}
10+
}

0 commit comments

Comments
 (0)