[json] option to format code with leading commas
#24.869 geöffnet am 16. Apr. 2017
Repository-Metriken
- Stars
- (74.848 Stars)
- PR-Merge-Metriken
- (Durchschn. Merge 11h 43m) (1.000 gemergte PRs in 30 T)
Beschreibung
Can we get an option in VS Code to have it format all lists by using leading commas instead of trailing commas?
This would so much simplify editing code and it would also greatly simplify the IDE's automatic code completion (e.g. the VS Code Settings editor).
With the suggested option set to true, comma separated lists would proposedly be formatted like this:
{ "workbench.iconTheme": "vs-seti"
, "editor.lineNumbers": "off"
, "editor.tabSize": 2
, "editor.insertSpaces": false
, "editor.autoClosingBrackets": false
}
Function calls using line wrapping for their arguments would look like this:
call( 1
, "test"
, new Console()
);
a nested sample would look like this:
{ "version": "0.2.0"
, "configurations":
[ { "type": "node"
, "request": "launch"
, "name": "Programm starten"
, "program": "${file}"
}
, { "type": "node"
, "request": "attach"
, "name": "An den Port anfügen"
, "address": "localhost"
, "port": 5858
}
]
}
Moreover, adding a new property to an object would be a snap:
Either copy/paste from an existing property (=> no more syntax errors due to redundant trailing commas, see screenshot below):

... or create a new property and you might immediately get IntelliSense right after typing the leading comma of the property to create.
The suggested formatting style is applicable to all languages
E.g. T-SQL:
CREATE TABLE
( id INT PRIMARY KEY IDENTITY
, name NVARCHAR(100) NOT NULL UNIQUE CHECK(LEN(name) > 0)
, created DATETIME NOT NULL DEFAULT(GETDATE())
, updated DATETIME NOT NULL DEFAULT(GETDATE())
)