mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-04-17 01:49:41 -05:00
Added node_modules path check on getTodoComments method.
This commit is contained in:
@@ -1834,7 +1834,7 @@ namespace ts {
|
||||
const fileContents = sourceFile.text;
|
||||
const result: TodoComment[] = [];
|
||||
|
||||
if (descriptors.length > 0) {
|
||||
if (descriptors.length > 0 && !isNodeModulesFile(fileName)) {
|
||||
const regExp = getTodoCommentsRegExp();
|
||||
|
||||
let matchArray: RegExpExecArray;
|
||||
@@ -1958,6 +1958,12 @@ namespace ts {
|
||||
(char >= CharacterCodes.A && char <= CharacterCodes.Z) ||
|
||||
(char >= CharacterCodes._0 && char <= CharacterCodes._9);
|
||||
}
|
||||
|
||||
function isNodeModulesFile(path: string): boolean {
|
||||
const node_modulesFolderName = "/node_modules/";
|
||||
|
||||
return path.indexOf(node_modulesFolderName) !== -1;
|
||||
}
|
||||
}
|
||||
|
||||
function getRenameInfo(fileName: string, position: number): RenameInfo {
|
||||
|
||||
6
tests/cases/fourslash/todoComments18.ts
Normal file
6
tests/cases/fourslash/todoComments18.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
// Tests node_modules name in file still gets todos.
|
||||
|
||||
// @Filename: /node_modules_todotest0.ts
|
||||
//// // [|TODO|]
|
||||
|
||||
verify.todoCommentsInCurrentFile(["TODO"]);
|
||||
6
tests/cases/fourslash/todoComments19.ts
Normal file
6
tests/cases/fourslash/todoComments19.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
// Tests that todos are not found in node_modules folder.
|
||||
|
||||
// @Filename: /node_modules/todotest0.ts
|
||||
//// // TODO
|
||||
|
||||
verify.todoCommentsInCurrentFile(["TODO"]);
|
||||
4
tests/cases/fourslash/todoComments20.ts
Normal file
4
tests/cases/fourslash/todoComments20.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
// @Filename: dir1/node_modules/todotest0.ts
|
||||
//// // TODO
|
||||
|
||||
verify.todoCommentsInCurrentFile(["TODO"]);
|
||||
Reference in New Issue
Block a user