From cea5dad68624e52ebb2c19851d455f5b47246a4f Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Mon, 27 Jan 2025 20:13:27 -0800 Subject: [PATCH] chore: remove eslint-plugin-internal-playwright (#34510) --- package-lock.json | 9 ---- package.json | 1 - .../playwright-core/src/client/.eslintrc.js | 7 --- .../src/client/eventEmitter.ts | 2 - .../index.js | 20 ------- .../package.json | 5 -- .../rules/await-promise-in-class-returns.js | 54 ------------------- 7 files changed, 98 deletions(-) delete mode 100644 packages/playwright-core/src/client/.eslintrc.js delete mode 100644 utils/eslint-plugin-internal-playwright/index.js delete mode 100644 utils/eslint-plugin-internal-playwright/package.json delete mode 100644 utils/eslint-plugin-internal-playwright/rules/await-promise-in-class-returns.js diff --git a/package-lock.json b/package-lock.json index 031f6b05d8..7df7698964 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,7 +48,6 @@ "electron": "^30.1.2", "esbuild": "^0.18.11", "eslint": "^8.55.0", - "eslint-plugin-internal-playwright": "file:utils/eslint-plugin-internal-playwright", "eslint-plugin-notice": "^0.9.10", "eslint-plugin-react": "^7.35.0", "eslint-plugin-react-hooks": "^4.6.2", @@ -3716,10 +3715,6 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/eslint-plugin-internal-playwright": { - "resolved": "utils/eslint-plugin-internal-playwright", - "link": true - }, "node_modules/eslint-plugin-notice": { "version": "0.9.10", "resolved": "https://registry.npmjs.org/eslint-plugin-notice/-/eslint-plugin-notice-0.9.10.tgz", @@ -8267,10 +8262,6 @@ "xterm": "^5.1.0", "xterm-addon-fit": "^0.7.0" } - }, - "utils/eslint-plugin-internal-playwright": { - "version": "0.0.1", - "dev": true } } } diff --git a/package.json b/package.json index 0bde8c158c..2b138262eb 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,6 @@ "electron": "^30.1.2", "esbuild": "^0.18.11", "eslint": "^8.55.0", - "eslint-plugin-internal-playwright": "file:utils/eslint-plugin-internal-playwright", "eslint-plugin-notice": "^0.9.10", "eslint-plugin-react": "^7.35.0", "eslint-plugin-react-hooks": "^4.6.2", diff --git a/packages/playwright-core/src/client/.eslintrc.js b/packages/playwright-core/src/client/.eslintrc.js deleted file mode 100644 index 38d3ba3f0b..0000000000 --- a/packages/playwright-core/src/client/.eslintrc.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - extends: '../../../.eslintrc.js', - plugins: ['internal-playwright'], - rules: { - 'internal-playwright/await-promise-in-class-returns': 'error', - }, -}; diff --git a/packages/playwright-core/src/client/eventEmitter.ts b/packages/playwright-core/src/client/eventEmitter.ts index c0375a70dc..89d723eb8d 100644 --- a/packages/playwright-core/src/client/eventEmitter.ts +++ b/packages/playwright-core/src/client/eventEmitter.ts @@ -243,7 +243,6 @@ export class EventEmitter implements EventEmitterType { if (options.behavior === 'wait') { const errors: Error[] = []; this._rejectionHandler = error => errors.push(error); - // eslint-disable-next-line internal-playwright/await-promise-in-class-returns return this._waitFor(type).then(() => { if (errors.length) throw errors[0]; @@ -253,7 +252,6 @@ export class EventEmitter implements EventEmitterType { if (options.behavior === 'ignoreErrors') this._rejectionHandler = () => {}; - // eslint-disable-next-line internal-playwright/await-promise-in-class-returns return Promise.resolve(); } diff --git a/utils/eslint-plugin-internal-playwright/index.js b/utils/eslint-plugin-internal-playwright/index.js deleted file mode 100644 index 20deef8cc4..0000000000 --- a/utils/eslint-plugin-internal-playwright/index.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -module.exports = { - rules: { - 'await-promise-in-class-returns': require('./rules/await-promise-in-class-returns'), - } -}; diff --git a/utils/eslint-plugin-internal-playwright/package.json b/utils/eslint-plugin-internal-playwright/package.json deleted file mode 100644 index c6de47abf7..0000000000 --- a/utils/eslint-plugin-internal-playwright/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "eslint-plugin-internal-playwright", - "version": "0.0.1", - "main": "index.js" -} diff --git a/utils/eslint-plugin-internal-playwright/rules/await-promise-in-class-returns.js b/utils/eslint-plugin-internal-playwright/rules/await-promise-in-class-returns.js deleted file mode 100644 index a71412c617..0000000000 --- a/utils/eslint-plugin-internal-playwright/rules/await-promise-in-class-returns.js +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -const { ESLintUtils } = require('@typescript-eslint/utils'); -const tsutils = require('ts-api-utils'); - -module.exports = { - meta: { - type: 'problem', - docs: { - description: 'ensure that return statements in classes await their promises so we always have the full stack trace in channel owners/tracing apiName extraction', - category: 'Best Practices', - recommended: false, - }, - schema: [], - fixable: 'code', - }, - create(context) { - const parserServices = ESLintUtils.getParserServices(context); - return { - 'ClassDeclaration MethodDefinition ReturnStatement': function (statement) { - if (statement.type === 'ReturnStatement' && statement.argument) { - if (tsutils.isThenableType( - parserServices.program.getTypeChecker(), - statement.argument, - parserServices.getTypeAtLocation(statement.argument) - )) { - context.report({ - node: statement, - message: 'Return statement in a class should await a promise so we are able to extract the whole stack trace when reporting it to e.g. Trace Viewer', - fix(fixer) { - const sourceCode = context.getSourceCode(); - const returnKeyword = sourceCode.getFirstToken(statement); - return fixer.insertTextAfter(returnKeyword, ' await'); - } - }); - } - } - }, - }; - }, -};