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

padding-line-between-statements doesn't treat IIFEs as functions #10843

Closed
LJNeon opened this issue Sep 8, 2018 · 4 comments
Closed

padding-line-between-statements doesn't treat IIFEs as functions #10843

LJNeon opened this issue Sep 8, 2018 · 4 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion question This issue asks a question about ESLint

Comments

@LJNeon
Copy link

LJNeon commented Sep 8, 2018

Tell us about your environment

  • ESLint Version: 5.5.0
  • Node Version: 10.9.0
  • npm Version: 6.2.0

What parser (default, Babel-ESLint, etc.) are you using?
default
Please show your full configuration:

Configuration
env: {
  es6: true,
  node: true
}

extends: "eslint:recommended"

rules: {
  padding-line-between-statements: [2, {
    blankLine: "never",
    next: "*",
    prev: "*"
  },
  {
    blankLine: "always",
    next: "function",
    prev: "*"
  },
  {
    blankLine: "always",
    next: "*",
    prev: "function"
  }]
}

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

process.on("unhandledRejection", (r, p) => {
  // ...
});
// <---- eslint wants me to remove this blank line
(async () => {
  // ...
})();
eslint . --ext .js

What did you expect to happen?
It would consider the code valid as I've stated that function should have blank lines both before and after.
What actually happened? Please include the actual, raw output from ESLint.

/../src/index.js
  34:1  error  Unexpected blank line before this statement  padding-line-between-statements
@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Sep 8, 2018
@platinumazure
Copy link
Member

Hi @LJNeon, thanks for the issue.

It looks like IIFEs are covered under the "block-like" or "multiline-block-like" statement types of this rule. Those statement types also cover standalone blocks, function declarations/expressions, and if/while/do-while/switch/for statements that have blocks, so they may be too broad for your use case.

I could see a case for enhancing the rule with a new "iife" statement type, which would only cover IIFEs. Then you could use ["function", "iife"] as the statement type in your rule config.

What do you think?

@platinumazure platinumazure added question This issue asks a question about ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Sep 8, 2018
@LJNeon
Copy link
Author

LJNeon commented Sep 9, 2018

That sounds good to me, I just need a way to treat iifes as functions.

@platinumazure
Copy link
Member

@LJNeon I've created #10853 to track the enhancement request. Please review and let me know if you think it needs any changes.

If all looks well and you're okay with tracking that issue, please feel free to close this. Thanks!

@LJNeon
Copy link
Author

LJNeon commented Sep 12, 2018

Looks good to me

@LJNeon LJNeon closed this as completed Sep 12, 2018
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Mar 12, 2019
@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 Mar 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion question This issue asks a question about ESLint
Projects
None yet
Development

No branches or pull requests

2 participants