From b2e123ddca640fd0e863b3393ffc3a3f0ea5509c Mon Sep 17 00:00:00 2001 From: Mark Banner Date: Tue, 9 Nov 2021 08:38:16 +0000 Subject: [PATCH] Bug 1739708 - Turn off ESLint rule mozilla/reject-importGlobalProperties for sjs files. r=Gijs,webdriver-reviewers,whimboo sjs files have a separate sandbox, and require Cu.importGlobalProperties for now. Differential Revision: https://phabricator.services.mozilla.com/D130693 --- .eslintrc.js | 1 - .../search/test/browser/searchSuggestionEngine.sjs | 1 - dom/security/test/https-first/file_referrer_policy.sjs | 1 - remote/cdp/test/browser/network/sjs-cookies.sjs | 1 - testing/mochitest/document-builder.sjs | 1 - .../eslint-plugin-mozilla/lib/configs/recommended.js | 9 +++++++++ 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 6d26e01041cb..14a5168dc480 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -99,7 +99,6 @@ module.exports = { "mozilla/use-services": "warn", "mozilla/use-includes-instead-of-indexOf": "warn", "mozilla/no-compare-against-boolean-literals": "warn", - "mozilla/reject-importGlobalProperties": "warn", }, }, { diff --git a/browser/components/search/test/browser/searchSuggestionEngine.sjs b/browser/components/search/test/browser/searchSuggestionEngine.sjs index ccb6710191ab..515b56984acf 100644 --- a/browser/components/search/test/browser/searchSuggestionEngine.sjs +++ b/browser/components/search/test/browser/searchSuggestionEngine.sjs @@ -1,7 +1,6 @@ /* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ -/* eslint-disable-next-line mozilla/reject-importGlobalProperties */ Cu.importGlobalProperties(["TextEncoder"]); let gTimer; diff --git a/dom/security/test/https-first/file_referrer_policy.sjs b/dom/security/test/https-first/file_referrer_policy.sjs index 153538609ca5..282f7ba09f2c 100644 --- a/dom/security/test/https-first/file_referrer_policy.sjs +++ b/dom/security/test/https-first/file_referrer_policy.sjs @@ -37,7 +37,6 @@ function readQuery(testCase) { function handleRequest(request, response) { response.setHeader("Cache-Control", "no-cache", false); - // eslint-disable-next-line mozilla/reject-importGlobalProperties Cu.importGlobalProperties(["URLSearchParams"]); let query = new URLSearchParams(request.queryString); // Downgrade to test http/https -> HTTP referrer policy diff --git a/remote/cdp/test/browser/network/sjs-cookies.sjs b/remote/cdp/test/browser/network/sjs-cookies.sjs index 345a66880d5c..d9107195a441 100644 --- a/remote/cdp/test/browser/network/sjs-cookies.sjs +++ b/remote/cdp/test/browser/network/sjs-cookies.sjs @@ -1,7 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -// eslint-disable-next-line mozilla/reject-importGlobalProperties Cu.importGlobalProperties(["URLSearchParams"]); function handleRequest(request, response) { diff --git a/testing/mochitest/document-builder.sjs b/testing/mochitest/document-builder.sjs index a18de93509df..8a7ddbd6aaa0 100644 --- a/testing/mochitest/document-builder.sjs +++ b/testing/mochitest/document-builder.sjs @@ -6,7 +6,6 @@ // eslint-disable-next-line mozilla/use-chromeutils-import Cu.import("resource://gre/modules/NetUtil.jsm"); -// eslint-disable-next-line mozilla/reject-importGlobalProperties Cu.importGlobalProperties(["URLSearchParams"]); function loadHTMLFromFile(path) { diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js index e17e17f9a04c..6c3dc2273329 100644 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js +++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js @@ -74,6 +74,15 @@ module.exports = { ], }, }, + { + // TODO Bug 1501127: sjs files have their own sandbox, and do not inherit + // the Window backstage pass directly. Turn this rule off for sjs files for + // now until we develop a solution. + files: ["**/*.sjs"], + rules: { + "mozilla/reject-importGlobalProperties": "off", + }, + }, ], parserOptions: {