Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: no-implicit-coercion errors when multiplied by fractions with numerator of 1

See original GitHub issue


Node version: N/A npm version: N/A Local ESLint version: 8.24.0 Global ESLint version: N/A Operating System: N/A

What parser are you using?

Default (Espree)

What did you do?

ESLint Playground Demo

console.log(Math.PI * 1/4)

What did you expect to happen?

This would not be an error since the * 1 isn’t logically part of the previous token but part of the following division.

What actually happened?

This is marked as an implicit conversion error and suggested to be changed to the following which is clearly missing the intent:



  • I am willing to submit a pull request for this issue.

Additional comments

This is a special case that seems specific to the following pattern: <number> * 1 / <number>. While I do realize that the * 1 is unnecessary here, for readability of math expressions it is very valuable such as the example of working with PI but applies to any number multiplied by a fraction.

I’d like a special case/exception made to the rule’s checks that if the * 1 is immediately followed by a / then it is not an error.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

mdjermanoviccommented, Nov 7, 2022

I can work on this.

mdjermanoviccommented, Oct 3, 2022

It seems like always a false positive since I cannot think of a case where the * 1 / pattern is used and the intent is to coerce the number rather than multiply by a fraction

That’s a good point, as / coerces its operands to numbers anyway. I’m not opposed to adding this exception (by default, no option) and treating this as a bug fix, but let’s hear from the rest of the team first.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Student Errors in Fractions and Possible Causes of These Errors
The most common student error, with 67% because of not knowing the part-whole relationship, is considering the fraction with large numerator and ...
Read more >
Uncertainties and Error Propagation
Propagation of errors (a) add/subtract (b) multiply/divide (c) powers (d) mixtures of ... We round the uncertainty to two figures since it starts...
Read more >
Multiplying Whole Numbers and Fractions | Math with Mr. J
Welcome to Multiplying Whole Numbers and Fractions with Mr. J! Need help with how to multiply a whole number and a fraction ?...
Read more >
Multiplying Fractions by Fractions, Whole Numbers, and Mixed ...
Welcome to Multiplying Fractions by Fractions, Whole Numbers, and Mixed Numbers with Mr. J! Need help with how to multiply a fraction by...
Read more >
Simplifying Complex Fractions - ChiliMath
Method 1. Key steps: Create a single fraction in the numerator and denominator. Apply the division rule of fractions by multiplying the numerator...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found