Skip to content

Commit b3b5bb2

Browse files
committed
Format files with Prettier
1 parent ad2a64f commit b3b5bb2

File tree

12 files changed

+205
-68
lines changed

12 files changed

+205
-68
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,16 @@ jobs:
3030
cache: "npm"
3131

3232
- run: npm install
33+
3334
- name: Lint
3435
run: npm run lint
3536

3637
- name: Type check
3738
run: npm run type-check
3839

40+
- name: Format check
41+
run: npm run format-check
42+
3943
- name: Setup Pages
4044
id: pages
4145
uses: actions/configure-pages@v5

.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"semi": false
3+
}

.vscode/extensions.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"recommendations": [
33
"vue.volar",
4-
"davidanson.vscode-markdownlint"
4+
"davidanson.vscode-markdownlint",
5+
"esbenp.prettier-vscode"
56
]
6-
}
7+
}

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"[vue]": {
3+
"editor.defaultFormatter": "esbenp.prettier-vscode"
4+
},
5+
"[typescript]": {
6+
"editor.defaultFormatter": "esbenp.prettier-vscode"
7+
}
8+
}

package-lock.json

Lines changed: 17 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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"build": "vite build",
99
"preview": "vite preview",
1010
"lint": "markdownlint src/pages",
11-
"type-check": "vue-tsc --build --force"
11+
"type-check": "vue-tsc --build --force",
12+
"format": "prettier --write src/**/*.ts src/**/*.vue",
13+
"format-check": "prettier --check src/**/*.ts src/**/*.vue"
1214
},
1315
"devDependencies": {
1416
"@rollup/pluginutils": "^5.1.3",
@@ -24,6 +26,7 @@
2426
"markdown-it-highlightjs": "^4.2.0",
2527
"markdown-it-replace-link": "^1.2.1",
2628
"markdownlint-cli": "^0.42.0",
29+
"prettier": "^3.3.3",
2730
"sass": "^1.81.0",
2831
"typescript": "^5.6.3",
2932
"vite": "^5.4.11",

plugins/troubleshooter/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { PageLoader, type LoaderConfig, type PageFile } from "./loader"
88
type UserOptions = LoaderConfig
99

1010
export default function TroubleshooterPlugin(
11-
userOptions: UserOptions = {}
11+
userOptions: UserOptions = {},
1212
): Plugin {
1313
const virtualModuleId = "virtual:troubleshooter"
1414

@@ -53,7 +53,7 @@ export default function TroubleshooterPlugin(
5353

5454
function makePage(file: PageFile): Page {
5555
const page: Page = {
56-
content: file.content
56+
content: file.content,
5757
}
5858
if (!isProduction) {
5959
page.filename = file.filename
@@ -65,7 +65,7 @@ export default function TroubleshooterPlugin(
6565
id: option.id,
6666
page: files.findIndex((f) => f.filename == option.page),
6767
label: option.label,
68-
summary: option.summary
68+
summary: option.summary,
6969
}))
7070
return page
7171
}
@@ -110,10 +110,10 @@ export default function TroubleshooterPlugin(
110110
code: dataToEsm(generatePages(), {
111111
compact: true,
112112
namedExports: false,
113-
preferConst: true
114-
})
113+
preferConst: true,
114+
}),
115115
}
116116
}
117-
}
117+
},
118118
}
119119
}

src/App.vue

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ function choose(option) {
2828
document.location.assign(option.hash)
2929
window.plausible("ArduinoJson Troubleshooter", {
3030
props: {
31-
hash: document.location.hash
31+
hash: document.location.hash,
3232
},
33-
});
33+
})
3434
}
3535
3636
async function copyReport() {
@@ -52,16 +52,37 @@ async function copyReport() {
5252
</p>
5353
<p>Ready? Here we go!</p>
5454
</div>
55-
<Transition v-for="step, idx in steps" :key="idx" name="fade" mode="out-in">
56-
<TroubleshooterStep :key="step.hash" :step="step" @choose="choose" :active="idx == steps.length - 1" />
55+
<Transition
56+
v-for="(step, idx) in steps"
57+
:key="idx"
58+
name="fade"
59+
mode="out-in"
60+
>
61+
<TroubleshooterStep
62+
:key="step.hash"
63+
:step="step"
64+
@choose="choose"
65+
:active="idx == steps.length - 1"
66+
/>
5767
</Transition>
5868
<div v-if="needsAssistance">
59-
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#assistance-modal">
69+
<button
70+
type="button"
71+
class="btn btn-primary"
72+
data-bs-toggle="modal"
73+
data-bs-target="#assistance-modal"
74+
>
6075
Contact support
61-
</button> <button class="btn" :class="{
62-
'btn-outline-primary': !reportCopied,
63-
'btn-success': reportCopied
64-
}" :disabled="reportCopied" @click="copyReport">
76+
</button>
77+
<button
78+
class="btn"
79+
:class="{
80+
'btn-outline-primary': !reportCopied,
81+
'btn-success': reportCopied,
82+
}"
83+
:disabled="reportCopied"
84+
@click="copyReport"
85+
>
6586
{{ reportCopied ? "✓ Report copied" : "Copy troubleshooter's report" }}
6687
</button>
6788
<AssistanceModal id="assistance-modal" :report="report" />

src/components/AssistanceModal.vue

Lines changed: 87 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { useTemplateRef } from "vue"
44
const { report } = defineProps({
55
report: {
66
type: String,
7-
required: true
8-
}
7+
required: true,
8+
},
99
})
1010
1111
const formRef = useTemplateRef("issueForm")
@@ -58,8 +58,12 @@ function createIssue() {
5858
<form class="modal-content" ref="issueForm" @submit.prevent="createIssue">
5959
<div class="modal-header bg-primary text-white">
6060
<h5 class="modal-title">Contact support</h5>
61-
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
62-
</button>
61+
<button
62+
type="button"
63+
class="btn-close"
64+
data-bs-dismiss="modal"
65+
aria-label="Close"
66+
></button>
6367
</div>
6468
<div class="modal-body">
6569
<div class="alert alert-info">
@@ -71,47 +75,103 @@ function createIssue() {
7175
</div>
7276
<div class="mb-3">
7377
<label for="title-input">Title</label>
74-
<input type="text" name="title" class="form-control" id="title-input" aria-describedby="title-help"
75-
required />
76-
<small id="title-help" class="form-text text-muted">Summarize your issue in one sentence.</small>
78+
<input
79+
type="text"
80+
name="title"
81+
class="form-control"
82+
id="title-input"
83+
aria-describedby="title-help"
84+
required
85+
/>
86+
<small id="title-help" class="form-text text-muted"
87+
>Summarize your issue in one sentence.</small
88+
>
7789
</div>
7890
<div class="mb-3">
7991
<label for="description-input">Description</label>
80-
<textarea name="description" rows="3" class="form-control" id="description-input"
81-
aria-describedby="description-help" required
82-
placeholder="When I do ..., I expect ..., but instead I get ..."></textarea>
83-
<small id="description-help" class="form-text text-muted">Describe your issue with a few sentences.</small>
92+
<textarea
93+
name="description"
94+
rows="3"
95+
class="form-control"
96+
id="description-input"
97+
aria-describedby="description-help"
98+
required
99+
placeholder="When I do ..., I expect ..., but instead I get ..."
100+
></textarea>
101+
<small id="description-help" class="form-text text-muted"
102+
>Describe your issue with a few sentences.</small
103+
>
84104
</div>
85105
<div class="mb-3">
86106
<label for="mcu-input">Microcontroller</label>
87-
<input type="text" name="mcu" class="form-control" id="mcu-input" aria-describedby="mcu-help"
88-
placeholder="ESP8266" required />
89-
<small id="mcu-help" class="form-text text-muted">Which processor or with board do you use?</small>
107+
<input
108+
type="text"
109+
name="mcu"
110+
class="form-control"
111+
id="mcu-input"
112+
aria-describedby="mcu-help"
113+
placeholder="ESP8266"
114+
required
115+
/>
116+
<small id="mcu-help" class="form-text text-muted"
117+
>Which processor or with board do you use?</small
118+
>
90119
</div>
91120
<div class="mb-3">
92121
<label for="framework-input">Arduino Core / Framework</label>
93-
<input type="text" name="framework" class="form-control" id="framework-input"
94-
aria-describedby="framework-help" placeholder="ESP8266 core for Arduino v3.0.2" />
95-
<small id="framework-help" class="form-text text-muted">Please include version number.</small>
122+
<input
123+
type="text"
124+
name="framework"
125+
class="form-control"
126+
id="framework-input"
127+
aria-describedby="framework-help"
128+
placeholder="ESP8266 core for Arduino v3.0.2"
129+
/>
130+
<small id="framework-help" class="form-text text-muted"
131+
>Please include version number.</small
132+
>
96133
</div>
97134
<div class="mb-3">
98135
<label for="ide-input">IDE</label>
99-
<input type="text" name="ide" class="form-control" id="ide-input" aria-describedby="ide-help"
100-
placeholder="Arduino IDE 1.8.16" />
101-
<small id="ide-help" class="form-text text-muted">Please include version number.</small>
136+
<input
137+
type="text"
138+
name="ide"
139+
class="form-control"
140+
id="ide-input"
141+
aria-describedby="ide-help"
142+
placeholder="Arduino IDE 1.8.16"
143+
/>
144+
<small id="ide-help" class="form-text text-muted"
145+
>Please include version number.</small
146+
>
102147
</div>
103148
<div class="mb-3">
104149
<label for="repro-input">Reproduction code</label>
105-
<textarea name="repro" rows="10" class="form-control text-monospace" style="font-size: 80%" id="repro-input"
106-
aria-describedby="repro-help" placeholder="DynamicJsonDocuemnt doc(1024);\n..."></textarea>
107-
<small id="repro-help" class="form-text text-muted">Write a few lines of code that demonstrate the
108-
issue.</small>
150+
<textarea
151+
name="repro"
152+
rows="10"
153+
class="form-control text-monospace"
154+
style="font-size: 80%"
155+
id="repro-input"
156+
aria-describedby="repro-help"
157+
placeholder="DynamicJsonDocuemnt doc(1024);\n..."
158+
></textarea>
159+
<small id="repro-help" class="form-text text-muted"
160+
>Write a few lines of code that demonstrate the issue.</small
161+
>
109162
</div>
110163
<div class="mb-3">
111164
<label for="remarks-input">Remarks</label>
112-
<textarea name="remarks" rows="4" class="form-control" id="remarks-input"
113-
aria-describedby="remarks-help"></textarea>
114-
<small id="remarks-help" class="form-text text-muted">Anything else you need to tell us?</small>
165+
<textarea
166+
name="remarks"
167+
rows="4"
168+
class="form-control"
169+
id="remarks-input"
170+
aria-describedby="remarks-help"
171+
></textarea>
172+
<small id="remarks-help" class="form-text text-muted"
173+
>Anything else you need to tell us?</small
174+
>
115175
</div>
116176
</div>
117177
<div class="modal-footer">

0 commit comments

Comments
 (0)