@@ -5,22 +5,24 @@ import prettier from 'prettier';
5
5
/**
6
6
* Write file and format it with ESLint
7
7
*/
8
- export async function writeAndFormat ( fileName : string , content : string ) : Promise < void > {
8
+ export function writeAndFormat ( fileName : string , content : string ) : Promise < void > {
9
9
fs . writeFileSync ( fileName , content , 'utf8' ) ;
10
-
11
- const prettierrc = await prettier . resolveConfig ( fileName ) ;
12
-
13
- const formatted =
14
- prettierrc && ! ( fileName . endsWith ( 'valid-style-parse.md' ) && content . includes ( '.class\n' ) )
15
- ? await prettier . format ( content , { filepath : fileName , ...prettierrc } )
16
- : content ;
17
-
18
- fs . writeFileSync ( fileName , formatted , 'utf8' ) ;
19
-
20
- const eslint = new ESLint ( { fix : true } ) ;
21
- const [ result ] = await eslint . lintText ( formatted , { filePath : fileName } ) ;
22
-
23
- if ( result ?. output ) {
24
- fs . writeFileSync ( fileName , result . output , 'utf8' ) ;
25
- }
10
+ return prettier
11
+ . resolveConfig ( fileName )
12
+ . then ( ( prettierrc ) => {
13
+ if ( ! prettierrc ) {
14
+ return content ;
15
+ }
16
+ return prettier . format ( content , { filepath : fileName , ...prettierrc } ) ;
17
+ } )
18
+ . then ( ( formatted ) => {
19
+ fs . writeFileSync ( fileName , formatted , 'utf8' ) ;
20
+ const eslint = new ESLint ( { fix : true } ) ;
21
+ return eslint . lintText ( formatted , { filePath : fileName } ) ;
22
+ } )
23
+ . then ( ( [ result ] ) => {
24
+ if ( result . output ) {
25
+ fs . writeFileSync ( fileName , result . output , 'utf8' ) ;
26
+ }
27
+ } ) ;
26
28
}
0 commit comments