feat(biome_js_analyse): added new rule noMagicNumbers#6562
feat(biome_js_analyse): added new rule noMagicNumbers#6562vladimir-ivanov merged 17 commits intobiomejs:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 86af259 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
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 |
7f0b76c to
8a306d7
Compare
CodSpeed Performance ReportMerging #6562 will not alter performanceComparing Summary
|
ematipico
left a comment
There was a problem hiding this comment.
Haven't checked the code yet. I left a couple of things to address
Co-authored-by: Emanuele Stoppa <[email protected]>
addressed the ones you mentioned, thanks for the suggestions. |
arendjr
left a comment
There was a problem hiding this comment.
Nice work!
Regarding "Operands in bitwise operations (e.g., a & 1, a | 2)", I personally think these shouldn't be an exception. 1 and 2 are already exceptions on their own, and more complex numbers are best assigned to a _MASK or _BITS constant IMO. Otherwise, your code is still not giving any explanation as to why these specific bits are relevant.
Co-authored-by: Arend van Beelen jr. <[email protected]>
Co-authored-by: Arend van Beelen jr. <[email protected]>
RE: 1 and 2 are already exceptions on their own - you are right about 1 and 2 being non magical :-), let me update with other examples. |
|
I can now merge if it goes green right? @arendjr |
Summary
Added noMagicNumbers rule.
The rule detects and reports the use of "magic numbers" — numeric literals that are used directly in code without being assigned to a named constant.
The no magic numbers rule ignores:
JSON.stringifyandparseInt(e.g.,JSON.stringify(22),parseInt("123", 25))a & 7,a | 7)<div>{1}</div>){ tax: 0.25 })Example
closes #4333