Skip to content

Commit 6f28f83

Browse files
author
Armando Aguirre
committed
Added node_modules path check on getTodoComments method.
1 parent de9a67f commit 6f28f83

4 files changed

Lines changed: 23 additions & 1 deletion

File tree

src/services/services.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1834,7 +1834,7 @@ namespace ts {
18341834
const fileContents = sourceFile.text;
18351835
const result: TodoComment[] = [];
18361836

1837-
if (descriptors.length > 0) {
1837+
if (descriptors.length > 0 && !isNodeModulesFile(fileName)) {
18381838
const regExp = getTodoCommentsRegExp();
18391839

18401840
let matchArray: RegExpExecArray;
@@ -1958,6 +1958,12 @@ namespace ts {
19581958
(char >= CharacterCodes.A && char <= CharacterCodes.Z) ||
19591959
(char >= CharacterCodes._0 && char <= CharacterCodes._9);
19601960
}
1961+
1962+
function isNodeModulesFile(path: string): boolean {
1963+
const node_modulesFolderName = "/node_modules/";
1964+
1965+
return path.indexOf(node_modulesFolderName) !== -1;
1966+
}
19611967
}
19621968

19631969
function getRenameInfo(fileName: string, position: number): RenameInfo {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Tests node_modules name in file still gets todos.
2+
3+
// @Filename: /node_modules_todotest0.ts
4+
//// // [|TODO|]
5+
6+
verify.todoCommentsInCurrentFile(["TODO"]);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Tests that todos are not found in node_modules folder.
2+
3+
// @Filename: /node_modules/todotest0.ts
4+
//// // TODO
5+
6+
verify.todoCommentsInCurrentFile(["TODO"]);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// @Filename: dir1/node_modules/todotest0.ts
2+
//// // TODO
3+
4+
verify.todoCommentsInCurrentFile(["TODO"]);

0 commit comments

Comments
 (0)