chore: fix RxJs import for BiDi (#11299)

This commit is contained in:
Nikolay Vitkov 2023-11-06 06:58:20 +01:00 committed by GitHub
parent 9eeb796885
commit 619d9d0262
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 5 deletions

View File

@ -157,6 +157,8 @@ module.exports = {
'rulesdir/prettier-comments': 'error',
// Enforces clean up of used resources.
'rulesdir/use-using': 'error',
// Enforces consistent file extension
'rulesdir/extensions': 'error',
// Brackets keep code readable.
curly: ['error', 'all'],
// Brackets keep code readable and `return` intentions clear.

View File

@ -19,10 +19,10 @@ import type {
ObservableInput,
ObservedValueOf,
OperatorFunction,
} from '../../third_party/rxjs/rxjs';
import {catchError} from '../../third_party/rxjs/rxjs';
import type {PuppeteerLifeCycleEvent} from '../cdp/LifecycleWatcher';
import {ProtocolError, TimeoutError} from '../common/Errors';
} from '../../third_party/rxjs/rxjs.js';
import {catchError} from '../../third_party/rxjs/rxjs.js';
import type {PuppeteerLifeCycleEvent} from '../cdp/LifecycleWatcher.js';
import {ProtocolError, TimeoutError} from '../common/Errors.js';
export type BiDiNetworkIdle = Extract<
PuppeteerLifeCycleEvent,

View File

@ -33,7 +33,6 @@
* find the one closest to our Chrome revision.
*/
// eslint-disable-next-line import/extensions
import {execSync} from 'child_process';
import packageJson from '../package.json' assert {type: 'json'};

View File

@ -0,0 +1,58 @@
/**
* Copyright 2023 Google Inc. All rights reserved.
*
* 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.
*/
import {ESLintUtils} from '@typescript-eslint/utils';
const createRule = ESLintUtils.RuleCreator(name => {
return `https://github.com/puppeteer/puppeteer/tree/main/tools/eslint/${name}.js`;
});
const enforceExtensionRule = createRule<[], 'extensionsRule'>({
name: 'extensions',
meta: {
docs: {
description: 'Requires `.js` for imports',
requiresTypeChecking: false,
},
messages: {
extensionsRule: 'Add `.js` to import.',
},
schema: [],
fixable: 'code',
type: 'problem',
},
defaultOptions: [],
create(context) {
return {
ImportDeclaration(node): void {
const file = node.source.value.split('/').pop();
if (!node.source.value.startsWith('.') || file?.includes('.')) {
return;
}
context.report({
node: node.source,
messageId: 'extensionsRule',
fix(fixer) {
return fixer.replaceText(node.source, `'${node.source.value}.js'`);
},
});
},
};
},
});
export = enforceExtensionRule;