Skip to content

Commit

Permalink
Use different line number
Browse files Browse the repository at this point in the history
  • Loading branch information
rehlma committed Apr 11, 2024
1 parent f63871c commit f84b1e5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 15 deletions.
8 changes: 1 addition & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29069,20 +29069,14 @@ function findTodos(prDiff) {
const lines = patch.split('\n');
if (lines === undefined || lines.length === 0)
return;
// remove first line and get the line number where the patch starts
const firstLine = lines.shift();
const match = firstLine === null || firstLine === void 0 ? void 0 : firstLine.match(regex);
if (match === undefined || match === null || (match === null || match === void 0 ? void 0 : match.length) === 0)
return;
const startLineNumer = parseInt(match[0]);
// get all todos from the patch map them to the line number
const todos = lines
.map((line, index) => {
const todo = getTodoIfFound(line);
if (todo === undefined)
return;
return {
line: startLineNumer + index,
line: index + 1,
content: todo,
added: line.startsWith('+')
};
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,13 @@ export function findTodos(prDiff: PrDiff): Todo[] {
const lines = patch.split('\n')
if (lines === undefined || lines.length === 0) return

// remove first line and get the line number where the patch starts
const firstLine = lines.shift()
const match = firstLine?.match(regex)
if (match === undefined || match === null || match?.length === 0) return
const startLineNumer = parseInt(match[0])

// get all todos from the patch map them to the line number
const todos: InnerTodo[] = lines

Check failure on line 66 in src/main.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

'todos' is already declared in the upper scope on line 57 column 9

Check failure on line 66 in src/main.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

'todos' is already declared in the upper scope on line 57 column 9
.map((line, index) => {
const todo = getTodoIfFound(line)
if (todo === undefined) return
return {
line: startLineNumer + index,
line: index + 1,
content: todo,
added: line.startsWith('+')
}
Expand Down

0 comments on commit f84b1e5

Please sign in to comment.