@@ -81,6 +81,7 @@ export class ConfigGenerator {
8181 let exportContent = "" ;
8282 let needCompatHelper = false ;
8383 const languages = this . answers . languages ;
84+ const purpose = this . answers . purpose ;
8485
8586 if ( languages ?. includes ( "javascript" ) ) {
8687 if ( this . answers . moduleType === "commonjs" || this . answers . moduleType === "script" ) {
@@ -99,10 +100,10 @@ export class ConfigGenerator {
99100 exportContent += ` {languageOptions: { ${ envContent [ this . answers . env . join ( "," ) ] } }},\n` ;
100101 }
101102
102- if ( this . answers . purpose === "syntax" ) {
103+ if ( purpose === "syntax" ) {
103104
104105 // no need to install any plugin
105- } else if ( this . answers . purpose === "problems" ) {
106+ } else if ( purpose === "problems" ) {
106107 this . result . devDependencies . push ( "@eslint/js" ) ;
107108 importContent += "import pluginJs from \"@eslint/js\";\n" ;
108109 exportContent += " pluginJs.configs.recommended,\n" ;
@@ -145,23 +146,43 @@ export class ConfigGenerator {
145146 importContent += "import json from \"@eslint/json\";\n" ;
146147 }
147148 if ( languages ?. includes ( "json" ) ) {
148- exportContent += " {files: [\"**/*.json\"], language: \"json/json\", ...json.configs.recommended},\n" ;
149+ const config = purpose === "syntax"
150+ ? " {files: [\"**/*.json\"], language: \"json/json\"},\n"
151+ : " {files: [\"**/*.json\"], language: \"json/json\", ...json.configs.recommended},\n" ;
152+
153+ exportContent += config ;
149154 }
150155 if ( languages ?. includes ( "jsonc" ) ) {
151- exportContent += " {files: [\"**/*.jsonc\"], language: \"json/jsonc\", ...json.configs.recommended},\n" ;
156+ const config = purpose === "syntax"
157+ ? " {files: [\"**/*.jsonc\"], language: \"json/jsonc\"},\n"
158+ : " {files: [\"**/*.jsonc\"], language: \"json/jsonc\", ...json.configs.recommended},\n" ;
159+
160+ exportContent += config ;
152161 }
153162 if ( languages ?. includes ( "json5" ) ) {
154- exportContent += " {files: [\"**/*.json5\"], language: \"json/json5\", ...json.configs.recommended},\n" ;
163+ const config = purpose === "syntax"
164+ ? " {files: [\"**/*.json5\"], language: \"json/json5\"},\n"
165+ : " {files: [\"**/*.json5\"], language: \"json/json5\", ...json.configs.recommended},\n" ;
166+
167+ exportContent += config ;
155168 }
156169
157170 if ( languages ?. includes ( "md" ) ) {
158171 this . result . devDependencies . push ( "@eslint/markdown" ) ;
159172 importContent += "import markdown from \"@eslint/markdown\";\n" ;
160- exportContent += " ...markdown.configs.recommended,\n" ;
161- if ( this . answers . mdType === "gfm" ) {
162173
163- // the default is commonmark
164- exportContent += " {files: [\"**/*.md\"], language: \"markdown/gfm\"},\n" ;
174+ if ( purpose === "syntax" ) {
175+ const config = this . answers . mdType === "commonmark" ? " {files: [\"**/*.md\"], language: \"markdown/commonmark\"},\n" : " {files: [\"**/*.md\"], language: \"markdown/gfm\"},\n" ;
176+
177+ exportContent += config ;
178+ } else if ( purpose === "problems" ) {
179+ exportContent += " ...markdown.configs.recommended,\n" ;
180+
181+ if ( this . answers . mdType === "gfm" ) {
182+
183+ // the default is commonmark
184+ exportContent += " {files: [\"**/*.md\"], language: \"markdown/gfm\"},\n" ;
185+ }
165186 }
166187 }
167188
0 commit comments