-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
function-call-argument-newline complains in some cases when it logically shouldn't. #12123
function-call-argument-newline complains in some cases when it logically shouldn't. #12123
Comments
It looks like the rule is expecting the following: document.body.addEventListener(
'scroll',
function() {
// do something
},
{
passive: true,
}
);
document.body.addEventListener(
'scroll',
function() {
// do something
},
{passive: true}
); That being said, I do think it's reasonable to configure it to account for multiline arguments in a way that allows for the expected behavior in the bug report. I wonder if that should be an option (something like |
I think an option would indeed be good. What's got me confused here is that if it's just two arguments, it doesn't seem to care for some reason (regardless of whether the first, the second, or both are multi-line arguments). |
Yeah, that does seem like a bug. Here's some more inconsistency in our demo. |
This isn't related directly to the /*eslint function-call-argument-newline:["error", "never"] */
foo({
}, bar); and is reporting a line break between The issue is with comparing first tokens instead of last vs first (there is also a similar but not same issue with multiline tokens because it compares start with start). I believe this could be seen as a bug, because:
If fixed to compare last to first (and end to start) all examples from this issue should be solved, but the following would be a new error: /*eslint function-call-argument-newline:["error", "always"] */
foo({
}, bar); |
Need to wait until eslint/eslint#12123 is resolved.
Unfortunately, it looks like there wasn't enough interest from the team Thanks for contributing to ESLint and we appreciate your understanding. |
Reopening because multiple team members think that this could be a bug. |
This seems like a bug in the implementation to me and I support the change @mdjermanovic suggests in this comment. I think it makes a lot of sense to instead check between the end of the previous argument and the start of the next argument. |
By #10323 it seems that These examples are equivalent to the two examples from the initial post, and there are no errors: /* eslint array-element-newline:["error", "consistent"] */
['scroll', function() {
// do something
}, {
passive: true,
}];
['scroll', function() {
// do something
}, {passive: true}]; Also, I strongly believe this is a bug that should be fixed, though it will generate some new warnings, like in these cases: /*eslint function-call-argument-newline:["error", "always"] */
foo({
bar: 1
}, baz);
/*eslint function-call-argument-newline:["error", "consistent"] */
foo(bar,
function (){
// do something
}, {
a: 1
}
);
@kaicataldo can we already accept this as a bug fix that will generate more warnings by default, or maybe wait for one more vote ? |
I’m in favor of this being a semver-minor bug fix but it would be great if we could get some eyes from the TSC before we accept this. |
@eslint/eslint-team this is probably a bug, but the fix can generate more warnings by default, so it's better to have an additional confirmation before accepting the issue and the related PR. |
Another scenario where this fails is when passing a dependency array to a React hook: useMemo ( () => { // Fine
} );
useMemo ( () => { // No longer fine
}, [foo] ); |
Agree. This seems like a bug. |
Marking related PR #12280 as accepted. |
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
default
Please show your full configuration:
This config is the minimum together with the example code below to reproduce the issue.
Configuration
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
This is a minimal reproducer that I've created based on my own experimentation, not the original code that caused the issue:
What did you expect to happen?
In consistent mode, none of the three calls to
document.body.addEventListener()
above should trigger an error (the use of newlines between arguments is consistent in all three cases).What actually happened? Please include the actual, raw output from ESLint.
Are you willing to submit a pull request to fix this bug?
I don't have enough background with Node.js to be comfortable submitting a PR, but I will be more than happy to help test any that does get submitted.
The text was updated successfully, but these errors were encountered: