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

fix(eslint-plugin): [explicit-function-return-type] Fix allowExpressions ignoring default exports#831

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
bradzacher merged 4 commits intotypescript-eslint:masterfromSvish:master
Aug 10, 2019

Conversation

Svish
Copy link
Contributor

@SvishSvish commentedAug 9, 2019
edited
Loading

The current implementation ofallowExpressions below causes default exports to be allowed/ignored:

if(options.allowExpressions&&node.parent.type!==AST_NODE_TYPES.VariableDeclarator&&node.parent.type!==AST_NODE_TYPES.MethodDefinition){return;}

I really think a default export should be considered as much a declaration/definition as a variable declaration is. Maybe even more so, as it's the main export of a module.

Currently only the last one of these fail whenallowExpressions is set totrue:

exportdefault()=>{};// <-- Allowedexportconstfn=()=>{};// <-- Not allowed

So in this PR I've addedAST_NODE_TYPES.ExportDefaultDeclaration to the check (and tests for it), so that both those cases are correctly (in my opinion) rejected as lacking a return type.

exportdefault()=>{};// <-- No longer allowedexportconstfn=()=>{};// <-- Still not allowed

@typescript-eslint
Copy link
Contributor

Thanks for the PR,@Svish!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently onhttps://opencollective.com/typescript-eslint

@Svish
Copy link
ContributorAuthor

By the way, I don't know if I should also create an issue for this issue? That's what I considered to do to begin with, but since I realized it would be super easy to fix, I decided to just create a PR directly instead. But yeah... not sure what you want for project tracking purposes and such. 🤔

@bradzacherbradzacher added breaking changeThis change will require a new major version to be released enhancementNew feature or request labelsAug 9, 2019
@bradzacherbradzacher added this to the2.0.0 milestoneAug 9, 2019
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.

I agree with you, and I'm happy with this change.
It's breaking, but we're going to release 2.0 soon, so we can include this.

The code LGTM.

One change before this can be merged; could you please update the rule doc appropriately.

@bradzacherbradzacher added the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelAug 9, 2019
@Svish
Copy link
ContributorAuthor

@bradzacher Cool! About updating the rule doc, I definitely could, but looking at it now, I'm not sure exactly what I should update. What it says there now is already correct.

if true, only functions which are part of a declaration will be checked

The check I've added isExportDefaultDeclaration, so it's covered by "part of a declaration". I suppose I could add my 1 valid and 2 invalid tests to the rule doc examples... Want me to do that? And are there other adjustments you think should be made? 🤔

@Svish
Copy link
ContributorAuthor

I've added two examples of code that after this change will still be incorrect, even withallowExpressions set totrue. Not sure what else would make sense to add/change though...

As a minor cleanup of my own earlier PR, I also simplified the examples forallowHigherOrderFunctions by removing the function parameters. Looking at them again now, I realized they aren't actually relevant to the examples at all, so they are really just adding clutter.

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.

Yeah that's perfect. I just wanted to be sure that theexport default case was included in the readme.

LGTM - thanks for doing this.

Svish reacted with rocket emoji
@bradzacherbradzacher added bugSomething isn't working and removed 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge enhancementNew feature or request labelsAug 10, 2019
@bradzacherbradzacher merged commitebbcc01 intotypescript-eslint:masterAug 10, 2019
@bradzacherbradzacher mentioned this pull requestAug 10, 2019
14 tasks
@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

@bradzacherbradzacherbradzacher approved these changes

Assignees
No one assigned
Labels
breaking changeThis change will require a new major version to be releasedbugSomething isn't working
Projects
None yet
Milestone
2.0.0
Development

Successfully merging this pull request may close these issues.

2 participants
@Svish@bradzacher

[8]ページ先頭

©2009-2025 Movatter.jp