Skip to content

Commit

Permalink
Bump typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
remusao committed Sep 22, 2021
1 parent d181626 commit 8b9aa56
Show file tree
Hide file tree
Showing 21 changed files with 889 additions and 897 deletions.
2 changes: 1 addition & 1 deletion packages/adblocker-benchmarks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"devDependencies": {
"@rollup/plugin-commonjs": "^20.0.0",
"@rollup/plugin-json": "^4.1.0",
"rollup": "^2.55.1",
"rollup": "^2.57.0",
"rollup-plugin-terser": "^7.0.2"
}
}
4 changes: 2 additions & 2 deletions packages/adblocker-content/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
"@rollup/plugin-node-resolve": "^13.0.0",
"@types/node": "^16.9.6",
"rimraf": "^3.0.0",
"rollup": "^2.48.0",
"rollup": "^2.57.0",
"rollup-plugin-sourcemaps": "^0.6.1",
"rollup-plugin-terser": "^7.0.0",
"tslint": "^6.0.0",
"tslint-config-prettier": "^1.18.0",
"tslint-no-unused-expression-chai": "^0.1.4",
"typescript": "^4.1.2"
"typescript": "^4.4.3"
},
"contributors": [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/adblocker-electron-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@
"@types/node-fetch": "^3.0.3",
"tslint": "^6.0.0",
"tslint-config-prettier": "^1.18.0",
"typescript": "^4.1.2"
"typescript": "^4.4.3"
}
}
4 changes: 2 additions & 2 deletions packages/adblocker-electron-preload/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@
"@types/chrome": "^0.0.157",
"electron": "^15.0.0",
"rimraf": "^3.0.0",
"rollup": "^2.48.0",
"rollup": "^2.57.0",
"rollup-plugin-sourcemaps": "^0.6.1",
"tslint": "^6.0.0",
"tslint-config-prettier": "^1.18.0",
"tslint-no-unused-expression-chai": "^0.1.4",
"typescript": "^4.1.2"
"typescript": "^4.4.3"
},
"contributors": [
{
Expand Down
29 changes: 20 additions & 9 deletions packages/adblocker-electron/adblocker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import type {
const PRELOAD_PATH = require.resolve('@cliqz/adblocker-electron-preload');

// https://stackoverflow.com/questions/48854265/why-do-i-see-an-electron-security-warning-after-updating-my-electron-project-t
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = 'true';
// tslint:disable no-string-literal
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';

/**
* Create an instance of `Request` from `Electron.OnBeforeRequestDetails`.
Expand All @@ -27,14 +28,24 @@ export function fromElectronDetails(
details: Electron.OnHeadersReceivedListenerDetails | Electron.OnBeforeRequestListenerDetails,
): Request {
const { id, url, resourceType, referrer, webContentsId } = details;
return Request.fromRawDetails({
_originalRequestDetails: details,
requestId: `${id}`,
sourceUrl: referrer,
tabId: webContentsId,
type: (resourceType || 'other') as ElectronRequestType,
url,
});
return Request.fromRawDetails(
webContentsId
? {
_originalRequestDetails: details,
requestId: `${id}`,
sourceUrl: referrer,
tabId: webContentsId,
type: (resourceType || 'other') as ElectronRequestType,
url,
}
: {
_originalRequestDetails: details,
requestId: `${id}`,
sourceUrl: referrer,
type: (resourceType || 'other') as ElectronRequestType,
url,
},
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/adblocker-electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"tslint": "^6.0.0",
"tslint-config-prettier": "^1.18.0",
"tslint-no-unused-expression-chai": "^0.1.4",
"typescript": "^4.1.2"
"typescript": "^4.4.3"
},
"contributors": [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/adblocker-extended-selectors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"tslint": "^6.0.0",
"tslint-config-prettier": "^1.18.0",
"tslint-no-unused-expression-chai": "^0.1.4",
"typescript": "^4.1.2"
"typescript": "^4.4.3"
},
"contributors": [
{
Expand Down
1 change: 1 addition & 0 deletions packages/adblocker-extended-selectors/src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ const GRAMMAR = [
pos: [],
name,
argument,
subtree: undefined,
},
after,
];
Expand Down
6 changes: 3 additions & 3 deletions packages/adblocker-extended-selectors/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export type Type = Base & {
export type PseudoClass = Base & {
type: 'pseudo-class';
name: string;
argument?: string;
subtree?: AST;
argument: string | undefined;
subtree: AST | undefined;
};

export type PseudoElement = Base & {
Expand Down Expand Up @@ -93,7 +93,7 @@ export interface Complex {
type: 'complex';
combinator: ' ' | '+' | '~' | '>';
right: AST;
left?: AST;
left: AST | undefined;
}

// Multiple selectors together
Expand Down
2 changes: 1 addition & 1 deletion packages/adblocker-playwright-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@types/node-fetch": "^3.0.3",
"tslint": "^6.0.0",
"tslint-config-prettier": "^1.18.0",
"typescript": "^4.1.2"
"typescript": "^4.4.3"
},
"contributors": [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/adblocker-playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"rimraf": "^3.0.0",
"tslint": "^6.0.0",
"tslint-config-prettier": "^1.18.0",
"typescript": "^4.1.2"
"typescript": "^4.4.3"
},
"contributors": [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/adblocker-puppeteer-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@types/node-fetch": "^3.0.3",
"tslint": "^6.0.0",
"tslint-config-prettier": "^1.18.0",
"typescript": "^4.1.2"
"typescript": "^4.4.3"
},
"contributors": [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/adblocker-puppeteer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"tslint": "^6.0.0",
"tslint-config-prettier": "^1.18.0",
"tslint-no-unused-expression-chai": "^0.1.4",
"typescript": "^4.1.2"
"typescript": "^4.4.3"
},
"contributors": [
{
Expand Down
4 changes: 2 additions & 2 deletions packages/adblocker-webextension-cosmetics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"mocha": "^9.0.0",
"nyc": "^15.0.0",
"rimraf": "^3.0.0",
"rollup": "^2.48.0",
"rollup": "^2.57.0",
"rollup-plugin-sourcemaps": "^0.6.1",
"rollup-plugin-terser": "^7.0.0",
"sinon": "^11.1.1",
Expand All @@ -89,7 +89,7 @@
"tslint": "^6.0.0",
"tslint-config-prettier": "^1.18.0",
"tslint-no-unused-expression-chai": "^0.1.4",
"typescript": "^4.1.2"
"typescript": "^4.4.3"
},
"dependencies": {
"@cliqz/adblocker-content": "^1.22.6",
Expand Down
4 changes: 2 additions & 2 deletions packages/adblocker-webextension-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
"@rollup/plugin-node-resolve": "^13.0.0",
"@types/chrome": "^0.0.157",
"rimraf": "^3.0.0",
"rollup": "^2.48.0",
"rollup": "^2.57.0",
"rollup-plugin-sourcemaps": "^0.6.1",
"tslint": "^6.0.0",
"tslint-config-prettier": "^1.18.0",
"typescript": "^4.1.2"
"typescript": "^4.4.3"
},
"contributors": [
{
Expand Down
54 changes: 38 additions & 16 deletions packages/adblocker-webextension/adblocker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,25 @@ type StreamFilter = WebRequest.StreamFilter & {
* Create an instance of `Request` from WebRequest details.
*/
export function fromWebRequestDetails(details: OnBeforeRequestDetailsType): Request {
return Request.fromRawDetails({
_originalRequestDetails: details,
requestId: details.requestId,
sourceUrl: details.initiator || details.originUrl || details.documentUrl,
tabId: details.tabId,
type: details.type,
url: details.url,
});
const sourceUrl = details.initiator || details.originUrl || details.documentUrl;
return Request.fromRawDetails(
sourceUrl
? {
_originalRequestDetails: details,
requestId: details.requestId,
sourceUrl,
tabId: details.tabId,
type: details.type,
url: details.url,
}
: {
_originalRequestDetails: details,
requestId: details.requestId,
tabId: details.tabId,
type: details.type,
url: details.url,
},
);
}

/**
Expand Down Expand Up @@ -472,14 +483,25 @@ export class WebExtensionBlocker extends FiltersEngine {
}

// Proceed with stylesheet injection.
return browser.tabs.insertCSS(tabId, {
allFrames,
code: styles,
cssOrigin: 'user',
frameId,
matchAboutBlank: true,
runAt: 'document_start',
});
return browser.tabs.insertCSS(
tabId,
frameId
? {
allFrames,
code: styles,
cssOrigin: 'user',
frameId,
matchAboutBlank: true,
runAt: 'document_start',
}
: {
allFrames,
code: styles,
cssOrigin: 'user',
matchAboutBlank: true,
runAt: 'document_start',
},
);
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/adblocker-webextension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@
"mocha": "^9.0.0",
"nyc": "^15.0.0",
"rimraf": "^3.0.0",
"rollup": "^2.48.0",
"rollup": "^2.57.0",
"rollup-plugin-sourcemaps": "^0.6.1",
"rollup-plugin-terser": "^7.0.0",
"ts-node": "^10.0.0",
"tslint": "^6.0.0",
"tslint-config-prettier": "^1.18.0",
"tslint-no-unused-expression-chai": "^0.1.4",
"typescript": "^4.1.2"
"typescript": "^4.4.3"
},
"dependencies": {
"@cliqz/adblocker": "^1.22.6",
Expand Down
4 changes: 2 additions & 2 deletions packages/adblocker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@
"mocha": "^9.0.0",
"nyc": "^15.0.0",
"rimraf": "^3.0.0",
"rollup": "^2.48.0",
"rollup": "^2.57.0",
"rollup-plugin-sourcemaps": "^0.6.1",
"rollup-plugin-terser": "^7.0.0",
"ts-node": "^10.0.0",
"tslint": "^6.0.0",
"tslint-config-prettier": "^1.18.0",
"tslint-no-unused-expression-chai": "^0.1.4",
"typescript": "^4.1.2"
"typescript": "^4.4.3"
},
"dependencies": {
"@cliqz/adblocker-content": "^1.22.6",
Expand Down
6 changes: 3 additions & 3 deletions packages/adblocker/src/engine/bucket/cosmetic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,9 @@ export default class CosmeticFilterBucket {
domain: string;
hostname: string;

classes?: string[];
hrefs?: string[];
ids?: string[];
classes: string[] | undefined;
hrefs: string[] | undefined;
ids: string[] | undefined;

allowGenericHides: boolean;
allowSpecificHides: boolean;
Expand Down
22 changes: 17 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,24 @@
"module": "commonjs",
"moduleResolution": "node",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"alwaysStrict": true,
"exactOptionalPropertyTypes": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": false,
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true
"noUnusedLocals": true,
"noUnusedParameters": true,
"strictBindCallApply": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"useUnknownInCatchVariables": true
}
}
Loading

0 comments on commit 8b9aa56

Please sign in to comment.