Skip to content

Commit 5a47324

Browse files
committed
Fix ESLint error: replace while(true) with proper loop condition
1 parent 33047af commit 5a47324

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

options/options.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,8 @@ async function fetchReposFromGitHub(type, token) {
825825
}
826826

827827
// Fetch all pages
828-
while (true) {
828+
let hasMorePages = true;
829+
while (hasMorePages) {
829830
const response = await fetch(`${url}${url.includes('?') ? '&' : '?'}per_page=${perPage}&page=${page}`, {
830831
headers
831832
});
@@ -841,7 +842,10 @@ async function fetchReposFromGitHub(type, token) {
841842
}
842843

843844
const repos = await response.json();
844-
if (repos.length === 0) break;
845+
if (repos.length === 0) {
846+
hasMorePages = false;
847+
break;
848+
}
845849

846850
// Transform to our format
847851
const transformed = repos.map(repo => ({
@@ -858,10 +862,10 @@ async function fetchReposFromGitHub(type, token) {
858862
// Check if there are more pages
859863
const linkHeader = response.headers.get('Link');
860864
if (!linkHeader || !linkHeader.includes('rel="next"')) {
861-
break;
865+
hasMorePages = false;
866+
} else {
867+
page++;
862868
}
863-
864-
page++;
865869
}
866870

867871
return allRepos;

0 commit comments

Comments
 (0)