If I try to write a method inside an object initializer, for example by typing:
myFunction() {
then vscode adds a }
, leaving me to manually add the ,
.
Is there a way to get it to always add },
?
I should note that in my coding standards, all object properties should end with a comma (ie including the final one).
I'm running vscode 1.13.0 on Windows 10 (outside WSL).
You can use ESLint with the ESLint extension.
ESLint is able to "Fix" some of the rules automatically. For this one — comma-dangle.
.eslintrc
or .eslintrc.json
or some other eslint config file:
{
//...
"rules": {
"comma-dangle": [1, {
"objects": "always",
"arrays": "ignore",
"imports": "ignore",
"exports": "ignore",
"functions": "ignore"
}]
}
}
settings.json
:
"eslint.autoFixOnSave": true
P.S. ESLint can auto fix some other things like indentation, spacing, semicolons, parentheses, curly braces, ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With