-
-
Notifications
You must be signed in to change notification settings - Fork 418
Closed
Labels
Description
Description
A special case of no-magic-numbers rule.
When calling Array#flat(depth) with depth. Normally the depth should be 1/Number.POSITIVE_INFINITY. Otherwise it should be reported, but I don't want this rule to get annoying, so
- If it's not a number literal, we assume user know the max depth.
- If there is a comment before the number, we assume the number is explained.
Fail
array.flat(2);array.flat(99);Pass
array.flat();array.flat(Number.POSITIVE_INFINITY);array.flat(depth);array.flat(/* The depth is always 2 */ 2);Additional Info
This rule should only be useful for users don't want to enable no-magic-numbers, otherwise the failed cases shold already covered.
sindresorhus, papb and fregante