Skip to content

Commit 2a8932a

Browse files
authored
Merge pull request #37 from tweedegolf/check-fmt
Check formatting
2 parents b7f9c11 + e9db4df commit 2a8932a

21 files changed

+195
-124
lines changed

.github/workflows/check.yml

+10
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,22 @@ jobs:
3434
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84
3535
with:
3636
shared-key: "check"
37+
cache-all-crates: true # Also cache taplo-cli
38+
- name: Install tools
39+
run: cargo install taplo-cli --locked
3740
- name: Clippy
3841
run: cargo clippy --locked --all-targets --all-features --workspace -- -Dwarnings
3942
- name: Test rust
4043
run: cargo test --locked
4144
- name: Check rust formatting
4245
run: cargo fmt --all --check
46+
- name: Check frontend formatting
47+
run: npm run fmt-check
48+
working-directory: frontend
49+
- name: Check driver-db syntax
50+
run: taplo check driver-db/*.toml
51+
- name: Check driver-db formatting
52+
run: taplo fmt --check --diff
4353
- name: Download db-dump
4454
run: wget --no-verbose https://static.crates.io/db-dump.tar.gz
4555
- name: Build database

.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/*
2+
3+
!frontend/

.taplo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include = [".taplo.toml", "driver-db/*.toml"]
2+
3+
[formatting]
4+
indent_string = " "

.vscode/extensions.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"recommendations": [
3+
"svelte.svelte-vscode",
4+
"esbenp.prettier-vscode",
5+
"rust-lang.rust-analyzer",
6+
"tamasfe.even-better-toml"
7+
]
8+
}

driver-db/ad57xx.toml

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#:schema ../schema.json
21
manifest_version = "0.0.1"
32

43
[meta]

driver-db/lsm303agr.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ packages = ["LGA-14"]
1313
[dev_boards]
1414
adafruit = 4413
1515
mikroe = 2684
16-
other = [{ name = "BBC micro:bit v2", link = "https://tech.microbit.org/hardware/" }]
16+
other = [
17+
{ name = "BBC micro:bit v2", link = "https://tech.microbit.org/hardware/" },
18+
]
1719

1820
[interfaces.i2c]
1921
addrs = [0x1E, 0x1D]

frontend/.prettierignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package-lock.json
2+
.vite/
3+
.vscode/
4+
dist/
5+
README.md

frontend/.vscode

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../.vscode

frontend/.vscode/extensions.json

-3
This file was deleted.

frontend/README.md

+22-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ This template should help get you started developing with Svelte and TypeScript
88

99
## Need an official Svelte framework?
1010

11-
Check out [SvelteKit](https://github.com/sveltejs/kit#readme), which is also powered by Vite. Deploy anywhere with its serverless-first approach and adapt to various platforms, with out of the box support for TypeScript, SCSS, and Less, and easily-added support for mdsvex, GraphQL, PostCSS, Tailwind CSS, and more.
11+
Check out [SvelteKit](https://github.com/sveltejs/kit#readme), which is also powered by Vite. Deploy anywhere with its
12+
serverless-first approach and adapt to various platforms, with out of the box support for TypeScript, SCSS, and Less,
13+
and easily-added support for mdsvex, GraphQL, PostCSS, Tailwind CSS, and more.
1214

1315
## Technical considerations
1416

@@ -17,27 +19,39 @@ Check out [SvelteKit](https://github.com/sveltejs/kit#readme), which is also pow
1719
- It brings its own routing solution which might not be preferable for some users.
1820
- It is first and foremost a framework that just happens to use Vite under the hood, not a Vite app.
1921

20-
This template contains as little as possible to get started with Vite + TypeScript + Svelte, while taking into account the developer experience with regards to HMR and intellisense. It demonstrates capabilities on par with the other `create-vite` templates and is a good starting point for beginners dipping their toes into a Vite + Svelte project.
22+
This template contains as little as possible to get started with Vite + TypeScript + Svelte, while taking into account
23+
the developer experience with regards to HMR and intellisense. It demonstrates capabilities on par with the other
24+
`create-vite` templates and is a good starting point for beginners dipping their toes into a Vite + Svelte project.
2125

22-
Should you later need the extended capabilities and extensibility provided by SvelteKit, the template has been structured similarly to SvelteKit so that it is easy to migrate.
26+
Should you later need the extended capabilities and extensibility provided by SvelteKit, the template has been
27+
structured similarly to SvelteKit so that it is easy to migrate.
2328

2429
**Why `global.d.ts` instead of `compilerOptions.types` inside `jsconfig.json` or `tsconfig.json`?**
2530

26-
Setting `compilerOptions.types` shuts out all other types not explicitly listed in the configuration. Using triple-slash references keeps the default TypeScript setting of accepting type information from the entire workspace, while also adding `svelte` and `vite/client` type information.
31+
Setting `compilerOptions.types` shuts out all other types not explicitly listed in the configuration. Using triple-slash
32+
references keeps the default TypeScript setting of accepting type information from the entire workspace, while also
33+
adding `svelte` and `vite/client` type information.
2734

2835
**Why include `.vscode/extensions.json`?**
2936

30-
Other templates indirectly recommend extensions via the README, but this file allows VS Code to prompt the user to install the recommended extension upon opening the project.
37+
Other templates indirectly recommend extensions via the README, but this file allows VS Code to prompt the user to
38+
install the recommended extension upon opening the project.
3139

3240
**Why enable `allowJs` in the TS template?**
3341

34-
While `allowJs: false` would indeed prevent the use of `.js` files in the project, it does not prevent the use of JavaScript syntax in `.svelte` files. In addition, it would force `checkJs: false`, bringing the worst of both worlds: not being able to guarantee the entire codebase is TypeScript, and also having worse typechecking for the existing JavaScript. In addition, there are valid use cases in which a mixed codebase may be relevant.
42+
While `allowJs: false` would indeed prevent the use of `.js` files in the project, it does not prevent the use of
43+
JavaScript syntax in `.svelte` files. In addition, it would force `checkJs: false`, bringing the worst of both worlds:
44+
not being able to guarantee the entire codebase is TypeScript, and also having worse typechecking for the existing
45+
JavaScript. In addition, there are valid use cases in which a mixed codebase may be relevant.
3546

3647
**Why is HMR not preserving my local component state?**
3748

38-
HMR state preservation comes with a number of gotchas! It has been disabled by default in both `svelte-hmr` and `@sveltejs/vite-plugin-svelte` due to its often surprising behavior. You can read the details [here](https://github.com/rixo/svelte-hmr#svelte-hmr).
49+
HMR state preservation comes with a number of gotchas! It has been disabled by default in both `svelte-hmr` and
50+
`@sveltejs/vite-plugin-svelte` due to its often surprising behavior. You can read the
51+
details [here](https://github.com/rixo/svelte-hmr#svelte-hmr).
3952

40-
If you have state that's important to retain within a component, consider creating an external store which would not be replaced by HMR.
53+
If you have state that's important to retain within a component, consider creating an external store which would not be
54+
replaced by HMR.
4155

4256
```ts
4357
// store.ts

frontend/index.html

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<!doctype html>
22
<html lang="en">
3-
<head>
4-
<meta charset="UTF-8"/>
5-
<link rel="icon" type="image/svg+xml" href="src/logo.svg"/>
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="src/logo.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>Rust Drivers</title>
8-
</head>
9-
<body>
10-
<div id="app"></div>
11-
<script type="module" src="/src/main.ts"></script>
12-
</body>
8+
</head>
9+
<body>
10+
<div id="app"></div>
11+
<script type="module" src="/src/main.ts"></script>
12+
</body>
1313
</html>

frontend/package-lock.json

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"dev": "vite",
88
"build": "vite build",
99
"preview": "vite preview",
10-
"check": "svelte-check --tsconfig ./tsconfig.json"
10+
"check": "svelte-check --tsconfig ./tsconfig.json",
11+
"fmt": "prettier --write .",
12+
"fmt-check": "prettier --check ."
1113
},
1214
"devDependencies": {
1315
"@sveltejs/vite-plugin-svelte": "^3.1.2",
@@ -16,8 +18,8 @@
1618
"svelte-check": "^3.6.7",
1719
"tslib": "^2.6.2",
1820
"typescript": "^5.2.2",
19-
"vite": "^5.4.2"
21+
"vite": "^5.4.2",
22+
"prettier": "^3.3.3"
2023
},
21-
"dependencies": {
22-
}
24+
"dependencies": {}
2325
}

frontend/src/app.css

+13-14
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@
3838
html {
3939
box-sizing: border-box;
4040
font-size: 16px;
41-
min-width: 454px
41+
min-width: 454px;
4242
}
4343

44-
*, *:before, *:after {
45-
box-sizing: inherit
44+
*,
45+
*:before,
46+
*:after {
47+
box-sizing: inherit;
4648
}
4749

4850
a {
@@ -52,7 +54,7 @@ a {
5254
}
5355

5456
a:hover {
55-
color: var(--color-secondary)
57+
color: var(--color-secondary);
5658
}
5759

5860
body {
@@ -85,15 +87,15 @@ main {
8587
align-items: flex-start;
8688
}
8789

88-
8990
table {
9091
flex: 1;
9192
width: 100%;
9293
border-collapse: collapse;
9394
height: auto;
9495
}
9596

96-
th, td {
97+
th,
98+
td {
9799
border: none;
98100
padding: 0.5rem;
99101
}
@@ -126,16 +128,16 @@ fieldset {
126128
background-color: var(--color-background-secondary);
127129
}
128130

129-
input[type=text] {
131+
input[type="text"] {
130132
border: 1px solid var(--color-border);
131133
width: 100%;
132134
font-size: 1rem;
133135
padding: 0.25rem;
134136
outline-color: var(--color-primary);
135137
}
136138

137-
input[type=checkbox] {
138-
margin: 0 0.25rem 0 0 ;
139+
input[type="checkbox"] {
140+
margin: 0 0.25rem 0 0;
139141
vertical-align: middle;
140142
}
141143

@@ -152,9 +154,7 @@ label {
152154
}
153155

154156
.filter {
155-
156157
.filter-box {
157-
158158
display: flex;
159159
flex-direction: row;
160160
align-items: center;
@@ -229,13 +229,13 @@ label {
229229

230230
&.sorted.asc {
231231
&::after {
232-
content: '↑';
232+
content: "↑";
233233
}
234234
}
235235

236236
&.sorted.desc {
237237
&::after {
238-
content: '↓';
238+
content: "↓";
239239
}
240240
}
241241
}
@@ -266,7 +266,6 @@ label {
266266
}
267267

268268
&.open {
269-
270269
.filter-box {
271270
border-bottom: 0px;
272271
padding-bottom: 1.5rem;

0 commit comments

Comments
 (0)