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