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

max-lines-per-function ignores arrow IIFEs #13332

Closed
cherryblossom000 opened this issue May 20, 2020 · 1 comment · Fixed by #13336
Closed

max-lines-per-function ignores arrow IIFEs #13332

cherryblossom000 opened this issue May 20, 2020 · 1 comment · Fixed by #13336
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

@cherryblossom000
Copy link
Contributor

Tell us about your environment

  • ESLint Version: 7.0.0
  • Node Version: 12.16.2
  • npm Version: 6.14.4

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

Please show your full configuration:

Configuration
{
  "env": {
    "es6": true
  },
  "rules": {
    "max-lines-per-function": [2, 1]
  }
}

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

(() => {
})()
eslint test.js

Demo

What did you expect to happen?
No errors because max-lines-per-function does not include any code in IIFEs by default.

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

/path/to/test.js
  1:2  error  Arrow function has too many lines (2). Maximum allowed is 1  max-lines-per-function

✖ 1 problem (1 error, 0 warnings)

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

lib/rules/max-lines-per-function.js:137

-            return node.type === "FunctionExpression" && node.parent && node.parent.type === "CallExpression" && node.parent.callee === node;
+            return (node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression") && node.parent && node.parent.type === "CallExpression" && node.parent.callee === node;
@cherryblossom000 cherryblossom000 added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels May 20, 2020
@yeonjuan yeonjuan added evaluating The team will evaluate this issue to decide whether it 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 May 20, 2020
@yeonjuan
Copy link
Member

@cherryblossom000
Thanks for the reporting! It seems a bug to me.

@yeonjuan yeonjuan added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels May 20, 2020
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Nov 20, 2020
@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 Nov 20, 2020
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