Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace tslint with eslint #3450

Merged
merged 3 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* eslint-env node */
module.exports = {
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-type-checked",
"prettier",
],
parser: "@typescript-eslint/parser",
parserOptions: {
tsconfigRootDir: __dirname,
project: ["./packages/*/tsconfig.json"],
},
plugins: [
"@typescript-eslint",
"prettier",
],
root: true,
rules: {
"prettier/prettier": 2, // Means error
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-redundant-type-constituents": "off",
"@typescript-eslint/no-duplicate-type-constituents": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/require-await": "off",
},
};
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,17 @@
"@remusao/auto-config": "^1.1.2",
"@types/benchmark": "^2.1.3",
"@types/node": "^20.6.2",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@typescript-eslint/parser": "^6.7.0",
"auto": "^11.0.4",
"benchmark": "^2.1.4",
"chalk": "^5.3.0",
"eslint": "^8.49.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"lerna": "^7.3.0",
"patch-package": "^8.0.0",
"prettier": "^3.0.3",
"tslint-no-unused-expression-chai": "^0.1.4",
"typescript": "^5.2.2"
},
"auto": {
Expand Down
6 changes: 2 additions & 4 deletions packages/adblocker-content/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"scripts": {
"clean": "rimraf dist coverage",
"lint": "tslint --config ../../tslint.json --project ./tsconfig.json",
"lint": "eslint 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 All @@ -39,13 +39,11 @@
"@rollup/plugin-node-resolve": "^15.2.1",
"@rollup/plugin-typescript": "^11.1.3",
"@types/node": "^20.6.2",
"eslint": "^8.49.0",
"rimraf": "^5.0.1",
"rollup": "^3.29.2",
"rollup-plugin-sourcemaps": "^0.6.3",
"rollup-plugin-terser": "^7.0.2",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-no-unused-expression-chai": "^0.1.4",
"typescript": "^5.2.2"
},
"contributors": [
Expand Down
5 changes: 2 additions & 3 deletions packages/adblocker-electron-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"scripts": {
"start": "electron index.js",
"lint": "tslint --config ../../tslint.json --project ./tsconfig.json"
"lint": "eslint index.ts"
},
"bugs": {
"url": "https://github.com/cliqz-oss/adblocker/issues"
Expand Down Expand Up @@ -67,8 +67,7 @@
},
"devDependencies": {
"@types/node-fetch": "^3.0.3",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"eslint": "^8.49.0",
"typescript": "^5.2.2"
}
}
6 changes: 2 additions & 4 deletions packages/adblocker-electron-preload/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"scripts": {
"clean": "rimraf dist coverage",
"lint": "tslint --config ../../tslint.json --project ./tsconfig.json",
"lint": "eslint preload.ts",
"build": "tsc --build ./tsconfig.json && rollup --config ./rollup.config.ts --configPlugin typescript",
"bundle": "yarn build",
"prepack": "yarn run bundle"
Expand All @@ -44,12 +44,10 @@
"@rollup/plugin-typescript": "^11.1.3",
"@types/chrome": "^0.0.246",
"electron": "^26.2.1",
"eslint": "^8.49.0",
"rimraf": "^5.0.1",
"rollup": "^3.29.2",
"rollup-plugin-sourcemaps": "^0.6.3",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-no-unused-expression-chai": "^0.1.4",
"typescript": "^5.2.2"
},
"contributors": [
Expand Down
6 changes: 2 additions & 4 deletions packages/adblocker-electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"scripts": {
"clean": "rimraf dist coverage",
"lint": "tslint --config ../../tslint.json --project ./tsconfig.json",
"lint": "eslint adblocker.ts",
"build": "tsc --build ./tsconfig.json",
"bundle": "tsc --build ./tsconfig.bundle.json",
"prepack": "yarn run bundle",
Expand All @@ -46,13 +46,11 @@
"@types/mocha": "^10.0.1",
"chai": "^4.3.8",
"electron": "^26.2.1",
"eslint": "^8.49.0",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"rimraf": "^5.0.1",
"ts-node": "^10.9.1",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-no-unused-expression-chai": "^0.1.4",
"typescript": "^5.2.2"
},
"contributors": [
Expand Down
6 changes: 2 additions & 4 deletions packages/adblocker-extended-selectors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"scripts": {
"clean": "rimraf dist coverage",
"lint": "tslint --config ../../tslint.json --project ./tsconfig.json",
"lint": "eslint src adblocker.ts",
"build": "tsc --build ./tsconfig.json",
"bundle": "tsc --build ./tsconfig.bundle.json",
"prepack": "yarn run bundle",
Expand All @@ -41,14 +41,12 @@
"@types/node": "^20.6.2",
"chai": "^4.3.8",
"chai-as-promised": "^7.1.1",
"eslint": "^8.49.0",
"jsdom": "^22.1.0",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"rimraf": "^5.0.1",
"ts-node": "^10.9.1",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-no-unused-expression-chai": "^0.1.4",
"typescript": "^5.2.2"
},
"contributors": [
Expand Down
3 changes: 2 additions & 1 deletion packages/adblocker-extended-selectors/src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export const RECURSIVE_PSEUDO_CLASSES = new Set([
]);

const TOKENS: { [T in TokenType]: RegExp } = {
attribute: /\[\s*(?:(?<namespace>\*|[-\w]*)\|)?(?<name>[-\w\u{0080}-\u{FFFF}]+)\s*(?:(?<operator>\W?=)\s*(?<value>.+?)\s*(?<caseSensitive>[iIsS])?\s*)?\]/gu,
attribute:
/\[\s*(?:(?<namespace>\*|[-\w]*)\|)?(?<name>[-\w\u{0080}-\u{FFFF}]+)\s*(?:(?<operator>\W?=)\s*(?<value>.+?)\s*(?<caseSensitive>[iIsS])?\s*)?\]/gu,
id: /#(?<name>(?:[-\w\u{0080}-\u{FFFF}]|\\.)+)/gu,
class: /\.(?<name>(?:[-\w\u{0080}-\u{FFFF}]|\\.)+)/gu,
comma: /\s*,\s*/g, // must be before combinator
Expand Down
2 changes: 1 addition & 1 deletion packages/adblocker-extended-selectors/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const tokenTypes = [
'type',
] as const;

export type TokenType = typeof tokenTypes[number];
export type TokenType = (typeof tokenTypes)[number];

export type Base = {
length: number;
Expand Down
5 changes: 2 additions & 3 deletions packages/adblocker-playwright-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"scripts": {
"start": "ts-node --project ./tsconfig.json index.ts",
"lint": "tslint --config ../../tslint.json --project ./tsconfig.json"
"lint": "eslint index.ts"
},
"bugs": {
"url": "https://github.com/cliqz-oss/adblocker/issues"
Expand All @@ -32,8 +32,7 @@
},
"devDependencies": {
"@types/node-fetch": "^3.0.3",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"eslint": "^8.49.0",
"typescript": "^5.2.2"
},
"contributors": [
Expand Down
6 changes: 5 additions & 1 deletion packages/adblocker-playwright/adblocker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ export class BlockingContext {
private readonly onFrameNavigated: (frame: pw.Frame) => Promise<void>;
private readonly onRequest: (route: pw.Route) => void;

constructor(private readonly page: pw.Page, private readonly blocker: PlaywrightBlocker) {
constructor(
private readonly page: pw.Page,
private readonly blocker: PlaywrightBlocker,
) {
this.onFrameNavigated = (frame) => blocker.onFrameNavigated(frame);
this.onRequest = (route: pw.Route) => blocker.onRequest(route);
}
Expand Down Expand Up @@ -266,6 +269,7 @@ export class PlaywrightBlocker extends FiltersEngine {
}

await sleep(500);
// eslint-disable-next-line no-constant-condition
} while (true);
};

Expand Down
5 changes: 2 additions & 3 deletions packages/adblocker-playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"scripts": {
"clean": "rimraf dist coverage",
"lint": "tslint --config ../../tslint.json --project ./tsconfig.json",
"lint": "eslint adblocker.ts",
"build": "tsc --build ./tsconfig.json",
"bundle": "tsc --build ./tsconfig.bundle.json",
"prepack": "yarn run bundle",
Expand All @@ -45,12 +45,11 @@
"@types/chai": "^4.3.6",
"@types/mocha": "^10.0.1",
"chai": "^4.3.8",
"eslint": "^8.49.0",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"playwright": "^1.38.0",
"rimraf": "^5.0.1",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"typescript": "^5.2.2"
},
"contributors": [
Expand Down
5 changes: 2 additions & 3 deletions packages/adblocker-puppeteer-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"scripts": {
"start": "ts-node --project ./tsconfig.json index.ts",
"lint": "tslint --config ../../tslint.json --project ./tsconfig.json"
"lint": "eslint index.ts"
},
"bugs": {
"url": "https://github.com/cliqz-oss/adblocker/issues"
Expand All @@ -32,8 +32,7 @@
},
"devDependencies": {
"@types/node-fetch": "^3.0.3",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"eslint": "^8.49.0",
"typescript": "^5.2.2"
},
"contributors": [
Expand Down
6 changes: 5 additions & 1 deletion packages/adblocker-puppeteer/adblocker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ export class BlockingContext {
private readonly onDomContentLoaded: () => Promise<void>;
private readonly onRequest: (details: puppeteer.HTTPRequest) => void;

constructor(private readonly page: puppeteer.Page, private readonly blocker: PuppeteerBlocker) {
constructor(
private readonly page: puppeteer.Page,
private readonly blocker: PuppeteerBlocker,
) {
this.onFrameNavigated = (frame) => blocker.onFrameNavigated(frame);
this.onDomContentLoaded = () => blocker.onFrameNavigated(this.page.mainFrame());
this.onRequest = (request) => blocker.onRequest(request);
Expand Down Expand Up @@ -276,6 +279,7 @@ export class PuppeteerBlocker extends FiltersEngine {
}

await sleep(500);
// eslint-disable-next-line no-constant-condition
} while (true);
};

Expand Down
6 changes: 2 additions & 4 deletions packages/adblocker-puppeteer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"scripts": {
"clean": "rimraf dist coverage",
"lint": "tslint --config ../../tslint.json --project ./tsconfig.json",
"lint": "eslint adblocker.ts",
"build": "tsc --build ./tsconfig.json",
"bundle": "tsc --build ./tsconfig.bundle.json",
"prepack": "yarn run bundle",
Expand All @@ -45,14 +45,12 @@
"@types/chai": "^4.3.6",
"@types/mocha": "^10.0.1",
"chai": "^4.3.8",
"eslint": "^8.49.0",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"puppeteer": "21.2.1",
"rimraf": "^5.0.1",
"ts-node": "^10.9.1",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-no-unused-expression-chai": "^0.1.4",
"typescript": "^5.2.2"
},
"contributors": [
Expand Down
6 changes: 2 additions & 4 deletions packages/adblocker-webextension-cosmetics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"scripts": {
"clean": "rimraf dist coverage",
"lint": "tslint --config ../../tslint.json --project ./tsconfig.json",
"lint": "eslint 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 Expand Up @@ -77,6 +77,7 @@
"@types/sinon": "^10.0.16",
"@types/sinon-chai": "^3.2.9",
"chai": "^4.3.8",
"eslint": "^8.49.0",
"jsdom": "^22.1.0",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
Expand All @@ -87,9 +88,6 @@
"sinon": "^16.0.0",
"sinon-chai": "^3.7.0",
"ts-node": "^10.9.1",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-no-unused-expression-chai": "^0.1.4",
"typescript": "^5.2.2"
},
"dependencies": {
Expand Down
5 changes: 2 additions & 3 deletions packages/adblocker-webextension-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"scripts": {
"clean": "rimraf dist coverage",
"lint": "tslint --config ../../tslint.json --project ./tsconfig.json",
"lint": "eslint background.ts content-script.ts",
"build": "tsc --build ./tsconfig.json",
"bundle": "rollup --config ./rollup.config.ts --configPlugin typescript",
"watch": "rollup --config ./rollup.config.ts --configPlugin typescript --watch",
Expand All @@ -41,11 +41,10 @@
"@rollup/plugin-node-resolve": "^15.2.1",
"@rollup/plugin-typescript": "^11.1.3",
"@types/chrome": "^0.0.246",
"eslint": "^8.49.0",
"rimraf": "^5.0.1",
"rollup": "^3.29.2",
"rollup-plugin-sourcemaps": "^0.6.3",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"typescript": "^5.2.2"
},
"contributors": [
Expand Down
Loading