Wrapping algorithm for callback arrow functions adds a comma to the arguments list
See original GitHub issueVersion: 0.0.5 (npm@latest); also 0.0.4, and prettier-browser.
Example: (prettier-browser)
func('a very very very very long long long name that exceeds the width limit', () => {
return true;
})
// becomes
func('a very very very very long long long name that exceeds the width limit', (
,
) =>
{
return true;
});
Where did the comma in the arguments list come from?
It doesn’t happen with shorter functions that don’t exceed the line length limit, nor with a function
callback.
// input
func('a short name', () => {
return true;
})
// output
func('a short name', () => {
return true;
});
// input
func('a very very very very long long long name that exceeds the width limit', function() {
return true;
})
// output
func(
'a very very very very long long long name that exceeds the width limit',
function() {
return true;
},
);
Side-note: The output for the incorrect function causes
prettier
to throw an error: prettier-browser. Is the comma actually illegal there, or should I file that as a separate bug?
This looks like a wonderful tool. I’m really excited to see where it leads.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Arrow function expressions - JavaScript - MDN Web Docs
Arrow functions don't have their own bindings to this , arguments , or super , and should not be used as methods. ·...
Read more >Arrow functions in JavaScript - GeeksforGeeks
The reason that we get undefined outputs instead of the proper info as output happens because the function() defined as the callback for ......
Read more >Arrow functions, the basics - The Modern JavaScript Tutorial
If we have only one argument, then parentheses around parameters can be omitted, making that even shorter. For example: · If there are...
Read more >Google JavaScript Style Guide
Import statements must not be line wrapped and are therefore an exception to the ... When declaring an anonymous function in the list...
Read more >A Practical Guide to ES6 Arrow Functions - Bits and Pieces
In Arrow functions, the parameter list and the function body is separated by a => symbol. That is, the function keyword is effectively ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think we might allow the
trailingComma
option to have two types, one where it prints them everywhere and another that doesn’t print them in function args.If I understand #210 correctly, it resolves the zero argument case, but what about the trailing comma on argument lists?