7
7
functions ,
8
8
imports ,
9
9
object ,
10
- type AstKinds ,
11
10
type AstTypes
12
11
} from '@sveltejs/cli-core/js' ;
13
12
import { parseJson , parseScript } from '@sveltejs/cli-core/parsers' ;
@@ -54,14 +53,12 @@ export default defineAddon({
54
53
sv . file ( 'eslint.config.js' , ( content ) => {
55
54
const { ast, generateCode } = parseScript ( content ) ;
56
55
57
- const eslintConfigs : Array <
58
- AstKinds . ExpressionKind | AstTypes . SpreadElement | AstTypes . ObjectExpression
59
- > = [ ] ;
56
+ const eslintConfigs : Array < AstTypes . Expression | AstTypes . SpreadElement > = [ ] ;
60
57
61
58
imports . addDefault ( ast , './svelte.config.js' , 'svelteConfig' ) ;
62
59
63
60
const gitIgnorePathStatement = common . statementFromString (
64
- ' \nconst gitignorePath = fileURLToPath(new URL(" ./.gitignore" , import.meta.url));'
61
+ " \nconst gitignorePath = fileURLToPath(new URL(' ./.gitignore' , import.meta.url));"
65
62
) ;
66
63
common . addStatement ( ast , gitIgnorePathStatement ) ;
67
64
@@ -90,16 +87,19 @@ export default defineAddon({
90
87
'"no-undef"' : off
91
88
} ) ;
92
89
93
- if ( rules . properties [ 0 ] . type !== 'ObjectProperty ' ) {
94
- throw new Error ( 'rules.properties[0].type !== "ObjectProperty "' ) ;
90
+ if ( rules . properties [ 0 ] . type !== 'Property ' ) {
91
+ throw new Error ( 'rules.properties[0].type !== "Property "' ) ;
95
92
}
96
- rules . properties [ 0 ] . key . comments = [
93
+ rules . properties [ 0 ] . key . leadingComments = [
97
94
{
98
- type : 'Block ' ,
95
+ type : 'Line ' ,
99
96
value :
100
- '*\n * typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects.\n * see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors\n ' ,
101
- leading : true ,
102
- trailing : false
97
+ ' typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects.'
98
+ } ,
99
+ {
100
+ type : 'Line' ,
101
+ value :
102
+ ' see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors'
103
103
}
104
104
] ;
105
105
@@ -114,8 +114,8 @@ export default defineAddon({
114
114
115
115
if ( typescript ) {
116
116
const svelteTSParserConfig = object . create ( {
117
- files : common . expressionFromString ( '[" **/*.svelte", " **/*.svelte.ts", " **/*.svelte.js"]' ) ,
118
- ignores : common . expressionFromString ( '[" eslint.config.js", " svelte.config.js"]' ) ,
117
+ files : common . expressionFromString ( "[' **/*.svelte', ' **/*.svelte.ts', ' **/*.svelte.js']" ) ,
118
+ ignores : common . expressionFromString ( "[' eslint.config.js', ' svelte.config.js']" ) ,
119
119
languageOptions : object . create ( {
120
120
parserOptions : object . create ( {
121
121
projectService : common . expressionFromString ( 'true' ) ,
@@ -128,7 +128,7 @@ export default defineAddon({
128
128
eslintConfigs . push ( svelteTSParserConfig ) ;
129
129
} else {
130
130
const svelteTSParserConfig = object . create ( {
131
- files : common . expressionFromString ( '[" **/*.svelte", " **/*.svelte.js"]' ) ,
131
+ files : common . expressionFromString ( "[' **/*.svelte', ' **/*.svelte.js']" ) ,
132
132
languageOptions : object . create ( {
133
133
parserOptions : object . create ( {
134
134
svelteConfig : common . expressionFromString ( 'svelteConfig' )
0 commit comments