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

`no-unexpected-multiline` flags opening parentheses sent as first argument to a function call #4658

Closed
dtinth opened this Issue Dec 10, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@dtinth
Copy link
Contributor

dtinth commented Dec 10, 2015

I am using eslint@1.10.3.

When sending a parenthesized expression on its own line to a function to a function call, no-unexpected-multiline rule flags that expression.

// example.js
module.exports = compose(
  (process.env.NODE_ENV === 'production'
    ? generateProductionConfig
    : generateDevelopmentConfig
  ),
  generateBaseConfig
)()

It is expected that the above code does not produce a warning, as it is clear that we are inside a call to function compose. There can be no ambiguity here.

However, the no-unexpected-multiline rule flags the newline between two (s as unexpected.

$ eslint example.js --rule 'no-unexpected-multiline: 2'

example.js
  3:3  error  Unexpected newline between function and ( of function call  no-unexpected-multiline

✖ 1 problem (1 error, 0 warnings)

When sending as a subsequent parameter, however, there is no warning (this is correct behavior).

// example.js
module.exports = pipe(
  generateBaseConfig,
  (process.env.NODE_ENV === 'production'
    ? generateProductionConfig
    : generateDevelopmentConfig
  )
)()
$ eslint example.js --rule 'no-unexpected-multiline: 2'
# no warnings generated

Inside an array there is also no warning (this is correct behavior).

// example.js
module.exports = compose([
  (process.env.NODE_ENV === 'production'
    ? generateProductionConfig
    : generateDevelopmentConfig
  ),
  generateBaseConfig,
])()
$ eslint example.js --rule 'no-unexpected-multiline: 2'
# no warnings generated

Minimal Test Case

Should not produce a warning:

f(
  (x)
)
@nzakas

This comment has been minimized.

Copy link
Member

nzakas commented Dec 10, 2015

Looks like we are confusing the open paren as part of the function call.

@alberto alberto closed this in acdda24 Dec 23, 2015

gyandeeps added a commit that referenced this issue Dec 23, 2015

Merge pull request #4794 from eslint/issue4658
Fix: ignore argument parens in no-unexpected-multiline (fixes #4658)

@eslint eslint bot locked and limited conversation to collaborators Feb 6, 2018

@eslint eslint bot added the archived due to age label Feb 6, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.