chore: remove unused eslint-disable directives (#35482)

This commit is contained in:
Yury Semikhatsky 2025-04-03 15:22:14 -07:00 committed by GitHub
parent f9d9c5c512
commit 43622f567f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 44 additions and 40 deletions

View File

@ -217,32 +217,27 @@ const noBooleanCompareRules = {
"@typescript-eslint/no-unnecessary-boolean-literal-compare": 2,
};
const noWebGlobalsRules = {
// This should contain every bulitin from builtins.ts.
"no-restricted-globals": [
"error",
{ "name": "window", "message": "Use InjectedScript.window instead" },
{ "name": "document", "message": "Use InjectedScript.document instead" },
{ "name": "globalThis", "message": "Use InjectedScript.window instead" },
{ "name": "setTimeout", "message": "Use InjectedScript.builtins.setTimeout instead" },
{ "name": "clearTimeout", "message": "Use InjectedScript.builtins.clearTimeout instead" },
{ "name": "setInterval", "message": "Use InjectedScript.builtins.setInterval instead" },
{ "name": "clearInterval", "message": "Use InjectedScript.builtins.clearInterval instead" },
{ "name": "requestAnimationFrame", "message": "Use InjectedScript.builtins.requestAnimationFrame instead" },
{ "name": "cancelAnimationFrame", "message": "Use InjectedScript.builtins.cancelAnimationFrame instead" },
{ "name": "requestIdleCallback", "message": "Use InjectedScript.builtins.requestIdleCallback instead" },
{ "name": "cancelIdleCallback", "message": "Use InjectedScript.builtins.cancelIdleCallback instead" },
{ "name": "performance", "message": "Use InjectedScript.builtins.performance instead" },
{ "name": "eval", "message": "Use InjectedScript.builtins.eval instead" },
{ "name": "Date", "message": "Use InjectedScript.builtins.Date instead" },
{ "name": "Map", "message": "Use InjectedScript.builtins.Map instead" },
{ "name": "Set", "message": "Use InjectedScript.builtins.Set instead" },
],
};
// This should contain every builtin from builtins.ts.
const noWebGlobalsRuleList = [
{ name: "window", message: "Use InjectedScript.window instead" },
{ name: "document", message: "Use InjectedScript.document instead" },
{ name: "globalThis", message: "Use InjectedScript.window instead" },
{ name: "setTimeout", message: "Use InjectedScript.builtins.setTimeout instead" },
{ name: "clearTimeout", message: "Use InjectedScript.builtins.clearTimeout instead" },
{ name: "setInterval", message: "Use InjectedScript.builtins.setInterval instead" },
{ name: "clearInterval", message: "Use InjectedScript.builtins.clearInterval instead" },
{ name: "requestAnimationFrame", message: "Use InjectedScript.builtins.requestAnimationFrame instead" },
{ name: "cancelAnimationFrame", message: "Use InjectedScript.builtins.cancelAnimationFrame instead" },
{ name: "requestIdleCallback", message: "Use InjectedScript.builtins.requestIdleCallback instead" },
{ name: "cancelIdleCallback", message: "Use InjectedScript.builtins.cancelIdleCallback instead" },
{ name: "performance", message: "Use InjectedScript.builtins.performance instead" },
{ name: "eval", message: "Use InjectedScript.builtins.eval instead" },
{ name: "Date", message: "Use InjectedScript.builtins.Date instead" },
{ name: "Map", message: "Use InjectedScript.builtins.Map instead" },
{ name: "Set", message: "Use InjectedScript.builtins.Set instead" },
];
const noNodeGlobalsRules = {
"no-restricted-globals": ["error", { name: "process" }],
};
const noNodeGlobalsRuleList = [{ name: "process" }];
const importOrderRules = {
"import/order": [
@ -367,16 +362,34 @@ export default [
"no-console": "off",
},
},
{
files: [
"packages/playwright-core/src/utils/**/*.ts",
],
languageOptions: languageOptionsWithTsConfig,
rules: {
"no-restricted-globals": [
"error",
...noNodeGlobalsRuleList,
// TODO: reenable once the violations are fixed is utils/isomorphic/*.
// ...noWebGlobalsRules,
],
...noFloatingPromisesRules,
...noBooleanCompareRules,
},
},
{
files: [
"packages/playwright-core/src/server/injected/**/*.ts",
"packages/playwright-core/src/utils/isomorphic/**/*.ts",
"packages/playwright-core/src/server/pageBinding.ts",
"packages/playwright-core/src/server/storageScript.ts",
],
languageOptions: languageOptionsWithTsConfig,
rules: {
...noWebGlobalsRules,
"no-restricted-globals": [
"error",
...noWebGlobalsRuleList,
],
...noFloatingPromisesRules,
...noBooleanCompareRules,
},
@ -385,11 +398,13 @@ export default [
files: [
"packages/playwright-core/src/client/**/*.ts",
"packages/playwright-core/src/protocol/**/*.ts",
"packages/playwright-core/src/utils/**/*.ts",
],
languageOptions: languageOptionsWithTsConfig,
rules: {
...noNodeGlobalsRules,
"no-restricted-globals": [
"error",
...noNodeGlobalsRuleList,
],
...noFloatingPromisesRules,
...noBooleanCompareRules,
},

View File

@ -1,6 +0,0 @@
[*]
./
./isomorphic
../utilsBundle.ts
../zipBundle.ts
../utils/isomorphic

View File

@ -14,8 +14,6 @@
* limitations under the License.
*/
/* eslint-disable no-restricted-globals */
// Make sure to update eslint.config.mjs when changing the list of builitins.
export type Builtins = {
setTimeout: Window['setTimeout'],

View File

@ -178,13 +178,10 @@ export function source(builtins: Builtins) {
function serialize(value: any, handleSerializer: (value: any) => HandleOrValue, visitorInfo: VisitorInfo): SerializedValue {
if (value && typeof value === 'object') {
// eslint-disable-next-line no-restricted-globals
if (typeof globalThis.Window === 'function' && value instanceof globalThis.Window)
return 'ref: <Window>';
// eslint-disable-next-line no-restricted-globals
if (typeof globalThis.Document === 'function' && value instanceof globalThis.Document)
return 'ref: <Document>';
// eslint-disable-next-line no-restricted-globals
if (typeof globalThis.Node === 'function' && value instanceof globalThis.Node)
return 'ref: <Node>';
}