@@ -8,7 +8,14 @@ import c from 'picocolors'
88
99// @ts -expect-error missing types
1010import parse from 'parse-gitignore'
11- import { ARROW , CHECK , WARN , eslintVersion , version , vscodeSettingsString } from './constants'
11+ import {
12+ ARROW ,
13+ CHECK ,
14+ WARN ,
15+ eslintVersion ,
16+ version ,
17+ vscodeSettingsString ,
18+ } from './constants'
1219import { isGitClean } from './utils'
1320
1421export interface RuleOptions {
@@ -29,14 +36,19 @@ export async function run(options: RuleOptions = {}) {
2936 const pathESLintIngore = path . join ( cwd , '.eslintignore' )
3037
3138 if ( fs . existsSync ( pathFlatConfig ) ) {
32- console . log ( c . yellow ( `${ WARN } eslint.config.js already exists, migration wizard exited.` ) )
39+ console . log (
40+ c . yellow (
41+ `${ WARN } eslint.config.js already exists, migration wizard exited.` ,
42+ ) ,
43+ )
3344 return process . exit ( 1 )
3445 }
3546
3647 if ( ! SKIP_GIT_CHECK && ! isGitClean ( ) ) {
3748 const { confirmed } = await prompts ( {
3849 initial : false ,
39- message : 'There are uncommitted changes in the current repository, are you sure to continue?' ,
50+ message :
51+ 'There are uncommitted changes in the current repository, are you sure to continue?' ,
4052 name : 'confirmed' ,
4153 type : 'confirm' ,
4254 } )
@@ -67,7 +79,10 @@ export async function run(options: RuleOptions = {}) {
6779
6880 for ( const glob of globs ) {
6981 if ( glob . type === 'ignore' ) eslintIgnores . push ( ...glob . patterns )
70- else if ( glob . type === 'unignore' ) eslintIgnores . push ( ...glob . patterns . map ( ( pattern : string ) => `!${ pattern } ` ) )
82+ else if ( glob . type === 'unignore' )
83+ eslintIgnores . push (
84+ ...glob . patterns . map ( ( pattern : string ) => `!${ pattern } ` ) ,
85+ )
7186 }
7287 }
7388
@@ -94,7 +109,8 @@ module.exports = defineConfig({\n${coderwydConfig}\n})
94109 const files = fs . readdirSync ( cwd )
95110 const legacyConfig : string [ ] = [ ]
96111 files . forEach ( file => {
97- if ( file . includes ( 'eslint' ) || file . includes ( 'prettier' ) ) legacyConfig . push ( file )
112+ if ( file . includes ( 'eslint' ) || file . includes ( 'prettier' ) )
113+ legacyConfig . push ( file )
98114 } )
99115 if ( legacyConfig . length > 0 ) {
100116 console . log ( `${ WARN } you can now remove those files manually:` )
@@ -112,7 +128,8 @@ module.exports = defineConfig({\n${coderwydConfig}\n})
112128 promptResult = await prompts (
113129 {
114130 initial : true ,
115- message : 'Update .vscode/settings.json for better VS Code experience?' ,
131+ message :
132+ 'Update .vscode/settings.json for better VS Code experience?' ,
116133 name : 'updateVscodeSettings' ,
117134 type : 'confirm' ,
118135 } ,
@@ -132,7 +149,8 @@ module.exports = defineConfig({\n${coderwydConfig}\n})
132149 const dotVscodePath : string = path . join ( cwd , '.vscode' )
133150 const settingsPath : string = path . join ( dotVscodePath , 'settings.json' )
134151
135- if ( ! fs . existsSync ( dotVscodePath ) ) await fsp . mkdir ( dotVscodePath , { recursive : true } )
152+ if ( ! fs . existsSync ( dotVscodePath ) )
153+ await fsp . mkdir ( dotVscodePath , { recursive : true } )
136154
137155 if ( ! fs . existsSync ( settingsPath ) ) {
138156 await fsp . writeFile ( settingsPath , `{${ vscodeSettingsString } }\n` , 'utf-8' )
@@ -141,7 +159,10 @@ module.exports = defineConfig({\n${coderwydConfig}\n})
141159 let settingsContent = await fsp . readFile ( settingsPath , 'utf8' )
142160
143161 settingsContent = settingsContent . trim ( ) . replace ( / \s * } $ / , '' )
144- settingsContent += settingsContent . endsWith ( ',' ) || settingsContent . endsWith ( '{' ) ? '' : ','
162+ settingsContent +=
163+ settingsContent . endsWith ( ',' ) || settingsContent . endsWith ( '{' )
164+ ? ''
165+ : ','
145166 settingsContent += `${ vscodeSettingsString } }\n`
146167
147168 await fsp . writeFile ( settingsPath , settingsContent , 'utf-8' )
@@ -151,5 +172,7 @@ module.exports = defineConfig({\n${coderwydConfig}\n})
151172
152173 // End update .vscode/settings.json
153174 console . log ( c . green ( `${ CHECK } migration completed` ) )
154- console . log ( `Now you can update the dependencies and run ${ c . blue ( 'eslint . --fix' ) } \n` )
175+ console . log (
176+ `Now you can update the dependencies and run ${ c . blue ( 'eslint . --fix' ) } \n` ,
177+ )
155178}
0 commit comments