@@ -16,8 +16,8 @@ import {
16
16
addExportToModule ,
17
17
addProviderToModule ,
18
18
addSymbolToNgModuleMetadata ,
19
- insertAfterLastOccurrence ,
20
19
findNodes ,
20
+ insertAfterLastOccurrence ,
21
21
} from './ast-utils' ;
22
22
23
23
@@ -39,6 +39,7 @@ function applyChanges(path: string, content: string, changes: Change[]): string
39
39
return getFileContent ( tree , path ) ;
40
40
}
41
41
42
+ // tslint:disable-next-line:no-big-function
42
43
describe ( 'ast utils' , ( ) => {
43
44
let modulePath : string ;
44
45
let moduleContent : string ;
@@ -209,20 +210,23 @@ describe('ast utils', () => {
209
210
} ) ;
210
211
211
212
describe ( 'insertAfterLastOccurrence' , ( ) => {
212
- const filePath : string = './src/foo.ts' ;
213
+ const filePath = './src/foo.ts' ;
213
214
214
215
it ( 'should work for the default scenario' , ( ) => {
215
216
const fileContent = `const arr = ['foo'];` ;
216
217
const source = getTsSource ( filePath , fileContent ) ;
217
- const arrayNode = findNodes ( source . getChildren ( ) . shift ( ) as ts . Node , ts . SyntaxKind . ArrayLiteralExpression ) ;
218
+ const arrayNode = findNodes (
219
+ source . getChildren ( ) . shift ( ) as ts . Node ,
220
+ ts . SyntaxKind . ArrayLiteralExpression ,
221
+ ) ;
218
222
const elements = ( arrayNode . pop ( ) as ts . ArrayLiteralExpression ) . elements ;
219
223
220
224
const change = insertAfterLastOccurrence (
221
- elements as any as ts . Node [ ] ,
225
+ elements as unknown as ts . Node [ ] ,
222
226
`, 'bar'` ,
223
227
filePath ,
224
228
elements . pos ,
225
- ts . SyntaxKind . StringLiteral
229
+ ts . SyntaxKind . StringLiteral ,
226
230
) ;
227
231
const output = applyChanges ( filePath , fileContent , [ change ] ) ;
228
232
@@ -233,15 +237,18 @@ describe('ast utils', () => {
233
237
it ( 'should work without occurrences' , ( ) => {
234
238
const fileContent = `const arr = [];` ;
235
239
const source = getTsSource ( filePath , fileContent ) ;
236
- const arrayNode = findNodes ( source . getChildren ( ) . shift ( ) as ts . Node , ts . SyntaxKind . ArrayLiteralExpression ) ;
240
+ const arrayNode = findNodes (
241
+ source . getChildren ( ) . shift ( ) as ts . Node ,
242
+ ts . SyntaxKind . ArrayLiteralExpression ,
243
+ ) ;
237
244
const elements = ( arrayNode . pop ( ) as ts . ArrayLiteralExpression ) . elements ;
238
245
239
246
const change = insertAfterLastOccurrence (
240
- elements as any as ts . Node [ ] ,
247
+ elements as unknown as ts . Node [ ] ,
241
248
`'bar'` ,
242
249
filePath ,
243
250
elements . pos ,
244
- ts . SyntaxKind . StringLiteral
251
+ ts . SyntaxKind . StringLiteral ,
245
252
) ;
246
253
const output = applyChanges ( filePath , fileContent , [ change ] ) ;
247
254
0 commit comments