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

proposal:add new option to rule array-callback-return and getter-return #8539

Closed
aladdin-add opened this issue May 3, 2017 · 11 comments · Fixed by mono-js/mono-notifications#5, mono-js/mono-push#5 or terrajs/lib-starter#5 · May be fixed by ali8889/emerald-wallet#4 or DmytroSkrypnyk/test_bootstrap#6
Assignees
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 enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules

Comments

@aladdin-add
Copy link
Member

aladdin-add commented May 3, 2017

What rule do you want to change?
array-callback-return

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

How will the change be implemented? (New option, new default behavior, etc.)?
new option:
"allowImplicit": true -- allows implicitly returning undefined with a return; statement.

Please provide some example code that this change will affect:

/* eslint array-callback-return: [2, {allowImplicit: true} */
[1, 2, 3].map(function (item) {
  return; // return undefined implicitly.
});

What does the rule currently do for this code?
Function expected a return value.(array-callback-return)

What will the rule do after it's changed?
no error.

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label May 3, 2017
@ljharb
Copy link
Sponsor Contributor

ljharb commented May 3, 2017

Yes please - I never write return undefined; because undefined is not a keyword, and is not a safe token to rely on in non-app code.

I would love this option (and would enable it in the airbnb config).

@platinumazure platinumazure added the needs info Not enough information has been provided to triage this issue label Jun 26, 2017
@eslintbot
Copy link

eslintbot commented Jun 26, 2017

Hi @aladdin-add, thanks for the issue. It looks like there's not enough information for us to know how to help you.

Requesting a rule change? Please see Proposing a Rule Change for instructions.

If it's something else, please just provide as much additional information as possible. Thanks!

(edited by @platinumazure)

@platinumazure
Copy link
Member

Hi @aladdin-add, are you thinking we should enhance the rule with an option like for getter-return? Or should we just focus on cleaning up the documentation?

@ljharb
Copy link
Sponsor Contributor

ljharb commented Jun 26, 2017

I would like an option.

@aladdin-add
Copy link
Member Author

aladdin-add commented Jun 26, 2017

the rule getter-return's option allowImplicit has been accepted. so better to be consistent.
updated the OP.

@platinumazure platinumazure added enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules and removed needs info Not enough information has been provided to triage this issue triage An ESLint team member will look at this issue soon labels Jun 27, 2017
@platinumazure
Copy link
Member

@ljharb You could use return void 0;, that's perfectly safe.

That said, I'm 👍 to there being an option.

@platinumazure
Copy link
Member

@eslint/eslint-team A PR just came for this, we should probably evaluate quickly or else close.

@ilyavolodin
Copy link
Member

@eslint/eslint-team Does anyone else want's to support this change?

@kaicataldo
Copy link
Member

kaicataldo commented Oct 16, 2017

From the original post by @aladdin-add:

"allowImplicit": true -- disallows implicitly returning undefined with a return; statement.

Just to clarify, should this actually read like this?

"allowImplicit": true -- disallows allows implicitly returning undefined with a return; statement."`

@aladdin-add
Copy link
Member Author

eh.yes! corrected @kaicataldo

@ilyavolodin ilyavolodin 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 Nov 2, 2017
@ilyavolodin
Copy link
Member

Marking as accepted since @aladdin-add is part of the team and will be the champion.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.