File tree 4 files changed +41
-2
lines changed
4 files changed +41
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " prettier-eslint " : minor
3
+ ---
4
+
5
+ feat: support handling ` .svelte ` files
Original file line number Diff line number Diff line change 20
20
" JounQin (https://www.1stG.me) <[email protected] >"
21
21
],
22
22
"license" : " MIT" ,
23
+ "peerDependencies" : {
24
+ "prettier-plugin-svelte" : " ^3.0.0" ,
25
+ "svelte-eslint-parser" : " *"
26
+ },
27
+ "peerDependenciesMeta" : {
28
+ "prettier-plugin-svelte" : {
29
+ "optional" : true
30
+ },
31
+ "svelte-eslint-parser" : {
32
+ "optional" : true
33
+ }
34
+ },
23
35
"dependencies" : {
24
36
"@typescript-eslint/parser" : " ^6.7.5" ,
25
37
"common-tags" : " ^1.4.0" ,
49
61
"nps" : " ^5.7.1" ,
50
62
"nps-utils" : " ^1.3.0" ,
51
63
"prettier-eslint-cli" : " ^8.0.0" ,
64
+ "prettier-plugin-svelte" : " ^3.1.2" ,
52
65
"rimraf" : " ^5.0.5" ,
53
- "strip-indent" : " ^3.0.0"
66
+ "strip-indent" : " ^3.0.0" ,
67
+ "svelte" : " ^4.2.9" ,
68
+ "svelte-eslint-parser" : " ^0.33.1"
54
69
},
55
70
"engines" : {
56
71
"node" : " >=16.10.0"
Original file line number Diff line number Diff line change @@ -193,6 +193,19 @@ const tests = [
193
193
output :
194
194
'<template>\n <div></div>\n</template>\n<script>\nfunction foo () {\n return "foo";\n}\n</script>\n<style></style>'
195
195
} ,
196
+ {
197
+ title : 'Svelte example' ,
198
+ input : {
199
+ prettierOptions : {
200
+ plugins : [ 'prettier-plugin-svelte' ] ,
201
+ overrides : [ { files : '*.svelte' , options : { parser : 'svelte' } } ]
202
+ } ,
203
+ text : '<script>\nfunction foo() { return "foo" }\n</script>\n <div>test</div>\n<style>\n</style>' ,
204
+ filePath : path . resolve ( './test.svelte' )
205
+ } ,
206
+ output :
207
+ '<script>\n function foo() {\n return "foo";\n }\n</script>\n\n<div>test</div>\n\n<style>\n</style>'
208
+ } ,
196
209
{
197
210
title : 'GraphQL example' ,
198
211
input : {
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ async function format(options) {
56
56
* `r.output` is the formatted string and `r.messages` is an array of
57
57
* message specifications from eslint.
58
58
*/
59
+ // eslint-disable-next-line complexity
59
60
async function analyze ( options ) {
60
61
const { logLevel = getDefaultLogLevel ( ) } = options ;
61
62
logger . setLevel ( logLevel ) ;
@@ -112,7 +113,8 @@ async function analyze(options) {
112
113
'.ts' ,
113
114
'.tsx' ,
114
115
'.mjs' ,
115
- '.vue'
116
+ '.vue' ,
117
+ '.svelte'
116
118
] ;
117
119
const fileExtension = path . extname ( filePath || '' ) ;
118
120
@@ -138,6 +140,10 @@ async function analyze(options) {
138
140
formattingOptions . eslint . parser ||= require . resolve ( 'vue-eslint-parser' ) ;
139
141
}
140
142
143
+ if ( [ '.svelte' ] . includes ( fileExtension ) ) {
144
+ formattingOptions . eslint . parser ||= require . resolve ( 'svelte-eslint-parser' ) ;
145
+ }
146
+
141
147
const eslintFix = await createEslintFix ( formattingOptions . eslint , eslintPath ) ;
142
148
143
149
if ( prettierLast ) {
You can’t perform that action at this time.
0 commit comments