chore: update eslint & eslint plugins (#6487)
Updates ESLint, the TypeScript ESLint plugins, and updates code where the rules have changed.
This commit is contained in:
parent
4846b8723c
commit
f04bec5a15
248
.eslintrc.js
248
.eslintrc.js
@ -1,44 +1,50 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
"root": true,
|
root: true,
|
||||||
"env": {
|
env: {
|
||||||
"node": true,
|
node: true,
|
||||||
"es6": true
|
es6: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
"parser": "@typescript-eslint/parser",
|
parser: '@typescript-eslint/parser',
|
||||||
|
|
||||||
"plugins": [
|
plugins: ['mocha', '@typescript-eslint', 'unicorn', 'import'],
|
||||||
"mocha",
|
|
||||||
"@typescript-eslint",
|
|
||||||
"unicorn",
|
|
||||||
"import"
|
|
||||||
],
|
|
||||||
|
|
||||||
"extends": [
|
extends: ['plugin:prettier/recommended'],
|
||||||
"plugin:prettier/recommended"
|
|
||||||
],
|
|
||||||
|
|
||||||
"rules": {
|
rules: {
|
||||||
// Error if files are not formatted with Prettier correctly.
|
// Error if files are not formatted with Prettier correctly.
|
||||||
"prettier/prettier": 2,
|
'prettier/prettier': 2,
|
||||||
// syntax preferences
|
// syntax preferences
|
||||||
"quotes": [2, "single", {
|
quotes: [
|
||||||
"avoidEscape": true,
|
2,
|
||||||
"allowTemplateLiterals": true
|
'single',
|
||||||
}],
|
{
|
||||||
"spaced-comment": [2, "always", {
|
avoidEscape: true,
|
||||||
"markers": ["*"]
|
allowTemplateLiterals: true,
|
||||||
}],
|
},
|
||||||
"eqeqeq": [2],
|
],
|
||||||
"accessor-pairs": [2, {
|
'spaced-comment': [
|
||||||
"getWithoutSet": false,
|
2,
|
||||||
"setWithoutGet": false
|
'always',
|
||||||
}],
|
{
|
||||||
"new-parens": 2,
|
markers: ['*'],
|
||||||
"func-call-spacing": 2,
|
},
|
||||||
"prefer-const": 2,
|
],
|
||||||
|
eqeqeq: [2],
|
||||||
|
'accessor-pairs': [
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
getWithoutSet: false,
|
||||||
|
setWithoutGet: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'new-parens': 2,
|
||||||
|
'func-call-spacing': 2,
|
||||||
|
'prefer-const': 2,
|
||||||
|
|
||||||
"max-len": [2, {
|
'max-len': [
|
||||||
|
2,
|
||||||
|
{
|
||||||
/* this setting doesn't impact things as we use Prettier to format
|
/* this setting doesn't impact things as we use Prettier to format
|
||||||
* our code and hence dictate the line length.
|
* our code and hence dictate the line length.
|
||||||
* Prettier aims for 80 but sometimes makes the decision to go just
|
* Prettier aims for 80 but sometimes makes the decision to go just
|
||||||
@ -47,95 +53,131 @@ module.exports = {
|
|||||||
* set it to something far higher than Prettier would allow to avoid
|
* set it to something far higher than Prettier would allow to avoid
|
||||||
* it causing issues and conflicting with Prettier.
|
* it causing issues and conflicting with Prettier.
|
||||||
*/
|
*/
|
||||||
"code": 200,
|
code: 200,
|
||||||
"comments": 90,
|
comments: 90,
|
||||||
"ignoreTemplateLiterals": true,
|
ignoreTemplateLiterals: true,
|
||||||
"ignoreUrls": true,
|
ignoreUrls: true,
|
||||||
"ignoreStrings": true,
|
ignoreStrings: true,
|
||||||
"ignoreRegExpLiterals": true
|
ignoreRegExpLiterals: true,
|
||||||
}],
|
},
|
||||||
|
],
|
||||||
// anti-patterns
|
// anti-patterns
|
||||||
"no-var": 2,
|
'no-var': 2,
|
||||||
"no-with": 2,
|
'no-with': 2,
|
||||||
"no-multi-str": 2,
|
'no-multi-str': 2,
|
||||||
"no-caller": 2,
|
'no-caller': 2,
|
||||||
"no-implied-eval": 2,
|
'no-implied-eval': 2,
|
||||||
"no-labels": 2,
|
'no-labels': 2,
|
||||||
"no-new-object": 2,
|
'no-new-object': 2,
|
||||||
"no-octal-escape": 2,
|
'no-octal-escape': 2,
|
||||||
"no-self-compare": 2,
|
'no-self-compare': 2,
|
||||||
"no-shadow-restricted-names": 2,
|
'no-shadow-restricted-names': 2,
|
||||||
"no-cond-assign": 2,
|
'no-cond-assign': 2,
|
||||||
"no-debugger": 2,
|
'no-debugger': 2,
|
||||||
"no-dupe-keys": 2,
|
'no-dupe-keys': 2,
|
||||||
"no-duplicate-case": 2,
|
'no-duplicate-case': 2,
|
||||||
"no-empty-character-class": 2,
|
'no-empty-character-class': 2,
|
||||||
"no-unreachable": 2,
|
'no-unreachable': 2,
|
||||||
"no-unsafe-negation": 2,
|
'no-unsafe-negation': 2,
|
||||||
"radix": 2,
|
radix: 2,
|
||||||
"valid-typeof": 2,
|
'valid-typeof': 2,
|
||||||
"no-unused-vars": [2, { "args": "none", "vars": "local", "varsIgnorePattern": "([fx]?describe|[fx]?it|beforeAll|beforeEach|afterAll|afterEach)" }],
|
'no-unused-vars': [
|
||||||
"no-implicit-globals": [2],
|
2,
|
||||||
|
{
|
||||||
|
args: 'none',
|
||||||
|
vars: 'local',
|
||||||
|
varsIgnorePattern:
|
||||||
|
'([fx]?describe|[fx]?it|beforeAll|beforeEach|afterAll|afterEach)',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'no-implicit-globals': [2],
|
||||||
|
|
||||||
// es2015 features
|
// es2015 features
|
||||||
"require-yield": 2,
|
'require-yield': 2,
|
||||||
"template-curly-spacing": [2, "never"],
|
'template-curly-spacing': [2, 'never'],
|
||||||
|
|
||||||
// ensure we don't have any it.only or describe.only in prod
|
// ensure we don't have any it.only or describe.only in prod
|
||||||
"mocha/no-exclusive-tests": "error",
|
'mocha/no-exclusive-tests': 'error',
|
||||||
|
|
||||||
// enforce the variable in a catch block is named error
|
// enforce the variable in a catch block is named error
|
||||||
"unicorn/catch-error-name": "error",
|
'unicorn/catch-error-name': 'error',
|
||||||
|
|
||||||
|
'no-restricted-imports': [
|
||||||
"no-restricted-imports": ["error", {
|
'error',
|
||||||
patterns: ["*Events"],
|
|
||||||
paths: [{
|
|
||||||
name: "mitt",
|
|
||||||
message:
|
|
||||||
"Import Mitt from the vendored location: vendor/mitt/src/index.js",
|
|
||||||
}],
|
|
||||||
}],
|
|
||||||
"import/extensions": ["error", "ignorePackages"]
|
|
||||||
},
|
|
||||||
"overrides": [
|
|
||||||
{
|
{
|
||||||
"files": ["*.ts"],
|
patterns: ['*Events'],
|
||||||
"extends": [
|
paths: [
|
||||||
|
{
|
||||||
|
name: 'mitt',
|
||||||
|
message:
|
||||||
|
'Import Mitt from the vendored location: vendor/mitt/src/index.js',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'import/extensions': ['error', 'ignorePackages'],
|
||||||
|
},
|
||||||
|
overrides: [
|
||||||
|
{
|
||||||
|
files: ['*.ts'],
|
||||||
|
extends: [
|
||||||
'plugin:@typescript-eslint/eslint-recommended',
|
'plugin:@typescript-eslint/eslint-recommended',
|
||||||
'plugin:@typescript-eslint/recommended',
|
'plugin:@typescript-eslint/recommended',
|
||||||
],
|
],
|
||||||
"rules": {
|
rules: {
|
||||||
"no-unused-vars": 0,
|
'no-unused-vars': 0,
|
||||||
"@typescript-eslint/no-unused-vars": 2,
|
'@typescript-eslint/no-unused-vars': 2,
|
||||||
"func-call-spacing": 0,
|
'func-call-spacing': 0,
|
||||||
"@typescript-eslint/func-call-spacing": 2,
|
'@typescript-eslint/func-call-spacing': 2,
|
||||||
"semi": 0,
|
semi: 0,
|
||||||
"@typescript-eslint/semi": 2,
|
'@typescript-eslint/semi': 2,
|
||||||
"@typescript-eslint/no-empty-function": 0,
|
'@typescript-eslint/no-empty-function': 0,
|
||||||
"@typescript-eslint/no-use-before-define": 0,
|
'@typescript-eslint/no-use-before-define': 0,
|
||||||
// We have to use any on some types so the warning isn't valuable.
|
// We have to use any on some types so the warning isn't valuable.
|
||||||
"@typescript-eslint/no-explicit-any": 0,
|
'@typescript-eslint/no-explicit-any': 0,
|
||||||
// We don't require explicit return types on basic functions or
|
// We don't require explicit return types on basic functions or
|
||||||
// dummy functions in tests, for example
|
// dummy functions in tests, for example
|
||||||
"@typescript-eslint/explicit-function-return-type": 0,
|
'@typescript-eslint/explicit-function-return-type': 0,
|
||||||
// We know it's bad and use it very sparingly but it's needed :(
|
// We know it's bad and use it very sparingly but it's needed :(
|
||||||
"@typescript-eslint/ban-ts-ignore": 0,
|
'@typescript-eslint/ban-ts-ignore': 0,
|
||||||
"@typescript-eslint/array-type": [2, {
|
/**
|
||||||
"default": "array-simple"
|
* This is the default options (as per
|
||||||
}]
|
* https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/ban-types.md),
|
||||||
}
|
*
|
||||||
|
* Unfortunately there's no way to
|
||||||
|
*/
|
||||||
|
'@typescript-eslint/ban-types': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
extendDefaults: true,
|
||||||
|
types: {
|
||||||
|
/*
|
||||||
|
* Puppeteer's API accepts generic functions in many places so it's
|
||||||
|
* not a useful linting rule to ban the `Function` type. This turns off
|
||||||
|
* the banning of the `Function` type which is a default rule.
|
||||||
|
*/
|
||||||
|
Function: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'@typescript-eslint/array-type': [
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
default: 'array-simple',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"files": ["test-browser/**/*.js"],
|
files: ['test-browser/**/*.js'],
|
||||||
"parserOptions": {
|
parserOptions: {
|
||||||
"sourceType": "module"
|
sourceType: 'module',
|
||||||
},
|
},
|
||||||
"env": {
|
env: {
|
||||||
"es6": true,
|
es6: true,
|
||||||
"browser": true,
|
browser: true,
|
||||||
"es2020": true
|
es2020: true,
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
};
|
};
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
waitFor(selectorOrFunctionOrTimeout: string | number | Function, options?: {}, ...args: SerializableOrJSHandle[]): Promise<JSHandle | null>;
|
waitFor(selectorOrFunctionOrTimeout: string | number | Function, options?: Record<string, unknown>, ...args: SerializableOrJSHandle[]): Promise<JSHandle | null>;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
@ -20,7 +20,7 @@ waitFor(selectorOrFunctionOrTimeout: string | number | Function, options?: {}, .
|
|||||||
| Parameter | Type | Description |
|
| Parameter | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| selectorOrFunctionOrTimeout | string \| number \| Function | a selector, predicate or timeout to wait for. |
|
| selectorOrFunctionOrTimeout | string \| number \| Function | a selector, predicate or timeout to wait for. |
|
||||||
| options | {} | optional waiting parameters. |
|
| options | Record<string, unknown> | optional waiting parameters. |
|
||||||
| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)<!-- -->\[\] | arguments to pass to <code>pageFunction</code>. |
|
| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)<!-- -->\[\] | arguments to pass to <code>pageFunction</code>. |
|
||||||
|
|
||||||
<b>Returns:</b>
|
<b>Returns:</b>
|
||||||
|
@ -9,11 +9,11 @@ Returns a JSON representation of the object.
|
|||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
jsonValue(): Promise<{}>;
|
jsonValue(): Promise<Record<string, unknown>>;
|
||||||
```
|
```
|
||||||
<b>Returns:</b>
|
<b>Returns:</b>
|
||||||
|
|
||||||
Promise<{}>
|
Promise<Record<string, unknown>>
|
||||||
|
|
||||||
## Remarks
|
## Remarks
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ Launches puppeteer and launches a browser instance with given arguments and opti
|
|||||||
```typescript
|
```typescript
|
||||||
launch(options?: LaunchOptions & ChromeArgOptions & BrowserOptions & {
|
launch(options?: LaunchOptions & ChromeArgOptions & BrowserOptions & {
|
||||||
product?: string;
|
product?: string;
|
||||||
extraPrefsFirefox?: {};
|
extraPrefsFirefox?: Record<string, unknown>;
|
||||||
}): Promise<Browser>;
|
}): Promise<Browser>;
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ launch(options?: LaunchOptions & ChromeArgOptions & BrowserOptions & {
|
|||||||
|
|
||||||
| Parameter | Type | Description |
|
| Parameter | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| options | [LaunchOptions](./puppeteer.launchoptions.md) & [ChromeArgOptions](./puppeteer.chromeargoptions.md) & [BrowserOptions](./puppeteer.browseroptions.md) & { product?: string; extraPrefsFirefox?: {}; } | Set of configurable options to set on the browser. |
|
| options | [LaunchOptions](./puppeteer.launchoptions.md) & [ChromeArgOptions](./puppeteer.chromeargoptions.md) & [BrowserOptions](./puppeteer.browseroptions.md) & { product?: string; extraPrefsFirefox?: Record<string, unknown>; } | Set of configurable options to set on the browser. |
|
||||||
|
|
||||||
<b>Returns:</b>
|
<b>Returns:</b>
|
||||||
|
|
||||||
|
16
package.json
16
package.json
@ -73,18 +73,18 @@
|
|||||||
"@types/sinon": "^9.0.4",
|
"@types/sinon": "^9.0.4",
|
||||||
"@types/tar-fs": "^1.16.2",
|
"@types/tar-fs": "^1.16.2",
|
||||||
"@types/ws": "^7.2.4",
|
"@types/ws": "^7.2.4",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.28.0",
|
"@typescript-eslint/eslint-plugin": "^4.4.0",
|
||||||
"@typescript-eslint/parser": "^2.28.0",
|
"@typescript-eslint/parser": "^4.4.0",
|
||||||
"@web/test-runner": "^0.8.4",
|
"@web/test-runner": "^0.8.4",
|
||||||
"commonmark": "^0.28.1",
|
"commonmark": "^0.28.1",
|
||||||
"cross-env": "^7.0.2",
|
"cross-env": "^7.0.2",
|
||||||
"dependency-cruiser": "^9.7.0",
|
"dependency-cruiser": "^9.7.0",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^7.10.0",
|
||||||
"eslint-config-prettier": "^6.11.0",
|
"eslint-config-prettier": "^6.12.0",
|
||||||
"eslint-plugin-import": "^2.22.0",
|
"eslint-plugin-import": "^2.22.0",
|
||||||
"eslint-plugin-mocha": "^6.3.0",
|
"eslint-plugin-mocha": "^8.0.0",
|
||||||
"eslint-plugin-prettier": "^3.1.3",
|
"eslint-plugin-prettier": "^3.1.4",
|
||||||
"eslint-plugin-unicorn": "^19.0.1",
|
"eslint-plugin-unicorn": "^22.0.0",
|
||||||
"esprima": "^4.0.0",
|
"esprima": "^4.0.0",
|
||||||
"expect": "^25.2.7",
|
"expect": "^25.2.7",
|
||||||
"husky": "^4.3.0",
|
"husky": "^4.3.0",
|
||||||
@ -95,7 +95,7 @@
|
|||||||
"ncp": "^2.0.0",
|
"ncp": "^2.0.0",
|
||||||
"pixelmatch": "^4.0.2",
|
"pixelmatch": "^4.0.2",
|
||||||
"pngjs": "^5.0.0",
|
"pngjs": "^5.0.0",
|
||||||
"prettier": "^2.0.5",
|
"prettier": "^2.1.2",
|
||||||
"sinon": "^9.0.2",
|
"sinon": "^9.0.2",
|
||||||
"text-diff": "^1.0.1",
|
"text-diff": "^1.0.1",
|
||||||
"ts-node": "^9.0.0",
|
"ts-node": "^9.0.0",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
"extends": "../.eslintrc.js",
|
extends: '../.eslintrc.js',
|
||||||
/**
|
/**
|
||||||
* ESLint rules
|
* ESLint rules
|
||||||
*
|
*
|
||||||
@ -9,8 +9,11 @@ module.exports = {
|
|||||||
* "rule-name", [severity, { opts }]
|
* "rule-name", [severity, { opts }]
|
||||||
* Severity: 2 == error, 1 == warning, 0 == off.
|
* Severity: 2 == error, 1 == warning, 0 == off.
|
||||||
*/
|
*/
|
||||||
"rules": {
|
rules: {
|
||||||
"no-console": [2, { "allow": ["warn", "error", "assert", "timeStamp", "time", "timeEnd"] }],
|
'no-console': [
|
||||||
"no-debugger": 0,
|
2,
|
||||||
}
|
{ allow: ['warn', 'error', 'assert', 'timeStamp', 'time', 'timeEnd'] },
|
||||||
|
],
|
||||||
|
'no-debugger': 0,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
@ -95,11 +95,13 @@ export class Connection extends EventEmitter {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_rawSend(message: {}): number {
|
_rawSend(message: Record<string, unknown>): number {
|
||||||
const id = ++this._lastId;
|
const id = ++this._lastId;
|
||||||
message = JSON.stringify(Object.assign({}, message, { id }));
|
const stringifiedMessage = JSON.stringify(
|
||||||
debugProtocolSend(message);
|
Object.assign({}, message, { id })
|
||||||
this._transport.send(message);
|
);
|
||||||
|
debugProtocolSend(stringifiedMessage);
|
||||||
|
this._transport.send(stringifiedMessage);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +184,7 @@ export class Connection extends EventEmitter {
|
|||||||
interface CDPSessionOnMessageObject {
|
interface CDPSessionOnMessageObject {
|
||||||
id?: number;
|
id?: number;
|
||||||
method: string;
|
method: string;
|
||||||
params: {};
|
params: Record<string, unknown>;
|
||||||
error: { message: string; data: any };
|
error: { message: string; data: any };
|
||||||
result?: any;
|
result?: any;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ export class FrameManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async initialize(): Promise<void> {
|
async initialize(): Promise<void> {
|
||||||
const result = await Promise.all<{}, Protocol.Page.GetFrameTreeResponse>([
|
const result = await Promise.all([
|
||||||
this._client.send('Page.enable'),
|
this._client.send('Page.enable'),
|
||||||
this._client.send('Page.getFrameTree'),
|
this._client.send('Page.getFrameTree'),
|
||||||
]);
|
]);
|
||||||
@ -1062,7 +1062,7 @@ export class Frame {
|
|||||||
*/
|
*/
|
||||||
waitFor(
|
waitFor(
|
||||||
selectorOrFunctionOrTimeout: string | number | Function,
|
selectorOrFunctionOrTimeout: string | number | Function,
|
||||||
options: {} = {},
|
options: Record<string, unknown> = {},
|
||||||
...args: SerializableOrJSHandle[]
|
...args: SerializableOrJSHandle[]
|
||||||
): Promise<JSHandle | null> {
|
): Promise<JSHandle | null> {
|
||||||
const xPathPattern = '//';
|
const xPathPattern = '//';
|
||||||
|
@ -243,7 +243,7 @@ export class JSHandle {
|
|||||||
* on the object in page and consequent {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse} in puppeteer.
|
* on the object in page and consequent {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse} in puppeteer.
|
||||||
* **NOTE** The method throws if the referenced object is not stringifiable.
|
* **NOTE** The method throws if the referenced object is not stringifiable.
|
||||||
*/
|
*/
|
||||||
async jsonValue(): Promise<{}> {
|
async jsonValue(): Promise<Record<string, unknown>> {
|
||||||
if (this._remoteObject.objectId) {
|
if (this._remoteObject.objectId) {
|
||||||
const response = await this._client.send('Runtime.callFunctionOn', {
|
const response = await this._client.send('Runtime.callFunctionOn', {
|
||||||
functionDeclaration: 'function() { return this; }',
|
functionDeclaration: 'function() { return this; }',
|
||||||
@ -378,10 +378,9 @@ export class ElementHandle<
|
|||||||
element.scrollIntoView({
|
element.scrollIntoView({
|
||||||
block: 'center',
|
block: 'center',
|
||||||
inline: 'center',
|
inline: 'center',
|
||||||
// Chrome still supports behavior: instant but it's not in the spec
|
// @ts-expect-error Chrome still supports behavior: instant but
|
||||||
// so TS shouts We don't want to make this breaking change in
|
// it's not in the spec so TS shouts We don't want to make this
|
||||||
// Puppeteer yet so we'll ignore the line.
|
// breaking change in Puppeteer yet so we'll ignore the line.
|
||||||
// @ts-ignore
|
|
||||||
behavior: 'instant',
|
behavior: 'instant',
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
@ -397,10 +396,9 @@ export class ElementHandle<
|
|||||||
element.scrollIntoView({
|
element.scrollIntoView({
|
||||||
block: 'center',
|
block: 'center',
|
||||||
inline: 'center',
|
inline: 'center',
|
||||||
// Chrome still supports behavior: instant but it's not in the spec
|
// @ts-expect-error Chrome still supports behavior: instant but
|
||||||
// so TS shouts We don't want to make this breaking change in
|
// it's not in the spec so TS shouts We don't want to make this
|
||||||
// Puppeteer yet so we'll ignore the line.
|
// breaking change in Puppeteer yet so we'll ignore the line.
|
||||||
// @ts-ignore
|
|
||||||
behavior: 'instant',
|
behavior: 'instant',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,10 @@ export class Puppeteer {
|
|||||||
launch(
|
launch(
|
||||||
options: LaunchOptions &
|
options: LaunchOptions &
|
||||||
ChromeArgOptions &
|
ChromeArgOptions &
|
||||||
BrowserOptions & { product?: string; extraPrefsFirefox?: {} } = {}
|
BrowserOptions & {
|
||||||
|
product?: string;
|
||||||
|
extraPrefsFirefox?: Record<string, unknown>;
|
||||||
|
} = {}
|
||||||
): Promise<Browser> {
|
): Promise<Browser> {
|
||||||
if (options.product) this._productName = options.product;
|
if (options.product) this._productName = options.product;
|
||||||
return this._launcher.launch(options);
|
return this._launcher.launch(options);
|
||||||
@ -296,7 +299,6 @@ export class Puppeteer {
|
|||||||
* @param queryHandler - The {@link CustomQueryHandler | custom query handler} to
|
* @param queryHandler - The {@link CustomQueryHandler | custom query handler} to
|
||||||
* register.
|
* register.
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
||||||
__experimental_registerCustomQueryHandler(
|
__experimental_registerCustomQueryHandler(
|
||||||
name: string,
|
name: string,
|
||||||
queryHandler: CustomQueryHandler
|
queryHandler: CustomQueryHandler
|
||||||
@ -307,7 +309,6 @@ export class Puppeteer {
|
|||||||
/**
|
/**
|
||||||
* @param name - The name of the query handler to unregistered.
|
* @param name - The name of the query handler to unregistered.
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
||||||
__experimental_unregisterCustomQueryHandler(name: string): void {
|
__experimental_unregisterCustomQueryHandler(name: string): void {
|
||||||
unregisterCustomQueryHandler(name);
|
unregisterCustomQueryHandler(name);
|
||||||
}
|
}
|
||||||
@ -315,7 +316,6 @@ export class Puppeteer {
|
|||||||
/**
|
/**
|
||||||
* @returns a list with the names of all registered custom query handlers.
|
* @returns a list with the names of all registered custom query handlers.
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
||||||
__experimental_customQueryHandlerNames(): string[] {
|
__experimental_customQueryHandlerNames(): string[] {
|
||||||
return customQueryHandlerNames();
|
return customQueryHandlerNames();
|
||||||
}
|
}
|
||||||
@ -323,7 +323,6 @@ export class Puppeteer {
|
|||||||
/**
|
/**
|
||||||
* Clears all registered handlers.
|
* Clears all registered handlers.
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
||||||
__experimental_clearQueryHandlers(): void {
|
__experimental_clearQueryHandlers(): void {
|
||||||
clearCustomQueryHandlers();
|
clearCustomQueryHandlers();
|
||||||
}
|
}
|
||||||
|
@ -97,9 +97,9 @@ describeChromeOnly('Target.createCDPSession', function () {
|
|||||||
expect(error.message).toContain('ThisCommand.DoesNotExist');
|
expect(error.message).toContain('ThisCommand.DoesNotExist');
|
||||||
|
|
||||||
async function theSourceOfTheProblems() {
|
async function theSourceOfTheProblems() {
|
||||||
// This fails in TS as it knows that command does not exist but we want to
|
// @ts-expect-error This fails in TS as it knows that command does not
|
||||||
// have this tests for our users who consume in JS not TS.
|
// exist but we want to have this tests for our users who consume in JS
|
||||||
// @ts-expect-error
|
// not TS.
|
||||||
await client.send('ThisCommand.DoesNotExist');
|
await client.send('ThisCommand.DoesNotExist');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -199,11 +199,10 @@ describe('ElementHandle specs', function () {
|
|||||||
const { page, server } = getTestState();
|
const { page, server } = getTestState();
|
||||||
|
|
||||||
await page.goto(server.PREFIX + '/input/button.html');
|
await page.goto(server.PREFIX + '/input/button.html');
|
||||||
const buttonTextNode = await page.evaluateHandle(
|
const buttonTextNode = await page.evaluateHandle<ElementHandle>(
|
||||||
() => document.querySelector('button').firstChild
|
() => document.querySelector('button').firstChild
|
||||||
);
|
);
|
||||||
let error = null;
|
let error = null;
|
||||||
// @ts-expect-error
|
|
||||||
await buttonTextNode.click().catch((error_) => (error = error_));
|
await buttonTextNode.click().catch((error_) => (error = error_));
|
||||||
expect(error.message).toBe('Node is not of type HTMLElement');
|
expect(error.message).toBe('Node is not of type HTMLElement');
|
||||||
});
|
});
|
||||||
@ -322,11 +321,9 @@ describe('ElementHandle specs', function () {
|
|||||||
it('should throw with invalid query names', () => {
|
it('should throw with invalid query names', () => {
|
||||||
try {
|
try {
|
||||||
const { puppeteer } = getTestState();
|
const { puppeteer } = getTestState();
|
||||||
puppeteer.__experimental_registerCustomQueryHandler(
|
puppeteer.__experimental_registerCustomQueryHandler('1/2/3', {
|
||||||
'1/2/3',
|
queryOne: () => document.querySelector('foo'),
|
||||||
// @ts-expect-error
|
});
|
||||||
() => {}
|
|
||||||
);
|
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Custom query handler name was invalid - throw expected'
|
'Custom query handler name was invalid - throw expected'
|
||||||
);
|
);
|
||||||
|
@ -333,16 +333,16 @@ describe('Keyboard', function () {
|
|||||||
const { page } = getTestState();
|
const { page } = getTestState();
|
||||||
|
|
||||||
let error = await page.keyboard
|
let error = await page.keyboard
|
||||||
// @ts-expect-error
|
// @ts-expect-error bad input
|
||||||
.press('NotARealKey')
|
.press('NotARealKey')
|
||||||
.catch((error_) => error_);
|
.catch((error_) => error_);
|
||||||
expect(error.message).toBe('Unknown key: "NotARealKey"');
|
expect(error.message).toBe('Unknown key: "NotARealKey"');
|
||||||
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error bad input
|
||||||
error = await page.keyboard.press('ё').catch((error_) => error_);
|
error = await page.keyboard.press('ё').catch((error_) => error_);
|
||||||
expect(error && error.message).toBe('Unknown key: "ё"');
|
expect(error && error.message).toBe('Unknown key: "ё"');
|
||||||
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error bad input
|
||||||
error = await page.keyboard.press('😊').catch((error_) => error_);
|
error = await page.keyboard.press('😊').catch((error_) => error_);
|
||||||
expect(error && error.message).toBe('Unknown key: "😊"');
|
expect(error && error.message).toBe('Unknown key: "😊"');
|
||||||
});
|
});
|
||||||
|
@ -442,11 +442,8 @@ describe('Launcher specs', function () {
|
|||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
const { puppeteer } = getTestState();
|
const { puppeteer } = getTestState();
|
||||||
/* launcher is a private property so we don't want our users doing this
|
// @ts-expect-error launcher is a private property that users can't
|
||||||
* but we need to reset the state fully here for testing different
|
// touch, but for testing purposes we need to reset it.
|
||||||
* browser launchers
|
|
||||||
*/
|
|
||||||
// @ts-expect-error
|
|
||||||
puppeteer._lazyLauncher = undefined;
|
puppeteer._lazyLauncher = undefined;
|
||||||
puppeteer._productName = productName;
|
puppeteer._productName = productName;
|
||||||
});
|
});
|
||||||
|
@ -92,8 +92,11 @@ const defaultBrowserOptions = Object.assign(
|
|||||||
`WARN: running ${product} tests with ${defaultBrowserOptions.executablePath}`
|
`WARN: running ${product} tests with ${defaultBrowserOptions.executablePath}`
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// TODO(jackfranklin): declare updateRevision in some form for the Firefox launcher.
|
// TODO(jackfranklin): declare updateRevision in some form for the Firefox
|
||||||
// @ts-expect-error
|
// launcher.
|
||||||
|
// @ts-expect-error _updateRevision is defined on the FF launcher
|
||||||
|
// but not the Chrome one. The types need tidying so that TS can infer that
|
||||||
|
// properly and not error here.
|
||||||
if (product === 'firefox') await puppeteer._launcher._updateRevision();
|
if (product === 'firefox') await puppeteer._launcher._updateRevision();
|
||||||
const executablePath = puppeteer.executablePath();
|
const executablePath = puppeteer.executablePath();
|
||||||
if (!fs.existsSync(executablePath))
|
if (!fs.existsSync(executablePath))
|
||||||
|
@ -193,7 +193,7 @@ describe('navigation', function () {
|
|||||||
|
|
||||||
let error = null;
|
let error = null;
|
||||||
await page
|
await page
|
||||||
// @ts-expect-error
|
// @ts-expect-error purposefully passing an old option
|
||||||
.goto(server.EMPTY_PAGE, { waitUntil: 'networkidle' })
|
.goto(server.EMPTY_PAGE, { waitUntil: 'networkidle' })
|
||||||
.catch((error_) => (error = error_));
|
.catch((error_) => (error = error_));
|
||||||
expect(error.message).toContain(
|
expect(error.message).toContain(
|
||||||
|
@ -516,7 +516,7 @@ describe('network', function () {
|
|||||||
|
|
||||||
let error = null;
|
let error = null;
|
||||||
try {
|
try {
|
||||||
// @ts-expect-error
|
// @ts-expect-error purposeful bad input
|
||||||
await page.setExtraHTTPHeaders({ foo: 1 });
|
await page.setExtraHTTPHeaders({ foo: 1 });
|
||||||
} catch (error_) {
|
} catch (error_) {
|
||||||
error = error_;
|
error = error_;
|
||||||
|
@ -1169,7 +1169,7 @@ describe('Page', function () {
|
|||||||
|
|
||||||
let error = null;
|
let error = null;
|
||||||
try {
|
try {
|
||||||
// @ts-expect-error
|
// @ts-expect-error purposefully passing bad options
|
||||||
await page.addScriptTag('/injectedfile.js');
|
await page.addScriptTag('/injectedfile.js');
|
||||||
} catch (error_) {
|
} catch (error_) {
|
||||||
error = error_;
|
error = error_;
|
||||||
@ -1298,7 +1298,7 @@ describe('Page', function () {
|
|||||||
|
|
||||||
let error = null;
|
let error = null;
|
||||||
try {
|
try {
|
||||||
// @ts-expect-error
|
// @ts-expect-error purposefully passing bad input
|
||||||
await page.addStyleTag('/injectedstyle.css');
|
await page.addStyleTag('/injectedstyle.css');
|
||||||
} catch (error_) {
|
} catch (error_) {
|
||||||
error = error_;
|
error = error_;
|
||||||
@ -1652,7 +1652,7 @@ describe('Page', function () {
|
|||||||
await page.setContent('<select><option value="12"/></select>');
|
await page.setContent('<select><option value="12"/></select>');
|
||||||
let error = null;
|
let error = null;
|
||||||
try {
|
try {
|
||||||
// @ts-expect-error
|
// @ts-expect-error purposefully passing bad input
|
||||||
await page.select('select', 12);
|
await page.select('select', 12);
|
||||||
} catch (error_) {
|
} catch (error_) {
|
||||||
error = error_;
|
error = error_;
|
||||||
|
@ -94,7 +94,7 @@ describe('waittask specs', function () {
|
|||||||
const { page } = getTestState();
|
const { page } = getTestState();
|
||||||
|
|
||||||
let error = null;
|
let error = null;
|
||||||
// @ts-expect-error
|
// @ts-expect-error purposefully passing bad type for test
|
||||||
await page.waitFor({ foo: 'bar' }).catch((error_) => (error = error_));
|
await page.waitFor({ foo: 'bar' }).catch((error_) => (error = error_));
|
||||||
expect(error.message).toContain('Unsupported target type');
|
expect(error.message).toContain('Unsupported target type');
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user