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-extra-parens incorrectly reports returned IIFE #9140

Closed
smbape opened this issue Aug 22, 2017 · 2 comments
Closed

no-extra-parens incorrectly reports returned IIFE #9140

smbape opened this issue Aug 22, 2017 · 2 comments
Assignees
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

@smbape
Copy link

smbape commented Aug 22, 2017

Tell us about your environment

  • ESLint Version: 4.5.0
  • Node Version: 8.1.3
  • npm Version: 5.3.0

What parser (default, Babel-ESLint, etc.) are you using?
default

Please show your full configuration:

Configuration
node node_modules/eslint/bin/eslint.js --no-eslintrc --rule '{"wrap-iife": [2, "any"], "no-extra-parens": 2, "no-trailing-spaces": 2, "quotes":[2, "double"]}' --fix test/compiled.js

What did you do? Please include the actual source code causing the issue.

(function() {
    // trailing spaces    
    console.log('quotes');

    // extra parens
    return (function() {
        // trailing spaces    
        console.log('quotes');
    }());
})();

What did you expect to happen?
Fix option to be executed on nested iife

What actually happened? Please include the actual, raw output from ESLint.
When applying the command line above on the code above, quotes fix is applied on the top iife but not on the neted iife.

Without the wrap-iife everything is fine.

I haven't tested if the fix is not applied only for those specified rules.

On v4.5.0 here is the output

  6:12  error  Gratuitous parentheses around expression  no-extra-parens
  8:21  error  Strings must use doublequote              quotes

On v3.19.0 here is the output

  6:12  error  Gratuitous parentheses around expression  no-extra-parens
  7:30  error  Trailing spaces not allowed               no-trailing-spaces
  8:21  error  Strings must use doublequote              quotes
@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Aug 22, 2017
@not-an-aardvark not-an-aardvark added accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Aug 23, 2017
@not-an-aardvark
Copy link
Member

Thanks for the report. This is an issue with the no-extra-parens rule. It's designed to avoid reporting extra parens around IIFEs to avoid conflicting with the wrap-iife rule, but it seems to be incorrectly reporting this case:

/* eslint no-extra-parens: error */
function x() {
  return (function() {}())
}

@smbape
Copy link
Author

smbape commented Aug 24, 2017

Thanks for the comment.
I will remove no-extra-parens rule.

@not-an-aardvark not-an-aardvark changed the title wrap-iife rule causes fixes not being applied in nested iife no-extra-parens incorrectly reports returned IIFE Aug 25, 2017
@not-an-aardvark not-an-aardvark self-assigned this Aug 25, 2017
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 25, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 25, 2018
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

No branches or pull requests

3 participants