skip to Main Content

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.

enter image description here

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


  1. Chosen as BEST ANSWER

    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.


  2. So I’m not sure why it isn’t working correctly, and can’t seem to figure it out. Any help would be appreciated.

    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’s trailing-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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search