File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11export * from '@tsslint/types' ;
2+ export { create as createDiagnosticsPlugin } from './lib/plugins/diagnostics.js' ;
23export { create as createIgnorePlugin } from './lib/plugins/ignore.js' ;
34
45import type { Config , Plugin , Rule } from '@tsslint/types' ;
Original file line number Diff line number Diff line change 1+ import type { Plugin } from '@tsslint/types' ;
2+
3+ type CheckMode = 'syntactic' | 'semantic' | 'declaration' ;
4+
5+ export function create ( mode : CheckMode | CheckMode [ ] = 'semantic' ) : Plugin {
6+ const modes = Array . isArray ( mode ) ? mode : [ mode ] ;
7+ return ( { languageService } ) => ( {
8+ resolveDiagnostics ( sourceFile , diagnostics ) {
9+ const program = languageService . getProgram ( ) ! ;
10+ for ( const mode of modes ) {
11+ const diags = mode === 'syntactic'
12+ ? program . getSyntacticDiagnostics ( sourceFile )
13+ : mode === 'semantic'
14+ ? program . getSemanticDiagnostics ( sourceFile )
15+ : mode === 'declaration'
16+ ? program . getDeclarationDiagnostics ( sourceFile )
17+ : [ ] ;
18+ for ( const diag of diags ) {
19+ diag . start ??= 0 ;
20+ diag . length ??= 0 ;
21+ diagnostics . push ( diag as any ) ;
22+ }
23+ }
24+ return diagnostics ;
25+ } ,
26+ } ) ;
27+ }
You can’t perform that action at this time.
0 commit comments