@@ -8,7 +8,14 @@ import c from 'picocolors'
8
8
9
9
// @ts -expect-error missing types
10
10
import 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'
12
19
import { isGitClean } from './utils'
13
20
14
21
export interface RuleOptions {
@@ -29,14 +36,19 @@ export async function run(options: RuleOptions = {}) {
29
36
const pathESLintIngore = path . join ( cwd , '.eslintignore' )
30
37
31
38
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
+ )
33
44
return process . exit ( 1 )
34
45
}
35
46
36
47
if ( ! SKIP_GIT_CHECK && ! isGitClean ( ) ) {
37
48
const { confirmed } = await prompts ( {
38
49
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?' ,
40
52
name : 'confirmed' ,
41
53
type : 'confirm' ,
42
54
} )
@@ -67,7 +79,10 @@ export async function run(options: RuleOptions = {}) {
67
79
68
80
for ( const glob of globs ) {
69
81
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
+ )
71
86
}
72
87
}
73
88
@@ -94,7 +109,8 @@ module.exports = defineConfig({\n${coderwydConfig}\n})
94
109
const files = fs . readdirSync ( cwd )
95
110
const legacyConfig : string [ ] = [ ]
96
111
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 )
98
114
} )
99
115
if ( legacyConfig . length > 0 ) {
100
116
console . log ( `${ WARN } you can now remove those files manually:` )
@@ -112,7 +128,8 @@ module.exports = defineConfig({\n${coderwydConfig}\n})
112
128
promptResult = await prompts (
113
129
{
114
130
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?' ,
116
133
name : 'updateVscodeSettings' ,
117
134
type : 'confirm' ,
118
135
} ,
@@ -132,7 +149,8 @@ module.exports = defineConfig({\n${coderwydConfig}\n})
132
149
const dotVscodePath : string = path . join ( cwd , '.vscode' )
133
150
const settingsPath : string = path . join ( dotVscodePath , 'settings.json' )
134
151
135
- if ( ! fs . existsSync ( dotVscodePath ) ) await fsp . mkdir ( dotVscodePath , { recursive : true } )
152
+ if ( ! fs . existsSync ( dotVscodePath ) )
153
+ await fsp . mkdir ( dotVscodePath , { recursive : true } )
136
154
137
155
if ( ! fs . existsSync ( settingsPath ) ) {
138
156
await fsp . writeFile ( settingsPath , `{${ vscodeSettingsString } }\n` , 'utf-8' )
@@ -141,7 +159,10 @@ module.exports = defineConfig({\n${coderwydConfig}\n})
141
159
let settingsContent = await fsp . readFile ( settingsPath , 'utf8' )
142
160
143
161
settingsContent = settingsContent . trim ( ) . replace ( / \s * } $ / , '' )
144
- settingsContent += settingsContent . endsWith ( ',' ) || settingsContent . endsWith ( '{' ) ? '' : ','
162
+ settingsContent +=
163
+ settingsContent . endsWith ( ',' ) || settingsContent . endsWith ( '{' )
164
+ ? ''
165
+ : ','
145
166
settingsContent += `${ vscodeSettingsString } }\n`
146
167
147
168
await fsp . writeFile ( settingsPath , settingsContent , 'utf-8' )
@@ -151,5 +172,7 @@ module.exports = defineConfig({\n${coderwydConfig}\n})
151
172
152
173
// End update .vscode/settings.json
153
174
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
+ )
155
178
}
0 commit comments