Skip to content

Commit

Permalink
refactor(config): streamline state handling for single-line and multi…
Browse files Browse the repository at this point in the history
…-line comments
  • Loading branch information
johnsoncodehk committed Jan 5, 2025
1 parent 02cbc40 commit 4ee3819
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions packages/config/lib/plugins/ignore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,25 +201,20 @@ export function create(

for (const code of [undefined, error.code]) {
const states = comments.get(code as any);
if (states) {
if (mode === 'singleLine') {
if (states.some(comment => comment.startLine === line)) {
for (const state of states) {
if (state.startLine === line) {
state.used = true;
break;
}
}
if (!states) {
continue;
}
if (mode === 'singleLine') {
for (const state of states) {
if (state.startLine === line) {
state.used = true;
return false;
}
} else {
if (states.some((comment => line >= comment.startLine && line <= (comment.endLine ?? Number.MAX_VALUE)))) {
for (const state of states) {
if (line >= state.startLine && line <= (state.endLine ?? Number.MAX_VALUE)) {
state.used = true;
break;
}
}
}
} else {
for (const state of states) {
if (line >= state.startLine && line <= (state.endLine ?? Number.MAX_VALUE)) {
state.used = true;
return false;
}
}
Expand Down

0 comments on commit 4ee3819

Please sign in to comment.