Skip to content

Commit

Permalink
Lint adblocker/tools
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmod committed Sep 18, 2023
1 parent 6b2a89c commit a2c559d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/adblocker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"scripts": {
"clean": "rimraf dist coverage",
"lint": "eslint src adblocker.ts",
"lint": "eslint src tools adblocker.ts",
"build": "tsc --build ./tsconfig.json",
"bundle": "tsc --build ./tsconfig.bundle.json && rollup --config ./rollup.config.ts --configPlugin typescript",
"prepack": "yarn run bundle",
Expand Down
1 change: 1 addition & 0 deletions packages/adblocker/tools/generate_compression_codebooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ function validateCodebook(codebook: string[], strings: string[]): void {
const compressed = smaz.compress(str);
const original = smaz.decompress(compressed);
if (original !== str) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
throw new Error(`Mismatch: ${str} vs. ${original} (compressed: ${compressed})`);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/adblocker/tools/priorities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ async function loadAllLists(): Promise<string> {
}
}

for (const [name, count] of unsupported.entries().sort(([_1, c1], [_2, c2]) => c2 - c1)) {
for (const [name, count] of unsupported.entries().sort(([, c1], [, c2]) => c2 - c1)) {
console.log(`+ ${name} = ${count}`);
}

Expand Down
6 changes: 4 additions & 2 deletions packages/adblocker/tools/stress-test-engine-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ function replacer(option: string): string {
* example `||foo.com$stylesheet,first-party,xhr` would be normalized to
* `||foo.com$css,1p,xhr`.
*/
const REGEX = /third-party|first-party|object-subrequest|stylesheet|subdocument|xmlhttprequest|document/g;
const REGEX =
/third-party|first-party|object-subrequest|stylesheet|subdocument|xmlhttprequest|document/g;
function normalizeFilters(rawFilter: string): string {
if (rawFilter.startsWith('|http*://$')) {
rawFilter = rawFilter.slice(9);
Expand Down Expand Up @@ -183,7 +184,7 @@ async function getRevision(url: string): Promise<string> {
return cached;
}

let data = (await axios.get(url)).data;
let data: string = (await axios.get(url)).data;
if (!data.startsWith('[Ad')) {
const buffer = Buffer.from(
(
Expand Down Expand Up @@ -272,6 +273,7 @@ async function collectTestCases(list: string): Promise<TestCase[]> {
const revisions: Set<string> = new Set();

// Append current revision (the most recent one)
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const previousRevisions = [...meta.revisions];
console.log('revisions', previousRevisions);

Expand Down
2 changes: 2 additions & 0 deletions packages/adblocker/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
],
"include": [
"./src/**/*.ts",
"./tools/**/*.ts",
"./test/**/*.ts",
"./adblocker.ts"
]
}

0 comments on commit a2c559d

Please sign in to comment.