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: max-params to only highlight function header #10815

Merged
merged 1 commit into from Aug 31, 2018

Conversation

ianobermiller
Copy link
Contributor

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

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[X] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)

Update the max-params rule to only report the location of the method header. Some tools, like Nuclide, will otherwise highlight the entire body of the method, which makes the rule visually noisy in practice.

What rule do you want to change?

max-params

Does this change cause the rule to produce more or fewer warnings?

No.

How will the change be implemented? (New option, new default behavior, etc.)?

New location reporting.

Please provide some example code that this change will affect:

function foo(a, b, c, d, e, f, g) {
  // long body
  // on multiple
  // lines
}

What does the rule currently do for this code?

Highlights the entire function:

function foo(a, b, c, d, e, f, g) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  // long body
^^^^^^^^^^^^^^
  // on multiple
^^^^^^^^^^^^^^^^
  // lines
^^^^^^^^^^
}
^

What will the rule do after it's changed?

Highlights only the function header:

function foo(a, b, c, d, e, f, g) {
^^^^^^^^^^^^
  // long body
  // on multiple
  // lines
}

I also considered highlighting the entire params list, but it is not really
necessary, and has more noise when the function has a multi-line param list.

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

It is fairly simple, just look at the test.

Update the max-params rule to only report the location of the method header. Some tools, like Nuclide, will otherwise highlight the entire body of the method, which makes the rule visually noisy in practice.

Test plan:

npm test
@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Aug 29, 2018
@ianobermiller
Copy link
Contributor Author

Travis failure appears to be random and unrelated.

@matanwerbner
Copy link

This totally makes sense. working with this rule in the past, it was always strange to me that the whole function was highlighted, many times conflicting with other highlights, when the rule applies to the arguments list only.

I do feel like highlighting the whole params list could be better, since highlighting the first row alone might seem strange when many arguments are there.

@ilyavolodin
Copy link
Member

Restarted Travis build. Thanks for PR! LGTM

@ilyavolodin ilyavolodin added bug ESLint is working incorrectly rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Aug 29, 2018
Copy link
Member

@platinumazure platinumazure 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 for contributing!

I'm okay with this as is, but should we consider highlighting the parameters too?

@ianobermiller
Copy link
Contributor Author

ianobermiller commented Aug 30, 2018 via email

@ianobermiller
Copy link
Contributor Author

ianobermiller commented Aug 30, 2018 via email

@platinumazure
Copy link
Member

Works for me. Thanks for considering!

@ianobermiller
Copy link
Contributor Author

Thanks for the reviews and discussion! May someone with write access please merge this PR?

@ilyavolodin
Copy link
Member

@ianobermiller We will. We usually leave PRs open for 48 hours to give other members of the team a chance to look it over. Once we get closer to 48 hours, and no other comments, we will merge it in.

@ianobermiller
Copy link
Contributor Author

ianobermiller commented Aug 30, 2018 via email

@ilyavolodin ilyavolodin merged commit b61d2cd into eslint:master Aug 31, 2018
@kaicataldo
Copy link
Member

@ianobermiller Contributors don't have to request that PRs be merged - we'll take care of it!

For reference, the information @ilyavolodin referenced above is outlined here.

@ianobermiller
Copy link
Contributor Author

ianobermiller commented Sep 3, 2018 via email

@ianobermiller ianobermiller deleted the max-params-highlight branch September 4, 2018 17:46
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 28, 2019
@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 Feb 28, 2019
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

5 participants