Aman-Mittal opened a new issue, #679:
URL: https://github.com/apache/fineract-backoffice-ui/issues/679

   The cheapest entry left in the ratchet. `Array.prototype.sort()` sorts **in 
place**, so it mutates the array it was given; `toSorted()` returns a new one.
   
   ```
   5  src/app/shared/components/data-table/data-table.component.ts
   1  src/app/features/system/business-steps/business-steps.component.ts
   4  
src/app/features/products/accounting/product-accounting-section.component.test.ts
   3  src/app/shared/components/data-table/data-table.component.test.ts
   1  src/app/features/reporting/report-execution.service.test.ts
   ```
   
   ## Why this one is worth doing properly rather than mechanically
   
   Two of the three production call sites are in `data-table.component.ts`, 
which sorts rows it was handed through an `input()`. Sorting those in place 
mutates the caller's array — a signal's value, in most cases — which is how a 
table can reorder data a parent component still believes it owns, without the 
parent's signal ever being set. Swapping to `toSorted()` is the fix, but each 
site is worth a glance to see whether anything downstream was relying on the 
mutation.
   
   Note `toSorted()` needs a reasonably current runtime target; it is available 
in the browsers this project targets and in the Node used for specs.
   
   ## Acceptance
   
   - `unicorn/no-array-sort` is gone from `eslint-suppressions.json` after `npm 
run lint:prune`.
   - `npm run lint` passes and the suite still passes.
   - If any call site genuinely needed in-place mutation, say so in the PR 
rather than working around the rule.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to