We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 701626c commit c94db33Copy full SHA for c94db33
.changeset/pretty-emus-breathe.md
@@ -0,0 +1,5 @@
1
+---
2
+'sv': patch
3
4
+
5
+fix: warn on an unparsable `.prettierrc` config file
packages/addons/prettier/index.ts
@@ -24,7 +24,15 @@ export default defineAddon({
24
});
25
26
sv.file('.prettierrc', (content) => {
27
- const { data, generateCode } = parseJson(content);
+ let data, generateCode;
28
+ try {
29
+ ({ data, generateCode } = parseJson(content));
30
+ } catch {
31
+ log.warn(
32
+ `A ${colors.yellow('.prettierrc')} config already exists and cannot be parsed as JSON. Skipping initialization.`
33
+ );
34
+ return content;
35
+ }
36
if (Object.keys(data).length === 0) {
37
// we'll only set these defaults if there is no pre-existing config
38
data.useTabs = true;
0 commit comments