ecoCode-javascript icon indicating copy to clipboard operation
ecoCode-javascript copied to clipboard

Add rule "Use native Intl.NumberFormat to format numbers"

Open utarwyn opened this issue 8 months ago • 3 comments

There's no need to use a library to display formatted numbers in a recent browser (even IE 11 seems to be supported!). It seems possible to use Intl.NumberFormat for that use case.

Maybe we can also use Intl for other use cases? You can adapt the idea to what it looks better for you.

Check MDN docs and Can I use table

utarwyn avatar May 20 '25 05:05 utarwyn

TERRE team is planning to work on this one

Nephtys avatar May 20 '25 09:05 Nephtys

A few librairies which format numbers: https://numbrojs.com/ and https://github.com/gastonmesseri/numerable and http://numeraljs.com/ and https://formatjs.github.io/ and https://github.com/Mottie/javascript-number-formatter

Sebi11 avatar May 20 '25 10:05 Sebi11

2 MRs opened about this issue: https://github.com/green-code-initiative/creedengo-rules-specifications/pull/400 and https://github.com/green-code-initiative/creedengo-javascript/pull/84

Sebi11 avatar May 30 '25 07:05 Sebi11