@@ -39,16 +39,47 @@ export function pruneDts(inputLocation: string, outputLocation: string): void {
3939 const program = ts . createProgram ( [ inputLocation ] , compilerOptions , host ) ;
4040 const printer : ts . Printer = ts . createPrinter ( ) ;
4141 const sourceFile = program . getSourceFile ( inputLocation ) ! ;
42+
4243 const result : ts . TransformationResult < ts . SourceFile > = ts . transform < ts . SourceFile > (
4344 sourceFile ,
4445 [ dropPrivateApiTransformer . bind ( null , program , host ) ]
4546 ) ;
4647 const transformedSourceFile : ts . SourceFile = result . transformed [ 0 ] ;
48+ let content = printer . printFile ( transformedSourceFile ) ;
4749
48- const content = printer . printFile ( transformedSourceFile ) ;
4950 fs . writeFileSync ( outputLocation , content ) ;
5051}
5152
53+ export async function addBlankLines ( outputLocation : string ) : Promise < void > {
54+ const eslint = new ESLint ( {
55+ fix : true ,
56+ overrideConfig : {
57+ parserOptions : {
58+ ecmaVersion : 2017 ,
59+ sourceType : 'module' ,
60+ tsconfigRootDir : __dirname ,
61+ project : [ './tsconfig.eslint.json' ]
62+ } ,
63+ env : {
64+ es6 : true
65+ } ,
66+ plugins : [ '@typescript-eslint' ] ,
67+ parser : '@typescript-eslint/parser' ,
68+ rules : {
69+ 'unused-imports/no-unused-imports-ts' : [ 'off' ] ,
70+ // add blank lines after imports. Otherwise removeUnusedImports() will remove the comment
71+ // of the first item after the import block
72+ 'padding-line-between-statements' : [
73+ 'error' ,
74+ { 'blankLine' : 'always' , 'prev' : 'import' , 'next' : '*' }
75+ ]
76+ }
77+ }
78+ } ) ;
79+ const results = await eslint . lintFiles ( outputLocation ) ;
80+ await ESLint . outputFixes ( results ) ;
81+ }
82+
5283export async function removeUnusedImports (
5384 outputLocation : string
5485) : Promise < void > {
0 commit comments