The actual snapshot is saved in prefer-number-properties.mjs.snap
.
Generated by AVA.
1 | const foo = {[NaN]: 1}
Output
`␊
1 | const foo = {[Number.NaN]: 1}␊
`
Error 1/1
`␊
> 1 | const foo = {[NaN]: 1}␊
| ^^^ Prefer \`Number.NaN\` over \`NaN\`.␊
`
1 | const foo = {[NaN]() {}}
Output
`␊
1 | const foo = {[Number.NaN]() {}}␊
`
Error 1/1
`␊
> 1 | const foo = {[NaN]() {}}␊
| ^^^ Prefer \`Number.NaN\` over \`NaN\`.␊
`
1 | foo[NaN] = 1;
Output
`␊
1 | foo[Number.NaN] = 1;␊
`
Error 1/1
`␊
> 1 | foo[NaN] = 1;␊
| ^^^ Prefer \`Number.NaN\` over \`NaN\`.␊
`
1 | class A {[NaN](){}}
Output
`␊
1 | class A {[Number.NaN](){}}␊
`
Error 1/1
`␊
> 1 | class A {[NaN](){}}␊
| ^^^ Prefer \`Number.NaN\` over \`NaN\`.␊
`
1 | foo = {[NaN]: 1}
Output
`␊
1 | foo = {[Number.NaN]: 1}␊
`
Error 1/1
`␊
> 1 | foo = {[NaN]: 1}␊
| ^^^ Prefer \`Number.NaN\` over \`NaN\`.␊
`
1 | const foo = Infinity;
Output
`␊
1 | const foo = Number.POSITIVE_INFINITY;␊
`
Error 1/1
`␊
> 1 | const foo = Infinity;␊
| ^^^^^^^^ Prefer \`Number.POSITIVE_INFINITY\` over \`Infinity\`.␊
`
1 | if (Number.isNaN(Infinity)) {}
Output
`␊
1 | if (Number.isNaN(Number.POSITIVE_INFINITY)) {}␊
`
Error 1/1
`␊
> 1 | if (Number.isNaN(Infinity)) {}␊
| ^^^^^^^^ Prefer \`Number.POSITIVE_INFINITY\` over \`Infinity\`.␊
`
1 | if (Object.is(foo, Infinity)) {}
Output
`␊
1 | if (Object.is(foo, Number.POSITIVE_INFINITY)) {}␊
`
Error 1/1
`␊
> 1 | if (Object.is(foo, Infinity)) {}␊
| ^^^^^^^^ Prefer \`Number.POSITIVE_INFINITY\` over \`Infinity\`.␊
`
1 | const foo = bar[Infinity];
Output
`␊
1 | const foo = bar[Number.POSITIVE_INFINITY];␊
`
Error 1/1
`␊
> 1 | const foo = bar[Infinity];␊
| ^^^^^^^^ Prefer \`Number.POSITIVE_INFINITY\` over \`Infinity\`.␊
`
1 | const foo = {Infinity};
Output
`␊
1 | const foo = {Infinity: Number.POSITIVE_INFINITY};␊
`
Error 1/1
`␊
> 1 | const foo = {Infinity};␊
| ^^^^^^^^ Prefer \`Number.POSITIVE_INFINITY\` over \`Infinity\`.␊
`
1 | const foo = {Infinity: Infinity};
Output
`␊
1 | const foo = {Infinity: Number.POSITIVE_INFINITY};␊
`
Error 1/1
`␊
> 1 | const foo = {Infinity: Infinity};␊
| ^^^^^^^^ Prefer \`Number.POSITIVE_INFINITY\` over \`Infinity\`.␊
`
1 | const foo = {[Infinity]: -Infinity};
Output
`␊
1 | const foo = {[Number.POSITIVE_INFINITY]: Number.NEGATIVE_INFINITY};␊
`
Error 1/2
`␊
> 1 | const foo = {[Infinity]: -Infinity};␊
| ^^^^^^^^ Prefer \`Number.POSITIVE_INFINITY\` over \`Infinity\`.␊
`
Error 2/2
`␊
> 1 | const foo = {[Infinity]: -Infinity};␊
| ^^^^^^^^^ Prefer \`Number.NEGATIVE_INFINITY\` over \`-Infinity\`.␊
`
1 | const foo = {[-Infinity]: Infinity};
Output
`␊
1 | const foo = {[Number.NEGATIVE_INFINITY]: Number.POSITIVE_INFINITY};␊
`
Error 1/2
`␊
> 1 | const foo = {[-Infinity]: Infinity};␊
| ^^^^^^^^^ Prefer \`Number.NEGATIVE_INFINITY\` over \`-Infinity\`.␊
`
Error 2/2
`␊
> 1 | const foo = {[-Infinity]: Infinity};␊
| ^^^^^^^^ Prefer \`Number.POSITIVE_INFINITY\` over \`Infinity\`.␊
`
1 | const foo = {Infinity: -Infinity};
Output
`␊
1 | const foo = {Infinity: Number.NEGATIVE_INFINITY};␊
`
Error 1/1
`␊
> 1 | const foo = {Infinity: -Infinity};␊
| ^^^^^^^^^ Prefer \`Number.NEGATIVE_INFINITY\` over \`-Infinity\`.␊
`
1 | const {foo = Infinity} = {};
Output
`␊
1 | const {foo = Number.POSITIVE_INFINITY} = {};␊
`
Error 1/1
`␊
> 1 | const {foo = Infinity} = {};␊
| ^^^^^^^^ Prefer \`Number.POSITIVE_INFINITY\` over \`Infinity\`.␊
`
1 | const {foo = -Infinity} = {};
Output
`␊
1 | const {foo = Number.NEGATIVE_INFINITY} = {};␊
`
Error 1/1
`␊
> 1 | const {foo = -Infinity} = {};␊
| ^^^^^^^^^ Prefer \`Number.NEGATIVE_INFINITY\` over \`-Infinity\`.␊
`
1 | const foo = Infinity.toString();
Output
`␊
1 | const foo = Number.POSITIVE_INFINITY.toString();␊
`
Error 1/1
`␊
> 1 | const foo = Infinity.toString();␊
| ^^^^^^^^ Prefer \`Number.POSITIVE_INFINITY\` over \`Infinity\`.␊
`
1 | const foo = -Infinity.toString();
Output
`␊
1 | const foo = -Number.POSITIVE_INFINITY.toString();␊
`
Error 1/1
`␊
> 1 | const foo = -Infinity.toString();␊
| ^^^^^^^^ Prefer \`Number.POSITIVE_INFINITY\` over \`Infinity\`.␊
`
1 | const foo = (-Infinity).toString();
Output
`␊
1 | const foo = (Number.NEGATIVE_INFINITY).toString();␊
`
Error 1/1
`␊
> 1 | const foo = (-Infinity).toString();␊
| ^^^^^^^^^ Prefer \`Number.NEGATIVE_INFINITY\` over \`-Infinity\`.␊
`
1 | const foo = +Infinity;
Output
`␊
1 | const foo = +Number.POSITIVE_INFINITY;␊
`
Error 1/1
`␊
> 1 | const foo = +Infinity;␊
| ^^^^^^^^ Prefer \`Number.POSITIVE_INFINITY\` over \`Infinity\`.␊
`
1 | const foo = +-Infinity;
Output
`␊
1 | const foo = +Number.NEGATIVE_INFINITY;␊
`
Error 1/1
`␊
> 1 | const foo = +-Infinity;␊
| ^^^^^^^^^ Prefer \`Number.NEGATIVE_INFINITY\` over \`-Infinity\`.␊
`
1 | const foo = -Infinity;
Output
`␊
1 | const foo = Number.NEGATIVE_INFINITY;␊
`
Error 1/1
`␊
> 1 | const foo = -Infinity;␊
| ^^^^^^^^^ Prefer \`Number.NEGATIVE_INFINITY\` over \`-Infinity\`.␊
`
1 | const foo = -(-Infinity);
Output
`␊
1 | const foo = -(Number.NEGATIVE_INFINITY);␊
`
Error 1/1
`␊
> 1 | const foo = -(-Infinity);␊
| ^^^^^^^^^ Prefer \`Number.NEGATIVE_INFINITY\` over \`-Infinity\`.␊
`
1 | const foo = 1 - Infinity;
Output
`␊
1 | const foo = 1 - Number.POSITIVE_INFINITY;␊
`
Error 1/1
`␊
> 1 | const foo = 1 - Infinity;␊
| ^^^^^^^^ Prefer \`Number.POSITIVE_INFINITY\` over \`Infinity\`.␊
`
1 | const foo = 1 - -Infinity;
Output
`␊
1 | const foo = 1 - Number.NEGATIVE_INFINITY;␊
`
Error 1/1
`␊
> 1 | const foo = 1 - -Infinity;␊
| ^^^^^^^^^ Prefer \`Number.NEGATIVE_INFINITY\` over \`-Infinity\`.␊
`
1 | const isPositiveZero = value => value === 0 && 1 / value === Infinity;
Output
`␊
1 | const isPositiveZero = value => value === 0 && 1 / value === Number.POSITIVE_INFINITY;␊
`
Error 1/1
`␊
> 1 | const isPositiveZero = value => value === 0 && 1 / value === Infinity;␊
| ^^^^^^^^ Prefer \`Number.POSITIVE_INFINITY\` over \`Infinity\`.␊
`
1 | const isNegativeZero = value => value === 0 && 1 / value === -Infinity;
Output
`␊
1 | const isNegativeZero = value => value === 0 && 1 / value === Number.NEGATIVE_INFINITY;␊
`
Error 1/1
`␊
> 1 | const isNegativeZero = value => value === 0 && 1 / value === -Infinity;␊
| ^^^^^^^^^ Prefer \`Number.NEGATIVE_INFINITY\` over \`-Infinity\`.␊
`
1 | const {a = NaN} = {};
Output
`␊
1 | const {a = Number.NaN} = {};␊
`
Error 1/1
`␊
> 1 | const {a = NaN} = {};␊
| ^^^ Prefer \`Number.NaN\` over \`NaN\`.␊
`
1 | const {[NaN]: a = NaN} = {};
Output
`␊
1 | const {[Number.NaN]: a = Number.NaN} = {};␊
`
Error 1/2
`␊
> 1 | const {[NaN]: a = NaN} = {};␊
| ^^^ Prefer \`Number.NaN\` over \`NaN\`.␊
`
Error 2/2
`␊
> 1 | const {[NaN]: a = NaN} = {};␊
| ^^^ Prefer \`Number.NaN\` over \`NaN\`.␊
`
1 | const [a = NaN] = [];
Output
`␊
1 | const [a = Number.NaN] = [];␊
`
Error 1/1
`␊
> 1 | const [a = NaN] = [];␊
| ^^^ Prefer \`Number.NaN\` over \`NaN\`.␊
`
1 | function foo({a = NaN}) {}
Output
`␊
1 | function foo({a = Number.NaN}) {}␊
`
Error 1/1
`␊
> 1 | function foo({a = NaN}) {}␊
| ^^^ Prefer \`Number.NaN\` over \`NaN\`.␊
`
1 | function foo({[NaN]: a = NaN}) {}
Output
`␊
1 | function foo({[Number.NaN]: a = Number.NaN}) {}␊
`
Error 1/2
`␊
> 1 | function foo({[NaN]: a = NaN}) {}␊
| ^^^ Prefer \`Number.NaN\` over \`NaN\`.␊
`
Error 2/2
`␊
> 1 | function foo({[NaN]: a = NaN}) {}␊
| ^^^ Prefer \`Number.NaN\` over \`NaN\`.␊
`
1 | function foo([a = NaN]) {}
Output
`␊
1 | function foo([a = Number.NaN]) {}␊
`
Error 1/1
`␊
> 1 | function foo([a = NaN]) {}␊
| ^^^ Prefer \`Number.NaN\` over \`NaN\`.␊
`
1 | function foo() {return-Infinity}
Output
`␊
1 | function foo() {return Number.NEGATIVE_INFINITY}␊
`
Error 1/1
`␊
> 1 | function foo() {return-Infinity}␊
| ^^^^^^^^^ Prefer \`Number.NEGATIVE_INFINITY\` over \`-Infinity\`.␊
`
1 | globalThis.isNaN(foo);
Error 1/1
`␊
> 1 | globalThis.isNaN(foo);␊
| ^^^^^^^^^^^^^^^^ Prefer \`Number.isNaN\` over \`isNaN\`.␊
␊
--------------------------------------------------------------------------------␊
Suggestion 1/1: Replace \`isNaN\` with \`Number.isNaN\`.␊
1 | Number.isNaN(foo);␊
`
1 | global.isNaN(foo);
Error 1/1
`␊
> 1 | global.isNaN(foo);␊
| ^^^^^^^^^^^^ Prefer \`Number.isNaN\` over \`isNaN\`.␊
␊
--------------------------------------------------------------------------------␊
Suggestion 1/1: Replace \`isNaN\` with \`Number.isNaN\`.␊
1 | Number.isNaN(foo);␊
`
1 | window.isNaN(foo);
Error 1/1
`␊
> 1 | window.isNaN(foo);␊
| ^^^^^^^^^^^^ Prefer \`Number.isNaN\` over \`isNaN\`.␊
␊
--------------------------------------------------------------------------------␊
Suggestion 1/1: Replace \`isNaN\` with \`Number.isNaN\`.␊
1 | Number.isNaN(foo);␊
`
1 | self.isNaN(foo);
Error 1/1
`␊
> 1 | self.isNaN(foo);␊
| ^^^^^^^^^^ Prefer \`Number.isNaN\` over \`isNaN\`.␊
␊
--------------------------------------------------------------------------------␊
Suggestion 1/1: Replace \`isNaN\` with \`Number.isNaN\`.␊
1 | Number.isNaN(foo);␊
`
1 | globalThis.parseFloat(foo);
Output
`␊
1 | Number.parseFloat(foo);␊
`
Error 1/1
`␊
> 1 | globalThis.parseFloat(foo);␊
| ^^^^^^^^^^^^^^^^^^^^^ Prefer \`Number.parseFloat\` over \`parseFloat\`.␊
`
1 | global.parseFloat(foo);
Output
`␊
1 | Number.parseFloat(foo);␊
`
Error 1/1
`␊
> 1 | global.parseFloat(foo);␊
| ^^^^^^^^^^^^^^^^^ Prefer \`Number.parseFloat\` over \`parseFloat\`.␊
`
1 | window.parseFloat(foo);
Output
`␊
1 | Number.parseFloat(foo);␊
`
Error 1/1
`␊
> 1 | window.parseFloat(foo);␊
| ^^^^^^^^^^^^^^^^^ Prefer \`Number.parseFloat\` over \`parseFloat\`.␊
`
1 | self.parseFloat(foo);
Output
`␊
1 | Number.parseFloat(foo);␊
`
Error 1/1
`␊
> 1 | self.parseFloat(foo);␊
| ^^^^^^^^^^^^^^^ Prefer \`Number.parseFloat\` over \`parseFloat\`.␊
`
1 | globalThis.NaN
Output
`␊
1 | Number.NaN␊
`
Error 1/1
`␊
> 1 | globalThis.NaN␊
| ^^^^^^^^^^^^^^ Prefer \`Number.NaN\` over \`NaN\`.␊
`
1 | -globalThis.Infinity
Output
`␊
1 | Number.NEGATIVE_INFINITY␊
`
Error 1/1
`␊
> 1 | -globalThis.Infinity␊
| ^^^^^^^^^^^^^^^^^^^^ Prefer \`Number.NEGATIVE_INFINITY\` over \`-Infinity\`.␊
`
1 | const options = {
2 | normalize: parseFloat,
3 | parseInt,
4 | };
5 |
6 | run(foo, options);
Output
`␊
1 | const options = {␊
2 | normalize: Number.parseFloat,␊
3 | parseInt: Number.parseInt,␊
4 | };␊
5 |␊
6 | run(foo, options);␊
`
Error 1/2
`␊
1 | const options = {␊
> 2 | normalize: parseFloat,␊
| ^^^^^^^^^^ Prefer \`Number.parseFloat\` over \`parseFloat\`.␊
3 | parseInt,␊
4 | };␊
5 |␊
6 | run(foo, options);␊
`
Error 2/2
`␊
1 | const options = {␊
2 | normalize: parseFloat,␊
> 3 | parseInt,␊
| ^^^^^^^^ Prefer \`Number.parseInt\` over \`parseInt\`.␊
4 | };␊
5 |␊
6 | run(foo, options);␊
`