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
Bug: max-lines-per-function changes in eslint 8.4.0 #15390
Comments
Hi @aarongoldenthal, thanks for the issue!
You can also add a const foo = () => {
const x = 1;
console.log(x);
console.log(x);
console.log(x);
console.log(x); // eslint-disable-line max-lines-per-function
console.log(x);
console.log(x);
console.log(x);
console.log(x);
}; Would that work for you? |
@mdjermanovic The place I really see it a lot is in tests, like the example below. I'd like to disable the rule for the describe('test something', () => {
it('should...', async () => {
...
});
it('should...', async () => {
...
});
it('should...', async () => {
...
});
it('should...', async () => {
expect.hasAssertions(); // eslint-disable-line max-lines-per-function
...
});
}); It is definitely somewhat of a fringe case, so maybe this is the best option, but in nested function cases like this it's not so intuitive. I do like that it now flags only the lines past the threshold, although it did surprise me when a minor release caused |
Indeed, it seems that in cases with inner function neither
This is also reported in #15098 (comment). @eslint/eslint-tsc thoughts about this? |
Indeed we are experiencing the same issue here. And I agree with @ljharb that this is a breaking change since it's a change in behaviour in a minor version. |
Given that there are so many edge cases we didn’t see during development, it seems best to roll this change back. |
Agreed. PR to revert the change: #15397 |
Environment
Node version: 16.13.1
npm version: 8.1.2
Local ESLint version: 8.4.0
Global ESLint version: none
Operating System: Windows 10 21H1, Alpine Linux 3.14
What parser are you using?
Default (Espree)
What did you do?
With the changes to
max-lines-per-function
in v8.4.0 per #15140, this rule cannot be disabled at the start of the function with// eslint-disable-next-line max-lines-per-function
, which did work in previous versions and has made this a breaking change. The rule now flags this disable as unused since no problems are reported formax-lines-per-function
on this line, and flags an error on the first line that exceeds the line length limit.Configuration
What did you expect to happen?
// eslint-disable-next-line max-lines-per-function
should disable the rule for a function exceeding the max lines, and should not be listed as unusedWhat actually happened?
// eslint-disable-next-line max-lines-per-function
before the function is listed as unused. The only way to disable for the function appears to be wrapping it withdisable
/enable
comments, as shown below. This limits the options to disable the rule, e.g. you might want to disable for a factory function, but enable the rule for any internally defined functions, which isn't an option with this disable.Participation
Additional comments
No response
The text was updated successfully, but these errors were encountered: