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

[function-paren-newline] Missing support for async arrow functions #13728

Closed
mdziekon opened this issue Oct 1, 2020 · 1 comment · Fixed by #13729
Closed

[function-paren-newline] Missing support for async arrow functions #13728

mdziekon opened this issue Oct 1, 2020 · 1 comment · Fixed by #13729
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 bug ESLint is working incorrectly rule Relates to ESLint's core rules

Comments

@mdziekon
Copy link
Contributor

mdziekon commented Oct 1, 2020

Tell us about your environment

  • ESLint Version: 7.10.0
  • Node Version: 14.7.0
  • npm Version: 6.14.7

What parser (default, @babel/eslint-parser, @typescript-eslint/parser, etc.) are you using?

default

Please show your full configuration:

Configuration
module.exports = {
    rules: {
        'function-paren-newline': [
            'error',
            'multiline',
        ],
    },
};

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

const test = async (foo,
    bar) => {};
./node_modules/.bin/eslint src/test.js

What did you expect to happen?

ESLint should report the following problems:

  1:20  error  Expected newline after '('                             function-paren-newline
  2:8   error  Expected newline before ')'                            function-paren-newline

ESLint should be able to autofix this issue by inserting missing newlines.

What actually happened? Please include the actual, raw output from ESLint.

No errors were reported.

Are you willing to submit a pull request to fix this bug?

Yes

Cause of the problem

In this rule's getParenTokens function, when analysing ArrowFunctionExpression, the code wrongly assumes that any arrow function always starts with a parenthesis opening. Since the introduction of async / await syntax, this is no longer the case.

Scope of the problem

This issue affects all possible options, not only the multiline one as shown in my example.

@mdziekon mdziekon added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Oct 1, 2020
mdziekon added a commit to mdziekon/eslint that referenced this issue Oct 1, 2020
@yeonjuan
Copy link
Member

yeonjuan commented Oct 2, 2020

@mdziekon Hi :) Thanks for the report
It seems missing support for the async arrow function.

/* eslint function-paren-newline: ["error", "multiline"] */

function func(bar,	// error
               baz) {} // error

var arrow = (bar, // error
             baz) => {}  // error

var asyncArrow = async (bar, // no error
                  baz) => {} // no error

@yeonjuan yeonjuan added accepted There is consensus among the team that this change meets the criteria for inclusion rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Oct 2, 2020
mdziekon added a commit to mdziekon/eslint that referenced this issue Oct 2, 2020
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Apr 5, 2021
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Apr 5, 2021
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 bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants