File tree Expand file tree Collapse file tree 4 files changed +33
-1
lines changed
Expand file tree Collapse file tree 4 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -1834,7 +1834,8 @@ namespace ts {
18341834 const fileContents = sourceFile . text ;
18351835 const result : TodoComment [ ] = [ ] ;
18361836
1837- if ( descriptors . length > 0 ) {
1837+ // Exclude node_modules files as we don't want to show the todos of external libraries.
1838+ if ( descriptors . length > 0 && ! isNodeModulesFile ( sourceFile . fileName ) ) {
18381839 const regExp = getTodoCommentsRegExp ( ) ;
18391840
18401841 let matchArray : RegExpExecArray ;
@@ -1958,6 +1959,12 @@ namespace ts {
19581959 ( char >= CharacterCodes . A && char <= CharacterCodes . Z ) ||
19591960 ( char >= CharacterCodes . _0 && char <= CharacterCodes . _9 ) ;
19601961 }
1962+
1963+ function isNodeModulesFile ( path : string ) : boolean {
1964+ const node_modulesFolderName = "/node_modules/" ;
1965+
1966+ return path . indexOf ( node_modulesFolderName ) !== - 1 ;
1967+ }
19611968 }
19621969
19631970 function getRenameInfo ( fileName : string , position : number ) : RenameInfo {
Original file line number Diff line number Diff line change 1+ /// <reference path='fourslash.ts' />
2+
3+ // Tests node_modules name in file still gets todos.
4+
5+ // @Filename : /node_modules_todoTest0.ts
6+ //// // [|TODO|]
7+
8+ verify . todoCommentsInCurrentFile ( [ "TODO" ] ) ;
Original file line number Diff line number Diff line change 1+ /// <reference path='fourslash.ts' />
2+
3+ // Tests that todos are not found in node_modules folder.
4+
5+ // @Filename : todoTest0.ts
6+ //// import * as foo1 from "fake-module";
7+
8+ // @Filename : node_modules/fake-module/ts.ts
9+ //// // TODO
10+
11+ verify . todoCommentsInCurrentFile ( [ "TODO" ] ) ;
Original file line number Diff line number Diff line change 1+ /// <reference path='fourslash.ts' />
2+
3+ // @Filename : dir1/node_modules/todoTest0.ts
4+ //// // TODO
5+
6+ verify . todoCommentsInCurrentFile ( [ "TODO" ] ) ;
You can’t perform that action at this time.
0 commit comments