@@ -34,22 +34,22 @@ const hasJsxRuntime = (() => {
34
34
function writeJson ( fileName , object ) {
35
35
fs . writeFileSync (
36
36
fileName ,
37
- JSON . stringify ( object , null , 2 ) . replace ( / \n / g, os . EOL ) + os . EOL
37
+ JSON . stringify ( object , null , 2 ) . replace ( / \n / g, os . EOL ) + os . EOL ,
38
38
) ;
39
39
}
40
40
41
41
function verifyNoTypeScript ( ) {
42
42
const typescriptFiles = globby (
43
43
[ '**/*.(ts|tsx)' , '!**/node_modules' , '!**/*.d.ts' ] ,
44
- { cwd : paths . appSrc }
44
+ { cwd : paths . appSrc } ,
45
45
) ;
46
46
if ( typescriptFiles . length > 0 ) {
47
47
console . warn (
48
48
chalk . yellow (
49
49
`We detected TypeScript in your project (${ chalk . bold (
50
- `src${ path . sep } ${ typescriptFiles [ 0 ] } `
51
- ) } ) and created a ${ chalk . bold ( 'tsconfig.json' ) } file for you.`
52
- )
50
+ `src${ path . sep } ${ typescriptFiles [ 0 ] } ` ,
51
+ ) } ) and created a ${ chalk . bold ( 'tsconfig.json' ) } file for you.`,
52
+ ) ,
53
53
) ;
54
54
console . warn ( ) ;
55
55
return false ;
@@ -88,26 +88,26 @@ function verifyTypeScriptSetup() {
88
88
console . error (
89
89
chalk . bold . red (
90
90
`It looks like you're trying to use TypeScript but do not have ${ chalk . bold (
91
- 'typescript'
92
- ) } installed.`
93
- )
91
+ 'typescript' ,
92
+ ) } installed.`,
93
+ ) ,
94
94
) ;
95
95
console . error (
96
96
chalk . bold (
97
97
'Please install' ,
98
98
chalk . cyan . bold ( 'typescript' ) ,
99
99
'by running' ,
100
100
chalk . cyan . bold (
101
- isYarn ? 'yarn add typescript' : 'npm install typescript'
102
- ) + '.'
103
- )
101
+ isYarn ? 'yarn add typescript' : 'npm install typescript' ,
102
+ ) + '.' ,
103
+ ) ,
104
104
) ;
105
105
console . error (
106
106
chalk . bold (
107
107
'If you are not trying to use TypeScript, please remove the ' +
108
108
chalk . cyan ( 'tsconfig.json' ) +
109
- ' file from your package root (and any TypeScript files).'
110
- )
109
+ ' file from your package root (and any TypeScript files).' ,
110
+ ) ,
111
111
) ;
112
112
console . error ( ) ;
113
113
process . exit ( 1 ) ;
@@ -160,7 +160,7 @@ function verifyTypeScriptSetup() {
160
160
} ;
161
161
162
162
const formatDiagnosticHost = {
163
- getCanonicalFileName : fileName => fileName ,
163
+ getCanonicalFileName : ( fileName ) => fileName ,
164
164
getCurrentDirectory : ts . sys . getCurrentDirectory ,
165
165
getNewLine : ( ) => os . EOL ,
166
166
} ;
@@ -172,7 +172,7 @@ function verifyTypeScriptSetup() {
172
172
try {
173
173
const { config : readTsConfig , error } = ts . readConfigFile (
174
174
paths . appTsConfig ,
175
- ts . sys . readFile
175
+ ts . sys . readFile ,
176
176
) ;
177
177
178
178
if ( error ) {
@@ -185,17 +185,17 @@ function verifyTypeScriptSetup() {
185
185
// Calling this function also mutates the tsconfig above,
186
186
// adding in "include" and "exclude", but the compilerOptions remain untouched
187
187
let result ;
188
- parsedTsConfig = immer ( readTsConfig , config => {
188
+ parsedTsConfig = immer ( readTsConfig , ( config ) => {
189
189
result = ts . parseJsonConfigFileContent (
190
190
config ,
191
191
ts . sys ,
192
- path . dirname ( paths . appTsConfig )
192
+ path . dirname ( paths . appTsConfig ) ,
193
193
) ;
194
194
} ) ;
195
195
196
196
if ( result . errors && result . errors . length ) {
197
197
throw new Error (
198
- ts . formatDiagnostic ( result . errors [ 0 ] , formatDiagnosticHost )
198
+ ts . formatDiagnostic ( result . errors [ 0 ] , formatDiagnosticHost ) ,
199
199
) ;
200
200
}
201
201
@@ -206,8 +206,8 @@ function verifyTypeScriptSetup() {
206
206
chalk . red . bold (
207
207
'Could not parse' ,
208
208
chalk . cyan ( 'tsconfig.json' ) + '.' ,
209
- 'Please make sure it contains syntactically correct JSON.'
210
- )
209
+ 'Please make sure it contains syntactically correct JSON.' ,
210
+ ) ,
211
211
) ;
212
212
}
213
213
@@ -228,35 +228,35 @@ function verifyTypeScriptSetup() {
228
228
229
229
if ( suggested != null ) {
230
230
if ( parsedCompilerOptions [ option ] === undefined ) {
231
- appTsConfig = immer ( appTsConfig , config => {
231
+ appTsConfig = immer ( appTsConfig , ( config ) => {
232
232
config . compilerOptions [ option ] = suggested ;
233
233
} ) ;
234
234
messages . push (
235
235
`${ coloredOption } to be ${ chalk . bold (
236
- 'suggested'
237
- ) } value: ${ chalk . cyan . bold ( suggested ) } (this can be changed)`
236
+ 'suggested' ,
237
+ ) } value: ${ chalk . cyan . bold ( suggested ) } (this can be changed)`,
238
238
) ;
239
239
}
240
240
} else if ( parsedCompilerOptions [ option ] !== valueToCheck ) {
241
- appTsConfig = immer ( appTsConfig , config => {
241
+ appTsConfig = immer ( appTsConfig , ( config ) => {
242
242
config . compilerOptions [ option ] = value ;
243
243
} ) ;
244
244
messages . push (
245
245
`${ coloredOption } ${ chalk . bold (
246
- valueToCheck == null ? 'must not' : 'must'
246
+ valueToCheck == null ? 'must not' : 'must' ,
247
247
) } be ${ valueToCheck == null ? 'set' : chalk . cyan . bold ( value ) } ` +
248
- ( reason != null ? ` (${ reason } )` : '' )
248
+ ( reason != null ? ` (${ reason } )` : '' ) ,
249
249
) ;
250
250
}
251
251
}
252
252
253
253
// tsconfig will have the merged "include" and "exclude" by this point
254
254
if ( parsedTsConfig . include == null ) {
255
- appTsConfig = immer ( appTsConfig , config => {
255
+ appTsConfig = immer ( appTsConfig , ( config ) => {
256
256
config . include = [ 'src' ] ;
257
257
} ) ;
258
258
messages . push (
259
- `${ chalk . cyan ( 'include' ) } should be ${ chalk . cyan . bold ( 'src' ) } `
259
+ `${ chalk . cyan ( 'include' ) } should be ${ chalk . cyan . bold ( 'src' ) } ` ,
260
260
) ;
261
261
}
262
262
@@ -266,33 +266,33 @@ function verifyTypeScriptSetup() {
266
266
chalk . bold (
267
267
'Your' ,
268
268
chalk . cyan ( 'tsconfig.json' ) ,
269
- 'has been populated with default values.'
270
- )
269
+ 'has been populated with default values.' ,
270
+ ) ,
271
271
) ;
272
272
console . log ( ) ;
273
273
} else {
274
274
console . warn (
275
275
chalk . bold (
276
276
'The following changes are being made to your' ,
277
277
chalk . cyan ( 'tsconfig.json' ) ,
278
- 'file:'
279
- )
278
+ 'file:' ,
279
+ ) ,
280
280
) ;
281
- messages . forEach ( message => {
281
+ messages . forEach ( ( message ) => {
282
282
console . warn ( ' - ' + message ) ;
283
283
} ) ;
284
284
console . warn ( ) ;
285
285
}
286
286
writeJson ( paths . appTsConfig , appTsConfig ) ;
287
287
}
288
288
289
- // Reference `react-scripts` types
290
- if ( ! fs . existsSync ( paths . appTypeDeclarations ) ) {
291
- fs . writeFileSync (
292
- paths . appTypeDeclarations ,
293
- `/// <reference types="@upleveled/react-scripts" />${ os . EOL } `
294
- ) ;
295
- }
289
+ // // Reference `react-scripts` types
290
+ // if (!fs.existsSync(paths.appTypeDeclarations)) {
291
+ // fs.writeFileSync(
292
+ // paths.appTypeDeclarations,
293
+ // `/// <reference types="@upleveled/react-scripts" />${os.EOL}`
294
+ // );
295
+ // }
296
296
}
297
297
298
298
module . exports = verifyTypeScriptSetup ;
0 commit comments