From 65b92de13b98343c1d2d3cd01cf1f11a6e51276e Mon Sep 17 00:00:00 2001 From: Mark Banner Date: Fri, 26 Aug 2022 13:39:38 +0000 Subject: [PATCH] Bug 1786197 - Turn on ESLint rule for prefer-boolean-length-check for tools. r=ahal Differential Revision: https://phabricator.services.mozilla.com/D155176 --- .eslintrc.js | 1 - tools/lint/eslint/eslint-plugin-mozilla/lib/helpers.js | 2 +- .../eslint/eslint-plugin-mozilla/lib/rules/avoid-Date-timing.js | 2 +- .../tests/browser/browser_test_profile_capture_by_pid.js | 2 +- tools/profiler/tests/xpcshell/test_asm.js | 2 +- tools/profiler/tests/xpcshell/test_feature_fileioall.js | 2 +- tools/tryselect/selectors/chooser/static/filter.js | 2 +- 7 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 35003e943c78..cfeefd212993 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -482,7 +482,6 @@ module.exports = { "layout/**", "netwerk/**", "storage/test/unit/test_vacuum.js", - "tools/**", "widget/tests/test_assign_event_data.html", ], rules: { diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/helpers.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/helpers.js index 8478e15bbc0e..5a61960f10cd 100644 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/helpers.js +++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/helpers.js @@ -188,7 +188,7 @@ module.exports = { }, leave(node, parent) { - if (parents.length == 0) { + if (!parents.length) { throw new Error("Left more nodes than entered."); } parents.pop(); diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/avoid-Date-timing.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/avoid-Date-timing.js index 094cf41a0c55..402e1fe7b8aa 100644 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/avoid-Date-timing.js +++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/avoid-Date-timing.js @@ -43,7 +43,7 @@ module.exports = { if ( callee.type !== "Identifier" || callee.name !== "Date" || - node.arguments.length > 0 + node.arguments.length ) { return; } diff --git a/tools/profiler/tests/browser/browser_test_profile_capture_by_pid.js b/tools/profiler/tests/browser/browser_test_profile_capture_by_pid.js index 98e058c60b75..3694ffd93eb8 100644 --- a/tools/profiler/tests/browser/browser_test_profile_capture_by_pid.js +++ b/tools/profiler/tests/browser/browser_test_profile_capture_by_pid.js @@ -57,7 +57,7 @@ async function test_with_filter(fnFilterWithContentId) { const profile = await waitSamplingAndStopAndGetProfile(); await TestUtils.waitForCondition(async function() { - return (await GetPidsWithSamplerThread()).length == 0; + return !(await GetPidsWithSamplerThread()).length; }, "Wait for all sampler threads to stop after profiler stop"); return { contentPid, pidsWithSamplerThread, profile }; diff --git a/tools/profiler/tests/xpcshell/test_asm.js b/tools/profiler/tests/xpcshell/test_asm.js index e1d3ce3dc2a6..ced36ce429af 100644 --- a/tools/profiler/tests/xpcshell/test_asm.js +++ b/tools/profiler/tests/xpcshell/test_asm.js @@ -30,7 +30,7 @@ add_task(async () => { delayMS *= 2; - if (thread0.samples.data.length == 0) { + if (!thread0.samples.data.length) { continue; } diff --git a/tools/profiler/tests/xpcshell/test_feature_fileioall.js b/tools/profiler/tests/xpcshell/test_feature_fileioall.js index 29d82daeecdb..e98b7d2a35d5 100644 --- a/tools/profiler/tests/xpcshell/test_feature_fileioall.js +++ b/tools/profiler/tests/xpcshell/test_feature_fileioall.js @@ -27,7 +27,7 @@ add_task(async () => { // Check for FileIO in any of the background threads. if (thread.name.startsWith("BgIOThreadPool")) { const markers = getInflatedFileIOMarkers(thread, filename); - if (markers.length > 0) { + if (markers.length) { backgroundThread = thread; backgroundThreadFileIO = markers; break; diff --git a/tools/tryselect/selectors/chooser/static/filter.js b/tools/tryselect/selectors/chooser/static/filter.js index 132372665b44..a82ff2920d13 100644 --- a/tools/tryselect/selectors/chooser/static/filter.js +++ b/tools/tryselect/selectors/chooser/static/filter.js @@ -42,7 +42,7 @@ var apply = () => { updateLabels(); if ( - Object.keys(filters).length == 0 || + !Object.keys(filters).length || (Object.keys(filters).length == 1 && "build_type" in filters) ) { selection.value = "";