You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Wrapping algorithm for callback arrow functions adds a comma to the arguments list #118
func('a very very very very long long long name that exceeds the width limit',()=>{returntrue;})// becomes func('a very very very very long long long name that exceeds the width limit',(,)=>{returntrue;});
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.
// inputfunc('a short name',()=>{returntrue;})// outputfunc('a short name',()=>{returntrue;});
// inputfunc('a very very very very long long long name that exceeds the width limit',function(){returntrue;})// outputfunc('a very very very very long long long name that exceeds the width limit',function(){returntrue;},);
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.
changed the title [-]Wrapping algorithm for callback arrow functions adds a comma[/-][+]Wrapping algorithm for callback arrow functions adds a comma to the arguments list[/+]on Jan 11, 2017
There is a babel extension to strip it out. Are you using babel already? If so you should enable that extension.
The point is that it's going to be legal soon, and if people want trailing commas they would like them there as well, and we assume your going to use the babel extension for now.
We should not output the comma though if there are no args. That is a bug.
Yeah, that's the bug I'm facing – it's adding the comma when an arrow callback function has no arguments. I'm eagerly awaiting the day that I can use trailing function commas! I hadn't realized it was that far along in the process yet. Thanks again!
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.
I think, until trailing function commas are supported natively, it's wrong to assume that people are running their code through babel. I would like trailing commas everywhere they are supported, but I don't run my node code through babel, so I have to turn the option off, which strips trailing commas from objects and arrays.
Activity
[-]Wrapping algorithm for callback arrow functions adds a comma[/-][+]Wrapping algorithm for callback arrow functions adds a comma to the arguments list[/+]jlongster commentedon Jan 11, 2017
Are you using the trailing comma option? It is still be outputting a comma even though there are no args. If you add parameters is looks better:
https://vjeux.github.io/prettier-browser/#%7B%22content%22%3A%22%5Cnfunc(%27a%20very%20very%20very%20very%20long%20long%20long%20name%20that%20exceeds%20the%20width%20limit%27%2C%20(a%2C%20b%5Cn%20%20%2C%5Cn)%20%3D%3E%20%5Cn%20%20%7B%5Cn%20%20%20%20return%20true%3B%5Cn%20%20%7D)%3B%22%2C%22options%22%3A%7B%22printWidth%22%3A80%2C%22tabWidth%22%3A2%2C%22useFlowParser%22%3Afalse%2C%22singleQuote%22%3Atrue%2C%22trailingComma%22%3Atrue%2C%22bracketSpacing%22%3Atrue%7D%7D
If you enable the trailing commas option, we output commas for function arg lists too. It is not legal right now, but there is a stage 4 proposal for it, so it will be legal soon: https://github.com/tc39/proposal-trailing-function-commas
There is a babel extension to strip it out. Are you using babel already? If so you should enable that extension.
The point is that it's going to be legal soon, and if people want trailing commas they would like them there as well, and we assume your going to use the babel extension for now.
We should not output the comma though if there are no args. That is a bug.
hawkrives commentedon Jan 11, 2017
Yeah, that's the bug I'm facing – it's adding the comma when an arrow callback function has no arguments. I'm eagerly awaiting the day that I can use trailing function commas! I hadn't realized it was that far along in the process yet. Thanks again!
jlongster commentedon Jan 11, 2017
I think we might allow the
trailingCommaoption to have two types, one where it prints them everywhere and another that doesn't print them in function args.erbridge commentedon Jan 13, 2017
I think, until trailing function commas are supported natively, it's wrong to assume that people are running their code through babel. I would like trailing commas everywhere they are supported, but I don't run my node code through babel, so I have to turn the option off, which strips trailing commas from objects and arrays.
Fix comma when an arrow function with no arguments breaks
Fix comma when an arrow function with no arguments breaks
Fix comma when an arrow function with no arguments breaks
Fix comma when an arrow function with no arguments breaks (#210)
erbridge commentedon Jan 15, 2017
If I understand #210 correctly, it resolves the zero argument case, but what about the trailing comma on argument lists?