-
Notifications
You must be signed in to change notification settings - Fork 176
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
Add quick fix for S4623 for ('no-undefined-argument') #3040
Conversation
7382adb
to
94245f3
Compare
{ | ||
messageId: 'suggestRemoveUndefined', | ||
fix: fixer => { | ||
const singleArgument = call.arguments.length === 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would inline this
messages: { | ||
removeUndefined: 'Remove this redundant "undefined".', | ||
suggestRemoveUndefined: 'Remove "undefined"', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say Remove this redundant argument
errors: 2, | ||
errors: [ | ||
{ | ||
messageId: 'removeUndefined', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would drop this extra assertion of issue message
}, | ||
], | ||
}, | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have test with trailing comma?
desc: 'Remove this redundant argument', | ||
output: ` | ||
function fun(p = 42) {} | ||
fun(,); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is syntax error, we can't have such fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add test with trailing comma when there are several arguments
desc: 'Remove this redundant argument', | ||
output: ` | ||
function fun(p, q, r = 42) {} | ||
fun(1, 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO we should keep trailing comma here. That would be most probably used for multiline and then it's expected to have comma after each argument:
foo(
1,
2,
undefined,
);
// will become
foo(
1,
2
);
// and this will violate style... while it's probably pretty minor
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fine with the behaviour you are suggesting.
cde0e0e
to
7d47447
Compare
…e of optional parameters
7d47447
to
8600bba
Compare
8600bba
to
920ff1b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yassin-kammoun-sonarsource I think you misunderstood me. I wanted to keep the styling: so if trailing comma is there we should keep it, if there is no trailing comma, there should be none in the result as well.
SonarQube Quality Gate |
Fixes #3028