File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
packages/eslint-plugin-svelte/src/utils Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ function getSvelteVersion(filePath: string): SvelteContext['svelteVersion'] {
145
145
if ( typeof version !== 'string' ) {
146
146
continue ;
147
147
}
148
- const major = extractMajorVersion ( version ) ;
148
+ const major = extractMajorVersion ( version , false ) ;
149
149
if ( major === '3' || major === '4' ) {
150
150
return '3/4' ;
151
151
}
@@ -186,10 +186,7 @@ function getSvelteKitVersion(filePath: string): SvelteContext['svelteKitVersion'
186
186
return null ;
187
187
}
188
188
189
- if ( version . includes ( '1.0.0-next' ) ) {
190
- return '1.0.0-next' ;
191
- }
192
- return extractMajorVersion ( version ) as SvelteContext [ 'svelteKitVersion' ] ;
189
+ return extractMajorVersion ( version , true ) as SvelteContext [ 'svelteKitVersion' ] ;
193
190
}
194
191
} catch {
195
192
/** do nothing */
@@ -198,7 +195,14 @@ function getSvelteKitVersion(filePath: string): SvelteContext['svelteKitVersion'
198
195
return null ;
199
196
}
200
197
201
- function extractMajorVersion ( version : string ) : string | null {
198
+ function extractMajorVersion ( version : string , recognizePrereleaseVersion : boolean ) : string | null {
199
+ if ( recognizePrereleaseVersion ) {
200
+ const match = / ^ (?: \^ | ~ ) ? ( \d + \. 0 \. 0 - n e x t ) / . exec ( version ) ;
201
+ if ( match && match [ 1 ] ) {
202
+ return match [ 1 ] ;
203
+ }
204
+ }
205
+
202
206
const match = / ^ (?: \^ | ~ ) ? ( \d + ) \. / . exec ( version ) ;
203
207
if ( match && match [ 1 ] ) {
204
208
return match [ 1 ] ;
You can’t perform that action at this time.
0 commit comments