Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update: fix no-magic-numbers false negative with ignoreArrayIndexes #12805

Merged
merged 1 commit into from Jan 28, 2020

Conversation

mdjermanovic
Copy link
Member

Prerequisites checklist

  • I have read the contributing guidelines.
  • The team has reached consensus on the changes proposed in this pull request. If not, I understand that the evaluation process will begin with this pull request and won't be merged until the team has reached consensus.

What is the purpose of this pull request? (put an "X" next to item)

[X] Bug fix

This bug fix produces more warnings by default.

Tell us about your environment

  • ESLint Version: v6.8.0
  • Node Version: v12.14.0
  • npm Version: v6.13.4

What parser (default, Babel-ESLint, etc.) are you using?

default

Please show your full configuration:

Configuration
module.exports = {
    parserOptions: {
        ecmaVersion: 2015,
    },
};

What did you do? Please include the actual source code causing the issue.

Online Demo Link

/*eslint no-magic-numbers: ["error", { "ignoreArrayIndexes": true }]*/

100 .toString();

What did you expect to happen?

1 error, since this isn't an array index.

What actually happened? Please include the actual, raw output from ESLint.

No errors.

What changes did you make? (Give an overview)

Added check that the number is property, not just any child of MemberExpression.

Is there anything you'd like reviewers to focus on?

Also added regression tests to make sure that this change doesn't affect behavior when the number is really the property, though some of these cases might be another bug. I'll open an issue for these.

@mdjermanovic mdjermanovic added bug ESLint is working incorrectly rule Relates to ESLint's core rules evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Jan 18, 2020
Copy link
Member

@kaicataldo kaicataldo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@kaicataldo kaicataldo added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Jan 27, 2020
Copy link
Member

@yeonjuan yeonjuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

@kaicataldo
Copy link
Member

Thanks for contributing!

@kaicataldo kaicataldo merged commit 562e784 into master Jan 28, 2020
@kaicataldo kaicataldo deleted the nomagicnumbers-arrayindexfalseneg branch January 28, 2020 19:10
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jul 28, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jul 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants