Use strict equality in the drop, inventory and sacrifice paths #515
No reviewers
Labels
No labels
blocked
duplicate
needs
approval
needs
criteria
needs
estimate
needs
tests
question
step
doing
step
review
step
testing
step
todo
step
uat
type
admin
type
alert
type
bug
type
change
type
defect
type
epic
type
idea
type
incident
type
investigation
type
spike
type
story
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
External/card-drop!515
Loading…
Reference in a new issue
No description provided.
Delete branch "cursor/487-strict-equality"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-up 3 of 3 from #487, split out as you asked on the issue. This is the loose-equality item, and it is deliberately partial - please read the scope note before merging.
What changed: 20 comparisons across the five files the checklist calls out by name,
==to===:src/helpers/InventoryHelper.tssrc/helpers/DropHelpers/GetUnclaimedCardsHelper.tssrc/commands/stats.tssrc/helpers/DropHelpers/GetCardsHelper.tssrc/commands/sacrifice.tsMost are length or quantity checks against
0, or page-index checks, where the two sides were already the same type and this is pure hygiene. The ones actually worth a look are the identity comparisons:Inventory.CardNumber === card.id(both declaredstring) andcard.type === rarity/=== CardRarity.X(both the numericCardRarityenum). I checked the declared types on each before changing it, andtscwould have rejected any comparison between genuinely disjoint types, so nothing here silently changes meaning.The one real risk, stated plainly. Card metadata is
JSON.parsed without validation, socard.typeis declared a number but nothing stops a metadata file containing"type": "1". Under==that string matched the enum; under===it will not, and the card would quietly drop out of/stats, the drop pool and the inventory filters. I think strict is the correct behaviour - a malformed metadata file should be visible rather than silently coerced - but it is a behaviour change on bad input, not a pure refactor. Worth ayarn build && yarn testplus a real/drop,/inventoryand/statsagainst the production card folder before this goes out. I have added a note todocs/cards.mdin #514 asking for parse-level validation of the metadata format.Scope note: 73 loose comparisons across 37 files remain, and the
eqeqeqESLint rule is not enabled here. Enabling it would fail lint on every file not yet swept, so it has to land with the last slice. I stopped at these five because this repo is only writable through the Forgejo contents API one whole file at a time, which puts a hard ceiling on how much mechanical churn fits in a single pass. Happy to keep going in further slices, or if you would rather do it in one shot,yarn lint:fixwitheqeqeqenabled locally will handle the bulk and is a much better use of your time than my API calls.I also raised separately that the
rulesblock ineslint.config.mjsis scoped tofiles: ["./src", "./tests"], which matches no files, soeqeqeqwill need a correctly scoped block rather than an addition to the existing one.Verified locally on
release/0.12.0with exactly these five files changed:tsc --noEmitclean,eslint .clean,jest17/17 suites and 99 tests passing. No overlap with #512, #513 or #514.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.