Skip to content

fix(xt): satisfy strict-boolean-expressions lint on postOnly checks - #30115

Merged
carlosmiei merged 1 commit into
ccxt:masterfrom
rayBastard:fix/xt-strict-boolean-lint
Aug 25, 2026
Merged

fix(xt): satisfy strict-boolean-expressions lint on postOnly checks#30115
carlosmiei merged 1 commit into
ccxt:masterfrom
rayBastard:fix/xt-strict-boolean-lint

Conversation

@rayBastard

@rayBastard rayBastard commented Aug 25, 2026

Copy link
Copy Markdown
Member

Summary

Master enabled @typescript-eslint/strict-boolean-expressions and the two if (postOnly) checks from #30059 now fail the lint lane, breaking unrelated PRs whose merge diff includes xt.ts (e.g. #29449). Switched to if (postOnly === true) matching the bybit/bitget idiom — transpiles to is True in Python, ruff-clean

Testing

  • Scoped eslint on ts/src/xt.ts — clean
  • tsBuild, transpile + ruff — clean, static request tests green in JS, Python, PHP

@carlotestor carlotestor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Replaces two bare if (postOnly) truthiness checks in createOrder/editOrder with explicit if (postOnly === true). Verified this is a real, currently-red lint on master — not a speculative cleanup.

Reproduced on master (9050e94):

ts/src/xt.ts
  2630:13  error  Unexpected nullable boolean value in conditional...  @typescript-eslint/strict-boolean-expressions
  2665:13  error  Unexpected nullable boolean value in conditional...  @typescript-eslint/strict-boolean-expressions

2 problems (2 errors)

On this PR head the same command exits 0.

Root cause

A merge race, not a latent defect. #30082 turned on strict-boolean-expressions (allowNullableBoolean: false) and #30059 added these postOnly blocks — both landed the same day, so #30059 was written against a config that did not yet reject the pattern and never got linted under the new rule.

The nullability comes from the declaration, not the callee: handlePostOnly only ever returns [ true, params ] or [ false, params ], but let postOnly: Bool = undefined (boolean | undefined) is the declared type and destructuring assignment does not narrow it. Hence "nullable boolean".

Correctness

No behaviour change. handlePostOnly never returns undefined, so postOnly === true and postOnly are equivalent for every reachable value — this is pure lint conformance, which is why no test change is warranted (the static fixtures added in #30059 already cover the GTX path).

Scope check

I checked whether this is a partial fix. It is not: of the 8 exchange files touched since the strict-boolean-expressions rollout (alpaca, bingx, bitget, krakenfutures, p2b, pacifica, paradex, xt), xt.ts is the only one that lints red — the other 7 exit 0. The ~40 other bare if (postOnly) sites in ts/src are green because they declare let postOnly = false (non-nullable), so the rule correctly does not fire. This PR closes the whole regression.

Transpile

npx tsx build/transpile.ts xt --force produces exactly the expected 4-line delta and nothing else:

php/xt.php                      | 4 ++--
php/async/xt.php                | 4 ++--
python/ccxt/xt.py               | 4 ++--
python/ccxt/async_support/xt.py | 4 ++--
  • Python: if postOnly:if postOnly is True:
  • PHP: if ($postOnly)if ($postOnly === true)

Both are identity-safe: the Python base handle_post_only returns the literal singletons [True, params] / [False, params], so is True is sound. Go and C# emit IsTrue(IsEqual(postOnly, true)) / isTrue(isEqual(postOnly, true)), matching the 25 existing === true sites already shipped in kucoin/okx. No cross-language risk.

Merge gate: 🟢
Merge probability: 96%

Verdict

Approve. Minimal, correct, and it restores npm run lint to green.

Comment thread ts/src/xt.ts
Comment on lines 2628 to +2630
let postOnly: Bool = undefined;
[ postOnly, params ] = this.handlePostOnly (type === 'market', timeInForce === 'GTX', params);
if (postOnly) {
if (postOnly === true) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking, for future reference: the nullability the rule is complaining about originates on line 2628, not at the check. handlePostOnly only ever returns [ true, params ] or [ false, params ], but Bool is boolean | undefined and the destructuring assignment on 2629 doesn't narrow the declared type — so postOnly stays nullable to the type checker.

=== true is the right call here since it matches the 25 existing sites in kucoin/okx and keeps the transpiled output uniform. Worth noting the other option for new code: the ~40 bare if (postOnly) sites elsewhere in ts/src lint clean purely because they declare let postOnly = false, which sidesteps the nullable type at the source. Nothing to change in this PR.

@carlosmiei
carlosmiei merged commit ba70c25 into ccxt:master Aug 25, 2026
14 checks passed
@carlotestor

Copy link
Copy Markdown
Collaborator

Merge digest

Master's new strict-boolean-expressions lint rule tripped on the two if (postOnly) checks in xt.ts, so they now compare explicitly against true like bybit/bitget.

File Δ What
ts/src/xt.ts +2/−2 postOnly truthiness checks
flowchart LR
  xt["xt"]
Loading

ts/src/xt.ts

@@ -2627,7 +2627,7 @@
-        if (postOnly) {
+        if (postOnly === true) {

@rayBastard
rayBastard deleted the fix/xt-strict-boolean-lint branch August 25, 2026 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants