From 443ee99a8dc2bdc1a25391c3f4c696eae14c6b4c Mon Sep 17 00:00:00 2001 From: Nikolay Vitkov <34244704+Lightning00Blade@users.noreply.github.com> Date: Tue, 17 Oct 2023 10:30:04 +0200 Subject: [PATCH] chore: fix RxJS import (#11176) --- .eslintrc.js | 44 +++++++++++++++++------- packages/puppeteer-core/src/bidi/Page.ts | 2 +- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 87f9f1c4bd0..76f9c7bcb0a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,6 +1,25 @@ +const {readdirSync} = require('fs'); +const {join} = require('path'); + const rulesDirPlugin = require('eslint-plugin-rulesdir'); + rulesDirPlugin.RULES_DIR = 'tools/eslint/lib'; +function getThirdPartyPackages() { + return readdirSync(join(__dirname, 'packages/puppeteer-core/third_party'), { + withFileTypes: true, + }) + .filter(dirent => { + return dirent.isDirectory(); + }) + .map(({name}) => { + return { + name, + message: `Import \`${name}\` from the vendored location: third_party/${name}/index.js`, + }; + }); +} + module.exports = { root: true, env: { @@ -104,19 +123,6 @@ module.exports = { // ensure we don't have any it.only or describe.only in prod 'mocha/no-exclusive-tests': 'error', - 'no-restricted-imports': [ - 'error', - { - patterns: ['*Events', '*.test.js'], - paths: [ - { - name: 'mitt', - message: - 'Import `mitt` from the vendored location: third_party/mitt/index.js', - }, - ], - }, - ], 'import/order': [ 'error', { @@ -234,6 +240,18 @@ module.exports = { '@typescript-eslint/no-import-type-side-effects': 'error', }, overrides: [ + { + files: 'packages/puppeteer-core/src/**/*.ts', + rules: { + 'no-restricted-imports': [ + 'error', + { + patterns: ['*Events', '*.test.js'], + paths: [...getThirdPartyPackages()], + }, + ], + }, + }, { files: [ 'packages/puppeteer-core/src/**/*.test.ts', diff --git a/packages/puppeteer-core/src/bidi/Page.ts b/packages/puppeteer-core/src/bidi/Page.ts index dc5e298a32e..c183355016e 100644 --- a/packages/puppeteer-core/src/bidi/Page.ts +++ b/packages/puppeteer-core/src/bidi/Page.ts @@ -18,8 +18,8 @@ import type {Readable} from 'stream'; import type * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js'; import type Protocol from 'devtools-protocol'; -import {firstValueFrom, from, raceWith} from 'rxjs'; +import {firstValueFrom, from, raceWith} from '../../third_party/rxjs/rxjs.js'; import type {CDPSession} from '../api/CDPSession.js'; import type {WaitForOptions} from '../api/Frame.js'; import {