⚡ Replace loose equality by strict one#6446
Conversation
🦋 Changeset detectedLatest commit: d238717 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@copilot please also deal with stuff like 'if(nonBooleanVariable) doX' or 'nonBooleanVariable ? X : Y' and prefer === instead (when legit) |
Co-authored-by: dubzzz <[email protected]>
Co-authored-by: dubzzz <[email protected]>
Co-authored-by: dubzzz <[email protected]>
|
|
||
| let errorMessage = message; | ||
| if (details != null) errorMessage += `\n\n${details}`; | ||
| if (details !== null && details !== undefined) errorMessage += `\n\n${details}`; |
There was a problem hiding this comment.
@copilot are you sure we need to check for both values?
There was a problem hiding this comment.
You're correct! Fixed in commit ec40299. The details variable is typed as string | null in the preFormat functions (initialized to null), so we only need to check for null, not undefined.
Co-authored-by: dubzzz <[email protected]>
Done! I've replaced all truthy/falsy checks on boolean variables with explicit strict equality comparisons ( Changes made in commit ce9d304:
Files updated:
|
|
@copilot do not replace truthy/falsy checks for values that are already true/false. Only replace the ones with a check responsible to detect if the value is there |
Co-authored-by: dubzzz <[email protected]>
@fast-check/ava
@fast-check/expect-type
fast-check
@fast-check/jest
@fast-check/packaged
@fast-check/poisoning
@fast-check/vitest
@fast-check/worker
commit: |
|
👋 A preview of the new documentation is available at: http://696abd7e77da3f90a94ecad9--dubzzz-fast-check.netlify.app |
Co-authored-by: dubzzz <[email protected]>
You're absolutely right! Fixed in commit c100722. Reverted boolean variable checks back to using the negation operator ( The changes now follow this principle:
Reverted 9 instances across 6 files:
|
|
👋 A preview of the new documentation is available at: http://696abff5690b5e373e3873be--dubzzz-fast-check.netlify.app |
Applied by GitHub Action workflow: PR Format Run ID: 21083234699 Target PR: 6446
|
👋 A preview of the new documentation is available at: http://696ac10f0ace9a285854a8e3--dubzzz-fast-check.netlify.app |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6446 +/- ##
==========================================
+ Coverage 94.84% 94.85% +0.01%
==========================================
Files 207 207
Lines 5570 5581 +11
Branches 1457 1466 +9
==========================================
+ Hits 5283 5294 +11
Misses 274 274
Partials 13 13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ast-check/[email protected], @fast-check/[email protected], @fast-check/[email protected], @fast-check/[email protected], @fast-check/[email protected] (#6706) Resulting CHANGELOG at: - https://github.com/dubzzz/fast-check/blob/changelog-c91edcb2009e78/packages/fast-check/CHANGELOG.md - https://github.com/dubzzz/fast-check/blob/changelog-c91edcb2009e78/packages/ava/CHANGELOG.md - https://github.com/dubzzz/fast-check/blob/changelog-c91edcb2009e78/packages/vitest/CHANGELOG.md - https://github.com/dubzzz/fast-check/blob/changelog-c91edcb2009e78/packages/poisoning/CHANGELOG.md - https://github.com/dubzzz/fast-check/blob/changelog-c91edcb2009e78/packages/packaged/CHANGELOG.md - https://github.com/dubzzz/fast-check/blob/changelog-c91edcb2009e78/packages/jest/CHANGELOG.md - https://github.com/dubzzz/fast-check/blob/changelog-c91edcb2009e78/packages/worker/CHANGELOG.md Got the following errors: -⚠️ Unhandled type: ⚡ on [PR-6446](#6446) with title Replace loose equality by strict one -⚠️ Unhandled type: ⚡ on [PR-6444](#6444) with title Slightly faster code for RunExecution - ℹ️ Scanned 208 PRs for fast-check: - ℹ️ • accepted: 71, - ℹ️ • skipped ignored: 108, - ℹ️ • skipped unrelated: 27, - ℹ️ • failed: 2 - ℹ️ Scanned 697 PRs for @fast-check/ava: - ℹ️ • accepted: 5, - ℹ️ • skipped ignored: 0, - ℹ️ • skipped unrelated: 692, - ℹ️ • failed: 0 - ℹ️ Scanned 277 PRs for @fast-check/vitest: - ℹ️ • accepted: 6, - ℹ️ • skipped ignored: 0, - ℹ️ • skipped unrelated: 271, - ℹ️ • failed: 0 - ℹ️ Scanned 697 PRs for @fast-check/poisoning: - ℹ️ • accepted: 4, - ℹ️ • skipped ignored: 0, - ℹ️ • skipped unrelated: 693, - ℹ️ • failed: 0 - ℹ️ Scanned 697 PRs for @fast-check/packaged: - ℹ️ • accepted: 4, - ℹ️ • skipped ignored: 0, - ℹ️ • skipped unrelated: 693, - ℹ️ • failed: 0 - ℹ️ Scanned 655 PRs for @fast-check/jest: - ℹ️ • accepted: 3, - ℹ️ • skipped ignored: 0, - ℹ️ • skipped unrelated: 652, - ℹ️ • failed: 0 - ℹ️ Scanned 670 PRs for @fast-check/worker: - ℹ️ • accepted: 9, - ℹ️ • skipped ignored: 0, - ℹ️ • skipped unrelated: 661, - ℹ️ • failed: 0 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Nicolas DUBIEN <[email protected]>
Plan: Replace loose equality and truthy/falsy checks with strict equality
!= nullwith!== null && !== undefined== nullwith=== null || === undefined== truewith=== true(except for intentional unboxing)== 1with=== 1!= undefinedwith!== undefinedSummary of Changes
Phase 1: Loose Equality Operators (15 files)
Replaced all
==and!=operators with===and!==Phase 2: Truthy/Falsy Checks - REVERTED
Initially converted boolean negations to
=== false, but reverted because:!for truthiness checks!booleanVaris correct, notbooleanVar === falsePhase 3: Simplify Null/Undefined Checks (7 files)
Based on TypeScript type information, simplified redundant checks:
constraints.freq === undefined(optional property)constraints === undefined(optional parameter)runId !== undefined(optional parameter)runId !== undefined(optional parameter)min/max === undefined(optional parameters)!== nullwhereundefinedalready excluded by type guarddetails !== null(typed asstring | null)Key Principles
===,!==) for all comparisons!) for boolean variable checksTesting
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.