Skip to content

Commit 5f013fd

Browse files
fix: resolve XO linter errors in index.js
- Replace .forEach() with for...of loops (unicorn/no-array-for-each) - Use Number.parseInt instead of parseInt (unicorn/prefer-number-properties) - Add required blank lines before statements (@stylistic/padding-line-between-statements) Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Sushant Bhadauria <sushant14bhadauria@gmail.com>
1 parent 841ddd4 commit 5f013fd

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

scripts/js/index.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,13 @@ function populateBlockedListFilter() {
371371

372372
if (!data.lists) return;
373373

374-
data.lists.forEach(list => {
374+
for (const list of data.lists) {
375375
if (list.type === "block" && list.enabled) {
376376
const label =
377377
list.address.length > 50 ? list.address.substring(0, 47) + "..." : list.address;
378378
select.append($("<option>", { value: list.id, text: label, title: list.address }));
379379
}
380-
});
380+
}
381381

382382
// Restore selection if the same list is still present
383383
if (previousVal) select.val(previousVal);
@@ -393,10 +393,11 @@ function fetchDomainAdlistIds(domain) {
393393
.then(data => {
394394
const ids = new Set();
395395
if (data.search && Array.isArray(data.search.gravity)) {
396-
data.search.gravity.forEach(entry => {
396+
for (const entry of data.search.gravity) {
397397
if (typeof entry.id === "number") ids.add(entry.id);
398-
});
398+
}
399399
}
400+
400401
resolve(ids);
401402
})
402403
.fail(() => resolve(new Set()));
@@ -405,7 +406,7 @@ function fetchDomainAdlistIds(domain) {
405406

406407
// Render a list of domain items into the blocked-domains table.
407408
function renderBlockedDomainRows(items, sum, domaintable) {
408-
items.forEach(item => {
409+
for (const item of items) {
409410
const domain = encodeURIComponent(item.domain);
410411
const urlText = domain === "" ? "." : item.domain;
411412
const url = '<a href="queries?domain=' + domain + '&upstream=blocklist">' + urlText + "</a>";
@@ -417,7 +418,7 @@ function renderBlockedDomainRows(items, sum, domaintable) {
417418
utils.addTD(utils.colorBar(percentage, sum, "queries-blocked")) +
418419
"</tr> "
419420
);
420-
});
421+
}
421422
}
422423

423424
function updateTopDomainsTable(blocked) {
@@ -435,7 +436,7 @@ function updateTopDomainsTable(blocked) {
435436
domaintable = $("#ad-frequency").find("tbody:last");
436437

437438
const selectedList = $("#ad-frequency-list-filter").val();
438-
const adlistId = selectedList ? parseInt(selectedList, 10) : -1;
439+
const adlistId = selectedList ? Number.parseInt(selectedList, 10) : -1;
439440

440441
if (adlistId >= 0) {
441442
// ── Filtered mode ────────────────────────────────────────────────────
@@ -482,6 +483,7 @@ function updateTopDomainsTable(blocked) {
482483
} else {
483484
renderBlockedDomainRows(matched, sum, domaintable);
484485
}
486+
485487
overlay.hide();
486488
});
487489
}

0 commit comments

Comments
 (0)