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

fix(eslint-plugin): [no-extra-parens] false positive with arrow generic #1689

Closed
wants to merge 7 commits into from
Closed

Conversation

yeonjuan
Copy link
Contributor

@yeonjuan yeonjuan commented Mar 6, 2020

Fixes #1587

It occurs because eslint core can't treat well about the checking parens when there is a token(() in type parameter position.

in eslint-utils

        case "CallExpression":
        case "NewExpression":
            if (parent.arguments.length === 1 && parent.arguments[0] === node) {
                return sourceCode.getTokenAfter(
                    parent.callee,
                    isOpeningParenToken
                )
            }
            return null

It seems the eslint-utils treats paren after the callee node as a stop condition for ensuring the paren is not excess paren.
So, #1287 occurs when there is ( in generic and(&&) call expression with one argument.

but it does not make sense because typescript can include ( token in type parameter position.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @yeonjuan!

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 on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

@bradzacher bradzacher added the bug Something isn't working label Mar 6, 2020
@bradzacher
Copy link
Member

This would probably be better as an upstream fix.
The current rule is hacky enough as is, so I'd rather not add too much in the way of extra hacks, when the logic should be able to be fixed at the source.

Example of different rules that I fixed at the source: eslint/eslint#12260
eslint/eslint#11698

@bradzacher bradzacher added the awaiting response Issues waiting for a reply from the OP or another party label Apr 3, 2020
@yeonjuan
Copy link
Contributor Author

yeonjuan commented May 6, 2020

@bradzacher Yes :) I agree. I close this PR

@yeonjuan yeonjuan closed this May 6, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
awaiting response Issues waiting for a reply from the OP or another party bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[no-extra-parens] Incorrect rule when used with arrow generic
2 participants