summaryrefslogtreecommitdiffstats
path: root/.eslintrc.js
diff options
context:
space:
mode:
Diffstat (limited to '.eslintrc.js')
-rw-r--r--.eslintrc.js255
1 files changed, 242 insertions, 13 deletions
diff --git a/.eslintrc.js b/.eslintrc.js
index af24ad0225..d51508e5f7 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -191,7 +191,7 @@ module.exports = {
},
},
{
- ...browserTestConfig,
+ ...removeOverrides(browserTestConfig),
files: testPaths.browser.map(path => `${path}**`),
excludedFiles: ["**/*.jsm", "**/*.mjs"],
},
@@ -222,6 +222,43 @@ module.exports = {
],
},
{
+ // Some directories have multiple kinds of tests, and some rules
+ // don't work well for HTML-based mochitests, so disable those.
+ files: testPaths.xpcshell
+ .concat(testPaths.browser)
+ .map(path => [`${path}/**/*.html`, `${path}/**/*.xhtml`])
+ .flat(),
+ rules: {
+ // plain/chrome mochitests don't automatically include Assert, so
+ // autofixing `ok()` to Assert.something is bad.
+ "mozilla/no-comparison-or-assignment-inside-ok": "off",
+ },
+ },
+ {
+ files: ["**/test/**", "**/tests/**"],
+ extends: ["plugin:mozilla/general-test"],
+ },
+ {
+ // Some directories reuse `test_foo.js` files between mochitest-plain and
+ // unit tests, or use custom postMessage-based assertion propagation into
+ // browser tests. Ignore those too:
+ files: [
+ // Reuses xpcshell unit test scripts in mochitest-plain HTML files.
+ "dom/indexedDB/test/**",
+ // Dispatches functions to the webpage in ways that are hard to detect.
+ "toolkit/components/antitracking/test/**",
+ ],
+ rules: {
+ "mozilla/no-comparison-or-assignment-inside-ok": "off",
+ },
+ },
+ {
+ files: ["browser/base/content/browser.js"],
+ rules: {
+ "mozilla/no-more-globals": "error",
+ },
+ },
+ {
// Bug 881389 - Complete switching to console.createInstance from custom
// modules. To support the gradual switch, we log these as warnings until
// they have been transitioned.
@@ -241,7 +278,6 @@ module.exports = {
"browser/components/shell/ShellService.sys.mjs",
"browser/components/syncedtabs/TabListComponent.sys.mjs",
"browser/components/uitour/UITour.sys.mjs",
- "browser/components/urlbar/**",
"browser/tools/mozscreenshots/mozscreenshots/extension/Screenshot.sys.mjs",
"devtools/client/webconsole/test/**",
"devtools/shared/tests/xpcshell/test_console_filtering.js",
@@ -268,7 +304,6 @@ module.exports = {
"toolkit/modules/GMPInstallManager.sys.mjs",
"toolkit/modules/OSKeyStore.sys.mjs",
"toolkit/modules/ProfileAge.sys.mjs",
- "toolkit/modules/Sqlite.sys.mjs",
"toolkit/modules/tests/xpcshell/test_Log*.js",
"toolkit/mozapps/defaultagent/BackgroundTask_defaultagent.sys.mjs",
"toolkit/mozapps/extensions/**",
@@ -279,6 +314,203 @@ module.exports = {
},
},
{
+ // Bug 1881270 - Gradually roll-out no-case-declarations to more areas.
+ files: [
+ "accessible/tests/mochitest/promisified-events.js",
+ "browser/actors/**",
+ "browser/base/content/**",
+ "browser/components/**",
+ "browser/modules/BrowserUsageTelemetry.sys.mjs",
+ "browser/modules/URILoadingHelper.sys.mjs",
+ "devtools/client/**",
+ "devtools/server/**",
+ "devtools/shared/layout/dom-matrix-2d.js",
+ "devtools/startup/DevToolsStartup.sys.mjs",
+ "docshell/test/navigation/file_blockBFCache.html",
+ "docshell/test/navigation/test_bug1375833.html",
+ "docshell/test/unit/AllowJavascriptParent.sys.mjs",
+ "dom/base/test/chrome/window_nsITextInputProcessor.xhtml",
+ "dom/html/test/forms/test_input_sanitization.html",
+ "dom/media/PeerConnection.sys.mjs",
+ "dom/media/autoplay/test/mochitest/test_autoplay_policy_web_audio_AudioParamStream.html",
+ "dom/payments/test/PayerDetailsChromeScript.js",
+ "dom/payments/test/simple_payment_request.html",
+ "dom/push/PushService.sys.mjs",
+ "dom/security/test/referrer-policy/browser_referrer_disallow_cross_site_relaxing.js",
+ "dom/tests/mochitest/bugs/test_bug622361.html",
+ "dom/workers/test/sourcemap_header_debugger.js",
+ "gfx/layers/apz/test/mochitest/**",
+ "intl/locale/tests/unit/test_localeService.js",
+ "layout/tools/layout-debug/LayoutDebugChild.sys.mjs",
+ "layout/tools/reftest/reftest.sys.mjs",
+ "mobile/android/actors/**",
+ "mobile/android/components/geckoview/GeckoViewStartup.sys.mjs",
+ "mobile/android/modules/geckoview/**",
+ "netwerk/test/browser/browser_test_data_channel_observer.js",
+ "netwerk/test/unit/test_proxyconnect.js",
+ "remote/**",
+ "services/fxaccounts/**",
+ "services/sync/**",
+ "testing/mochitest/ShutdownLeaksCollector.sys.mjs",
+ "testing/specialpowers/content/SpecialPowers*.sys.mjs",
+ "toolkit/actors/**",
+ "toolkit/components/**",
+ "toolkit/modules/**",
+ "toolkit/mozapps/downloads/DownloadLastDir.sys.mjs",
+ "toolkit/mozapps/extensions/**",
+ "toolkit/mozapps/update/UpdateListener.sys.mjs",
+ "toolkit/content/widgets/**",
+ "uriloader/exthandler/tests/mochitest/browser_download_open_with_internal_handler.js",
+ "widget/tests/file_test_ime_state_on_focus_move.js",
+ ],
+ rules: {
+ "no-case-declarations": "warn",
+ },
+ },
+ {
+ // Bug 1881268 - Gradually roll-out no-constant-condition to more areas.
+ files: [
+ "accessible/tests/browser/mac/browser_attributed_text.js",
+ "accessible/tests/mochitest/text.js",
+ "browser/base/content/test/general/browser_bug734076.js",
+ "browser/base/content/test/static/**",
+ "browser/components/BrowserContentHandler.sys.mjs",
+ "browser/components/extensions/test/browser/browser_ext_slow_script.js",
+ "browser/components/places/content/places-tree.js",
+ "browser/components/translations/tests/browser/browser_translations_panel_fuzzing.js",
+ "browser/components/translations/tests/browser/browser_translations_full_page_panel_fuzzing.js",
+ "browser/components/urlbar/UrlbarUtils.sys.mjs",
+ "browser/components/urlbar/tests/browser/browser_copying.js",
+ "devtools/client/dom/test/head.js",
+ "devtools/client/framework/browser-toolbox/test/helpers-browser-toolbox.js",
+ "devtools/client/fronts/inspector/rule-rewriter.js",
+ "devtools/client/inspector/**",
+ "devtools/client/netmonitor/**",
+ "devtools/client/performance-new/test/browser/helpers.js",
+ "devtools/client/shared/**",
+ "devtools/client/webconsole/**",
+ "devtools/server/actors/**",
+ "devtools/server/socket/websocket-server.js",
+ "devtools/shared/css/parsing-utils.js",
+ "devtools/shared/inspector/css-logic.js",
+ "devtools/shared/tests/xpcshell/test_csslexer.js",
+ "docshell/test/mochitest/test_bug529119-1.html",
+ "docshell/test/mochitest/test_bug529119-2.html",
+ "docshell/test/navigation/file_sessionhistory_iframe_removal.html",
+ "docshell/test/navigation/test_online_offline_bfcache.html",
+ "dom/base/test/chrome/window_nsITextInputProcessor.xhtml",
+ "dom/base/test/fullscreen/file_fullscreen-bug-1798219.html",
+ "dom/base/test/unit/test_isequalnode.js",
+ "dom/filesystem/tests/script_fileList.js",
+ "dom/media/mediasource/test/test_Eviction_mp4.html",
+ "dom/media/mediasource/test/test_ExperimentalAsync.html",
+ "dom/media/webspeech/recognition/test/test_online_http.html",
+ "dom/media/webspeech/recognition/test/test_online_http_webkit.html",
+ "dom/streams/test/xpcshell/large-pipeto.js",
+ "dom/webtransport/test/xpcshell/test_simple_stream.js",
+ "dom/xhr/tests/terminateSyncXHR_worker.js",
+ "editor/libeditor/tests/test_contenteditable_text_input_handling.html",
+ "editor/libeditor/tests/test_selection_move_commands.html",
+ "gfx/layers/apz/test/mochitest/**",
+ "gfx/layers/layerviewer/layerTreeView.js",
+ "intl/uconv/tests/unit/test_charset_conversion.js",
+ "js/src/builtin/**",
+ "layout/inspector/tests/test_getCSSStyleRules.html",
+ "layout/inspector/tests/test_is_valid_css_color.html",
+ "layout/style/test/property_database.js",
+ "layout/style/test/test_computed_style_grid_with_pseudo.html",
+ "layout/style/test/test_visited_reftests.html",
+ "mobile/android/components/extensions/test/mochitest/test_ext_tabs_events.html",
+ "mobile/android/geckoview/src/androidTest/assets/www/getusermedia_xorigin_container.html",
+ "modules/libjar/test/unit/test_fault_handler.js",
+ "netwerk/test/httpserver/httpd.sys.mjs",
+ "netwerk/test/unit/**",
+ "remote/cdp/domains/content/runtime/ExecutionContext.sys.mjs",
+ "remote/cdp/test/browser/page/browser_printToPDF.js",
+ "remote/marionette/actors/MarionetteCommandsParent.sys.mjs",
+ "remote/shared/messagehandler/transports/RootTransport.sys.mjs",
+ "services/settings/Attachments.sys.mjs",
+ "storage/test/unit/test_storage_service.js",
+ "testing/talos/talos/pageloader/chrome/report.js",
+ "testing/talos/talos/**",
+ "toolkit/components/asyncshutdown/tests/xpcshell/head.js",
+ "toolkit/components/extensions/NativeMessaging.sys.mjs",
+ "toolkit/components/extensions/test/xpcshell/test_ext_i18n.js",
+ "toolkit/components/extensions/test/xpcshell/test_ext_i18n_css.js",
+ "toolkit/components/formautofill/default/FormAutofillPrompter.sys.mjs",
+ "toolkit/components/pictureinpicture/tests/browser_videoEmptied.js",
+ "toolkit/components/printing/tests/browser_print_stream.js",
+ "toolkit/components/telemetry/tests/unit/test_ThirdPartyModulesPing.js",
+ "toolkit/components/terminator/tests/xpcshell/test_terminator_record.js",
+ "toolkit/content/aboutwebrtc/aboutWebrtc.mjs",
+ "toolkit/content/tests/widgets/tree_shared.js",
+ "toolkit/content/widgets/tabbox.js",
+ "toolkit/crashreporter/test/browser/crashreport.sjs",
+ "toolkit/modules/CertUtils.sys.mjs",
+ "toolkit/mozapps/downloads/tests/unit/test_DownloadUtils.js",
+ "toolkit/mozapps/extensions/internal/XPIInstall.sys.mjs",
+ "tools/profiler/tests/**",
+ "uriloader/exthandler/tests/mochitest/browser_save_filenames.js",
+ "widget/tests/browser/browser_test_AZERTY_digit_shortcut.js",
+ "widget/tests/window_composition_text_querycontent.xhtml",
+ ],
+ rules: { "no-constant-condition": "warn" },
+ },
+ {
+ files: [
+ "browser/actors/AboutPocketParent.sys.mjs",
+ "browser/actors/SpeechDispatcherParent.sys.mjs",
+ "browser/base/content/browser-sync.js",
+ "browser/base/content/tabbrowser.js",
+ "browser/components/BrowserContentHandler.sys.mjs",
+ "browser/components/enterprisepolicies/Policies.sys.mjs",
+ "browser/components/messagepreview/actors/AboutMessagePreviewChild.sys.mjs",
+ "browser/components/messagepreview/actors/AboutMessagePreviewParent.sys.mjs",
+ "browser/components/migration/ChromeMigrationUtils.sys.mjs",
+ "browser/components/migration/SafariProfileMigrator.sys.mjs",
+ "browser/components/places/content/places-tree.js",
+ "browser/components/places/content/treeView.js",
+ "browser/extensions/screenshots/build/shot.js",
+ "browser/extensions/webcompat/**",
+ "browser/modules/BackgroundTask_*.sys.mjs",
+ "browser/themes/BuiltInThemes.sys.mjs",
+ "browser/tools/mozscreenshots/mozscreenshots/extension/lib/mozscreenshots-script.js",
+ "browser/tools/mozscreenshots/mozscreenshots/extension/lib/mozscreenshots.html",
+ "devtools/client/**",
+ "devtools/server/actors/inspector/css-logic.js",
+ "devtools/shared/compatibility/bin/update.js",
+ "devtools/shared/discovery/discovery.js",
+ "devtools/shared/protocol/Front.js",
+ "dom/media/webvtt/update-webvtt.js",
+ "gfx/layers/layerviewer/layerTreeView.js",
+ "layout/tools/reftest/reftest-analyzer.xhtml",
+ "mobile/android/geckoview/src/androidTest/**",
+ "services/automation/ServicesAutomation.sys.mjs",
+ "services/settings/RemoteSettings.worker.mjs",
+ "services/sync/modules/SyncDisconnect.sys.mjs",
+ "taskcluster/docker/index-task/insert-indexes.js",
+ "testing/**",
+ "toolkit/actors/NetErrorParent.sys.mjs",
+ "toolkit/components/aboutcheckerboard/content/aboutCheckerboard.js",
+ "toolkit/components/backgroundtasks/BackgroundTask_message.sys.mjs",
+ "toolkit/components/backgroundtasks/BackgroundTasksTestUtils.sys.mjs",
+ "toolkit/components/credentialmanagement/IdentityCredentialPromptService.sys.mjs",
+ "toolkit/components/ml/content/MLEngine.worker.mjs",
+ "toolkit/components/telemetry/pings/BackgroundTask_pingsender.sys.mjs",
+ "toolkit/components/translations/actors/TranslationsParent.sys.mjs",
+ "toolkit/components/translations/content/translations-engine.worker.js",
+ "toolkit/components/xulstore/XULStore.sys.mjs",
+ "toolkit/content/aboutTelemetry.js",
+ "toolkit/content/customElements.js",
+ "toolkit/content/widgets/dialog.js",
+ "toolkit/content/widgets/menu.js",
+ "toolkit/mozapps/update/BackgroundUpdate.sys.mjs",
+ ],
+ rules: {
+ "no-console": "off",
+ },
+ },
+ {
// Bug 877389 - Gradually migrate from Cu.reportError to console.error.
// Enable these as we fix more areas.
files: [
@@ -354,7 +586,6 @@ module.exports = {
"toolkit/components/lz4/lz4.js",
"toolkit/components/messaging-system/**",
"toolkit/components/mozintl/mozIntl.sys.mjs",
- "toolkit/components/narrate/Narrator.jsm",
"toolkit/components/nimbus/**",
"toolkit/components/normandy/**",
"toolkit/components/passwordmgr/**",
@@ -372,7 +603,6 @@ module.exports = {
"toolkit/components/thumbnails/**",
"toolkit/components/timermanager/UpdateTimerManager.*",
"toolkit/components/translation/LanguageDetector.*",
- "toolkit/components/translations/**",
"toolkit/components/url-classifier/**",
"toolkit/components/utils/**",
"toolkit/components/viewsource/**",
@@ -470,6 +700,7 @@ module.exports = {
"mozilla/use-services": "off",
"no-array-constructor": "off",
"no-caller": "off",
+ "no-constant-condition": "off",
"no-control-regex": "off",
"no-else-return": "off",
"no-empty": "off",
@@ -1040,7 +1271,6 @@ module.exports = {
"browser/components/urlbar/tests/browser/browser_view_resultDisplay.js",
"browser/components/urlbar/tests/browser/browser_view_resultTypes_display.js",
"browser/components/urlbar/tests/ext/browser/browser_ext_urlbar_clearInput.js",
- "browser/components/urlbar/tests/quicksuggest/QuickSuggestTestUtils.jsm ",
"browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest.js",
"browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest_block.js",
"browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest_configuration.js",
@@ -1601,7 +1831,6 @@ module.exports = {
"dom/u2f/tests/frame_appid_facet_insecure.html",
"dom/u2f/tests/frame_appid_facet_subdomain.html",
"dom/url/tests/browser_download_after_revoke.js",
- "dom/url/tests/file_url.jsm ",
"dom/url/tests/protocol_worker.js",
"dom/url/tests/test_unknown_url_origin.html",
"dom/url/tests/test_url.html",
@@ -1646,7 +1875,6 @@ module.exports = {
"image/test/browser/head.js",
"image/test/mochitest/test_animated_gif.html",
"image/test/mochitest/test_bug671906.html",
- "intl/locale/tests/LangPackMatcherTestUtils.jsm ",
"layout/base/tests/browser_disableDialogs_onbeforeunload.js",
"layout/base/tests/browser_lazyload_page_load_telemetry_iframe.js",
"layout/base/tests/browser_lazyload_telemetry.js",
@@ -1678,8 +1906,6 @@ module.exports = {
"netwerk/test/browser/browser_103_preload.js",
"netwerk/test/browser/browser_cookie_filtering_subdomain.js",
"netwerk/test/browser/browser_test_favicon.js",
- "netwerk/test/browser/cookie_filtering_helper.jsm",
- "netwerk/test/browser/early_hint_preload_test_helper.jsm ",
"netwerk/test/httpserver/httpd.js",
"netwerk/test/mochitests/file_loadinfo_redirectchain.sjs",
"netwerk/test/mochitests/file_testloadflags_chromescript.js",
@@ -1789,11 +2015,9 @@ module.exports = {
"toolkit/components/httpsonlyerror/tests/browser/browser_errorpage_www_suggestion.js",
"toolkit/components/httpsonlyerror/tests/browser/browser_exception.js",
"toolkit/components/narrate/test/head.js",
- "toolkit/components/normandy/test/NormandyTestUtils.jsm ",
"toolkit/components/normandy/test/browser/browser_RecipeRunner.js",
"toolkit/components/normandy/test/browser/browser_actions_ShowHeartbeatAction.js",
"toolkit/components/normandy/test/browser/head.js",
- "toolkit/components/passwordmgr/test/LoginTestUtils.jsm ",
"toolkit/components/passwordmgr/test/browser/browser_autofill_http.js",
"toolkit/components/passwordmgr/test/browser/browser_context_menu.js",
"toolkit/components/passwordmgr/test/browser/browser_context_menu_iframe.js",
@@ -1983,17 +2207,22 @@ module.exports = {
},
},
{
- files: ["*.html", "*.xhtml", "*.xml"],
+ files: ["**"],
excludedFiles: [
+ // Devtools code, see bug 1525652.
+ "devtools/**",
// Tests specific to JSM
"dom/encoding/test/test_stringencoding.xhtml",
"dom/url/tests/test_bug883784.xhtml",
"dom/url/tests/test_url.xhtml",
"dom/url/tests/test_worker_url.xhtml",
"dom/workers/test/test_chromeWorkerJSM.xhtml",
+ "js/xpconnect/tests/browser/browser_import_mapped_jsm.js",
"js/xpconnect/tests/chrome/test_chrometoSource.xhtml",
"js/xpconnect/tests/chrome/test_expandosharing.xhtml",
"js/xpconnect/tests/chrome/test_xrayic.xhtml",
+ // Code that can't be cleaned until we're ready to remove the old loader.
+ "js/xpconnect/loader/XPCOMUtils.sys.mjs",
],
rules: {
"mozilla/reject-chromeutils-import": "error",