Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(eslint-plugin): [explicit-function-return-type] allowHigherOrderFunctions (#193)#538

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
JamesHenry merged 17 commits intotypescript-eslint:masterfromSvish:feature/explicit-function-return-type-allow-currying
Jun 3, 2019
Merged

feat(eslint-plugin): [explicit-function-return-type] allowHigherOrderFunctions (#193)#538

JamesHenry merged 17 commits intotypescript-eslint:masterfromSvish:feature/explicit-function-return-type-allow-currying
Jun 3, 2019

Conversation

Svish
Copy link
Contributor

@SvishSvish commentedMay 16, 2019
edited
Loading

The last comment of#193 said that you wereAccepting PRs from the community (we love new contributors!!), and I really wanted#193 implemented, so... I gave it a shot, and... itseems to work? All the existing tests and the 3 new ones I wrote for this seems to run fine at least? 🤔 🎉

Fixes#193

denkristoffer reacted with thumbs up emojidenkristoffer reacted with heart emoji
@SvishSvish changed the titlefix(eslint-plugin): explicit-function-return-type allowCurry (#193)fix(eslint-plugin): [explicit-function-return-type] allowCurry (#193)May 16, 2019
@codecov
Copy link

codecovbot commentedMay 16, 2019
edited
Loading

Codecov Report

Merging#538 intomaster willincrease coverage by0.03%.
The diff coverage is100%.

@@            Coverage Diff             @@##           master     #538      +/-   ##==========================================+ Coverage   94.23%   94.27%   +0.03%==========================================  Files         104      104                Lines        4234     4246      +12       Branches     1152     1160       +8     ==========================================+ Hits         3990     4003      +13  Misses        142      142+ Partials      102      101       -1
Impacted FilesCoverage Δ
...-plugin/src/rules/explicit-function-return-type.ts100% <100%> (+2.7%)⬆️

@SvishSvish changed the titlefix(eslint-plugin): [explicit-function-return-type] allowCurry (#193)feat(eslint-plugin): [explicit-function-return-type] allowCurry (#193)May 16, 2019
@SvishSvish changed the titlefeat(eslint-plugin): [explicit-function-return-type] allowCurry (#193)feat(eslint-plugin): [explicit-function-return-type] allowCurrying (#193)May 16, 2019
JamesHenry
JamesHenry previously requested changesMay 17, 2019
Copy link
Member

@JamesHenryJamesHenry left a comment

Choose a reason for hiding this comment

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

On mobile, so can't write much detail write now, but I don't think this should go in as is.

Currying is not specific to arrow functions, so it is confusing to have this name/relationship IMO

Svish reacted with thumbs up emoji
@Svish
Copy link
ContributorAuthor

Svish commentedMay 17, 2019
edited
Loading

Good point. Do you have some examples of what else should pass/fail with this new option?

@bradzacher
Copy link
Member

bradzacher commentedMay 17, 2019
edited
Loading

The only case you've handled is an arrow function which returns an arrow function and has no body

constx=()=>()=>1

Should probably support all of these cases, as no doubt people will ask for them down the line.

functionFunctionDeclaration(){returnfunctionFunctionExpression_Within_FunctionDeclaration(){returnfunctionFunctionExpression_Within_FunctionExpression(){return()=>{// ArrowFunctionExpression_Within_FunctionExpressionreturn()=>// ArrowFunctionExpression_Within_ArrowFunctionExpression()=>1// ArrowFunctionExpression_Within_ArrowFunctionExpression_WithNoBody}}}}functionFunctionDeclaration(){return()=>{// ArrowFunctionExpression_Within_FunctionDeclaration// etc}}

I.e. every single combination ofFunctionExpression /FunctionDeclaration /ArrowFunctionExpression

Svish reacted with thumbs up emoji

@bradzacherbradzacher added the enhancement: plugin rule optionNew rule option for an existing eslint-plugin rule labelMay 17, 2019
@Svish
Copy link
ContributorAuthor

@JamesHenry Thanks to the examples provided by@bradzacher and some time looking at them throughhttps://astexplorer.net, I think I figured out how to implement it for all(?) cases now (i.e. not just forArrowFunctionExpression). The tests seem to run fine at least. Branch updated. 🙂👍

bradzacher reacted with thumbs up emoji

Copy link
Member

@bradzacherbradzacher left a comment

Choose a reason for hiding this comment

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

Code + Tests LGTM!

One last change I can see: Please document a few more cases in the rule rule doc just to clarify it works for non-arrow functions too.

Svish reacted with thumbs up emoji
bradzacher
bradzacher previously approved these changesMay 22, 2019
@bradzacherbradzacher added the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelMay 22, 2019
@Svish
Copy link
ContributorAuthor

@bradzacher I see you already added an approval, but just so it's said: Docs have been updated with function example, and I added two tests to cover a missing branch in my changes.

I also looked into adding a test to coverthe very last uncovered branch in the file, but I'm pretty sure it's actually impossible to hit that branch?

We only get to theif whennode is eitherFunctionExpression orArrowFunctionExpression, which seems to always have a parent ofExpressionStatement? And even if that were to not be the case, there should still be a parent ofProgram?

So, to get the coverage up to 100% (and for others not to waste time trying to cover that branch too) I added anistanbul ignore else there.

bradzacher reacted with thumbs up emoji

bradzacher
bradzacher previously approved these changesMay 22, 2019
Copy link
Member

@JamesHenryJamesHenry left a comment

Choose a reason for hiding this comment

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

I know I'm being the naming police on this, but this still isn't really currying thatallowCurrying is allowing.

The implementation is more broad than that, it is allowing any higher order function pattern.

I think that is probably what is most valuable anyway, so it's just the name that needs to change, so that users aren't confused and think it checks explicitly for currying patterns.

I'm not married to it, butallowHigherOrderFunctions ?

@Svish
Copy link
ContributorAuthor

Svish commentedMay 23, 2019
edited
Loading

@JamesHenry Could you explain what the difference is? From what I can see, currying looks like what this option allows. I'm reading about higher order functions, but they seem a lot more broader, like taking functions as arguments as well, which has nothing to do with this. There seems to be another concept called partial application, which to me looks like a slightly broader currying, but yeah... not really knowledgeable in this area...

I don't mind changing the name though. What do you think@bradzacher?

@bradzacher
Copy link
Member

IIRC technically currying is more the concept of functions which automatically return functions if you don't pass all of the required arguments, instead of explicitly defined functions returning functions.

In that regard, calling these higher order functions is technically more correct.

I think that either will work - people will probably understand either way.
But in case they don't, probs best to change it to something likeallowHigherOrderFunctions.

@Svish
Copy link
ContributorAuthor

@JamesHenry@bradzacher Alrighty, the option has now been renamed to technically more correctallowHigherOrderFunctions, and documentation and code adjusted accordingly. 🙂

bradzacher reacted with thumbs up emoji

@SvishSvish changed the titlefeat(eslint-plugin): [explicit-function-return-type] allowCurrying (#193)feat(eslint-plugin): [explicit-function-return-type] allowHigherOrderFunctions (#193)May 23, 2019
@Svish
Copy link
ContributorAuthor

@JamesHenry Is it good now? Anything else preventing a ✔ from you as well? Would really like to get this PR merged in, closed and released so I can make use of this new option in our project. 🙂

@Svish
Copy link
ContributorAuthor

I know I'm being the naming police on this, but this still isn't really currying thatallowCurrying is allowing.

The implementation is more broad than that, it is allowing any higher order function pattern.

I think that is probably what is most valuable anyway, so it's just the name that needs to change, so that users aren't confused and think it checks explicitly for currying patterns.

I'm not married to it, butallowHigherOrderFunctions ?

@JamesHenry Your requested change was fixed over a week ago now. Is there still more you'd like to be changed, or is it good now?

@JamesHenryJamesHenry merged commit50a493e intotypescript-eslint:masterJun 3, 2019
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsApr 21, 2020
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@JamesHenryJamesHenryJamesHenry approved these changes

@bradzacherbradzacherbradzacher approved these changes

Assignees
No one assigned
Labels
1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we mergeenhancement: plugin rule optionNew rule option for an existing eslint-plugin rule
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

[explicit-function-return-type] request option for curried arrow functions
3 participants
@Svish@bradzacher@JamesHenry

[8]ページ先頭

©2009-2025 Movatter.jp