I seem to have a problem with ESlint & Prettier in Vscode. As far as I can tell everything is configured correctly, where <;> will be added on save, but not <,> for objects.
Eslint Config has:
`
"comma-dangle": [
1,
{
"objects": "always",
"arrays": "ignore",
"imports": "ignore",
"exports": "ignore",
"functions": "ignore"
}
],`
prettier config has "trailingComma": "es5",
So I’m not sure why it isn’t working correctly, and can’t seem to figure it out. Any help would be appreciated.
the comma to be placed automatically when I save the document like semi colon.
2
Answers
While eslint & prettier can be setup to add
;
on save,,
can not. You would think for the sake of consistency you could. The extension auto insert comma will accomplish that though, if (for whatever reason) the punctuation discontinuity stands out to you.If that’s all you’re wondering about, the reason why it’s not working correctly is because that’s because
comma-dangle
is about the optional, trailing comma for the last property of an object definition. Also related is Prettier’strailing-commas
option. You’re wanting something different- fixing missing commas after any property of an object definition.TL;DR the thing you’re trying to use doesn’t do the thing you want because that’s the way it is.