Skip to content

Commit

Permalink
fix(#3): show report on the correct node
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Hoeffernig committed Jan 24, 2022
1 parent 268b891 commit 3697ae6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/rules/jira-ticket-todo-comment.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
create(context) {
return {
"Program": function(node) {
Program(node) {
const options = context.options[0];
const projectKey = options && options.projectKey;
const regexOption = options && options.regex;
Expand All @@ -16,8 +16,8 @@ module.exports = {
if(regexOption) {
regex = new RegExp(regexOption);
}
for(const comment of context.getSourceCode().getAllComments()) {
const value = comment.value.trimStart();
for(const node of context.getSourceCode().getAllComments()) {
const value = node.value.trimStart();
if(value.startsWith(`TODO`) && !regex.test(value)) {
context.report({ message: `Add a JIRA ticket number to the TODO comment (e.g. ${projectKey ? projectKey : `MP`}-123)`, node });
}
Expand Down

0 comments on commit 3697ae6

Please sign in to comment.