Bug 1881266 - Enable ESLint recommended rule no-constant-condition globally, warning for existing cases. r=mossop,devtools-reviewers,nchevobbe

Differential Revision: https://phabricator.services.mozilla.com/D202319
This commit is contained in:
Mark Banner 2024-02-26 11:35:41 +00:00
parent fa86f5170e
commit c9b5df99c1
4 changed files with 90 additions and 9 deletions

View file

@ -303,6 +303,95 @@ module.exports = {
"mozilla/use-console-createInstance": "off", "mozilla/use-console-createInstance": "off",
}, },
}, },
{
// 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" },
},
{ {
// Bug 877389 - Gradually migrate from Cu.reportError to console.error. // Bug 877389 - Gradually migrate from Cu.reportError to console.error.
// Enable these as we fix more areas. // Enable these as we fix more areas.
@ -495,6 +584,7 @@ module.exports = {
"mozilla/use-services": "off", "mozilla/use-services": "off",
"no-array-constructor": "off", "no-array-constructor": "off",
"no-caller": "off", "no-caller": "off",
"no-constant-condition": "off",
"no-control-regex": "off", "no-control-regex": "off",
"no-else-return": "off", "no-else-return": "off",
"no-empty": "off", "no-empty": "off",

View file

@ -132,8 +132,6 @@ module.exports = {
"no-cond-assign": 2, "no-cond-assign": 2,
// Allow using the console API. // Allow using the console API.
"no-console": 0, "no-console": 0,
// Allow using constant expressions in conditions like while (true)
"no-constant-condition": 0,
// Allow use of the continue statement. // Allow use of the continue statement.
"no-continue": 0, "no-continue": 0,
// Disallow control characters in regular expressions. // Disallow control characters in regular expressions.

View file

@ -123,9 +123,6 @@ module.exports = {
// Disallow using the console API. // Disallow using the console API.
"no-console": "error", "no-console": "error",
// Allow using constant expressions in conditions like while (true)
"no-constant-condition": "off",
// Allow use of the continue statement. // Allow use of the continue statement.
"no-continue": "off", "no-continue": "off",

View file

@ -218,10 +218,6 @@ module.exports = {
// TODO: This is enabled by default in ESLint's v9 recommended configuration. // TODO: This is enabled by default in ESLint's v9 recommended configuration.
"no-constant-binary-expression": "error", "no-constant-binary-expression": "error",
// XXX Bug 1487642 - decide if we want to enable this or not.
// Disallow constant expressions in conditions
"no-constant-condition": "off",
// If an if block ends with a return no need for an else block // If an if block ends with a return no need for an else block
"no-else-return": "error", "no-else-return": "error",