Skip to content

Commit

Permalink
Check type directly
Browse files Browse the repository at this point in the history
Co-authored-by: Francesco Trotta <github@fasttime.org>
  • Loading branch information
gurgunday and fasttime committed Dec 16, 2023
1 parent 9c74329 commit 7476cd9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/no-implicit-coercion.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ module.exports = {

// foo - 0
operatorAllowed = options.allow.includes("-");
if (!operatorAllowed && options.number && node.operator === "-" && isNumeric(node.right) && node.right.value === 0 && !isNumeric(node.left)) {
if (!operatorAllowed && options.number && node.operator === "-" && node.right.type === "Literal" && node.right.value === 0 && !isNumeric(node.left)) {
const recommendation = `Number(${sourceCode.getText(node.left)})`;

report(node, recommendation, true);
Expand Down

0 comments on commit 7476cd9

Please sign in to comment.