zardoy / vscode-fix-all-json

Utils & commands for fixing problems in JSON
https://marketplace.visualstudio.com/items?itemName=zardoy.fix-all-json
MIT License
5 stars 2 forks source link

add comma position not right #18

Open tjx666 opened 1 year ago

tjx666 commented 1 year ago

before:

{
    "name": "123",
    "age": 18,
    "scripts": {
        "test": ""
        "build": ""
    }
}

after:

{
    "name": "123",
    "age": 18,
    "scripts": {
        "test": ""
        ,"build": ""
    }
}

settings:

{
    "editor.codeActionsOnSave": {
        "source.fixAll": true
    }
}

versions:

Version: 1.79.2
Commit: 695af097c7bd098fbf017ce3ac85e09bbc5dda06
Date: 2023-06-14T08:58:33.551Z
Electron: 22.5.7
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Darwin arm64 22.5.0
zardoy.fix-all-json v0.1.5
zardoy commented 1 year ago

As I mentioned in readme

Note: missing commas just placed before the error range. Its assumed you have autoformatter enabled to handle the "right positioning"

For example I'm using builtin json formatter (actually default setting, but note that it wont work with "json.format.keepLines": true), I think prettier can also be an option. On the other hand I also want it to be fixed, because I have greatly optimized logic in comma on enter for comma positioning, so it should be easy to fix.