Skip to content

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

Merged
platinumazure merged 7 commits intoeslint:masterfrom
chiawendt:default-param-last
Sep 7, 2019
Merged

New: add rule default-param-last (fixes #11361)#12188
platinumazure merged 7 commits intoeslint:masterfrom
chiawendt:default-param-last

Conversation

@chiawendt
Copy link
Copy Markdown
Contributor

@chiawendt chiawendt 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
Copy Markdown
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.

Comment thread docs/rules/default-param-last.md Outdated
Comment thread docs/rules/default-param-last.md Outdated
Comment thread tests/lib/rules/default-param-last.js
Comment thread tests/lib/rules/default-param-last.js Outdated
@chiawendt
Copy link
Copy Markdown
Contributor Author

Good catch!

Copy link
Copy Markdown
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!

Comment thread tests/lib/rules/default-param-last.js Outdated
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread docs/rules/default-param-last.md
Comment thread lib/rules/default-param-last.js Outdated
Copy link
Copy Markdown
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
Copy Markdown
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!

@chiawendt
Copy link
Copy Markdown
Contributor Author

Thanks for the suggestions!

Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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