11import type { DependencyInfo , Extractor , ValidNode } from '#types/extractor'
22import type { ResolvedPackument } from '#utils/npm'
3+ import type { Awaitable } from 'reactive-vscode'
34import type { Diagnostic , TextDocument } from 'vscode'
45import { basename } from 'node:path'
56import { logger } from '#state'
@@ -8,14 +9,16 @@ import { useActiveTextEditor, useDocumentText, watch } from 'reactive-vscode'
89import { languages } from 'vscode'
910import { displayName } from '../../generated-meta'
1011import { checkDeprecation } from './rules/deprecation'
12+ import { checkReplacement } from './rules/replacement'
1113
1214export interface NodeDiagnosticInfo extends Pick < Diagnostic , 'message' | 'severity' > {
1315 node : ValidNode
1416}
15- export type DiagnosticRule = ( dep : DependencyInfo , pkg : ResolvedPackument ) => NodeDiagnosticInfo | undefined
17+ export type DiagnosticRule = ( dep : DependencyInfo , pkg : ResolvedPackument ) => Awaitable < NodeDiagnosticInfo | undefined >
1618
1719const rules : DiagnosticRule [ ] = [
1820 checkDeprecation ,
21+ checkReplacement ,
1922]
2023
2124export function registerDiagnosticCollection ( mapping : Record < string , Extractor | undefined > ) {
@@ -38,7 +41,7 @@ export function registerDiagnosticCollection(mapping: Record<string, Extractor |
3841 const pkg = await getPackageInfo ( dep . name )
3942
4043 for ( const rule of rules ) {
41- const diagnostic = rule ( dep , pkg )
44+ const diagnostic = await rule ( dep , pkg )
4245
4346 if ( diagnostic ) {
4447 diagnostics . push ( {
@@ -55,6 +58,8 @@ export function registerDiagnosticCollection(mapping: Record<string, Extractor |
5558 } ) ,
5659 )
5760
61+ if ( diagnostics . length > 0 )
62+ logger . info ( `${ diagnostics . length } diagnostic collected in ${ document . fileName } .` )
5863 diagnosticCollection . set ( document . uri , diagnostics )
5964 }
6065
0 commit comments