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

New: add rule default-param-last (fixes #11361) #12188

Merged
merged 7 commits into from Sep 7, 2019
Merged

New: add rule default-param-last (fixes #11361) #12188

merged 7 commits into from Sep 7, 2019

Conversation

golopot
Copy link
Contributor

@golopot golopot commented Aug 30, 2019

closes #11361.

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

X [ ] New rule (template)

Please describe what the rule should do:
Enforce default params to be last. Only es6 default params are dealt with.

What category of rule is this? (place an "X" next to just one item)

[ ] Enforces code style
[ ] Warns about a potential error
X [ ] Suggests an alternate way of doing something
[ ] Other (please specify:)

Provide 2-3 code examples that this rule will warn about:

function f(a = 5, b) {}
function f(a, b = 5, c) {}

Why should this rule be included in ESLint (instead of a plugin)?
See the accepted proposal #11361.

What changes did you make? (Give an overview)
Add a new rule.

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

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Aug 30, 2019
@g-plane g-plane added accepted There is consensus among the team that this change meets the criteria for inclusion feature This change adds a new feature to ESLint rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Aug 31, 2019
Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

The rule already LGTM! There are two small typos, and it would be good to have a few more tests.

docs/rules/default-param-last.md Outdated Show resolved Hide resolved
docs/rules/default-param-last.md Outdated Show resolved Hide resolved
tests/lib/rules/default-param-last.js Show resolved Hide resolved
tests/lib/rules/default-param-last.js Outdated Show resolved Hide resolved
@golopot
Copy link
Contributor Author

golopot commented Sep 1, 2019

Good catch!

Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

Thank you! An additional note for one test case, everything else LGTM!

tests/lib/rules/default-param-last.js Outdated Show resolved Hide resolved
Copy link
Member

@mdjermanovic mdjermanovic 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!

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 in general, just a couple of suggestions.

docs/rules/default-param-last.md Show resolved Hide resolved
lib/rules/default-param-last.js Outdated Show resolved Hide resolved
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.

One request: can we add some tests with default values and destructured parameters?

const f = ({ a } = {}, b) => {};

const f = ({ a, b } = { a: 1, b: 2 }, c) => {};

const f = ([a] = [], b) => {};

const f = ([a, b] = [1, 2], c) => {};

Otherwise, this LGTM!

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!

@golopot
Copy link
Contributor Author

golopot commented Sep 3, 2019

Thanks for the suggestions!

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!

@nitinsh99
Copy link

hey @golopot I am looking to use this rule.. can we merge this pls?

@platinumazure platinumazure merged commit 0313441 into eslint:master Sep 7, 2019
@platinumazure
Copy link
Member

Hi @nitinsh99, I've gone ahead and merged this since multiple team members have reviewed and all questions were addressed. That said, this will be available with our next release, currently scheduled for next weekend. Thanks for your patience!

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 feature This change adds a new feature to ESLint rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New: enforce default param be the last
6 participants