Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-2427

The base should be provided to "parseInt"

    XMLWordPrintable

    Details

    • Type: Bug Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Add the base to this "parseInt" call.
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Covered Languages:
      JavaScript
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      2min
    • ESLint:
      radix

      Description

      The parseInt function has two versions, one that takes a base value as a second argument, and one that does not. Unfortunately using the single-arg version can result in unexpected results on older browsers.

      Noncompliant Code Example

      parseInt("010");  // Noncompliant; pre-2013 browsers may return 8 
      

      Compliant Solution

      parseInt("010", 10);
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              ann.campbell.2 Ann Campbell
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated: