GitXplorerGitXplorer
z

vscode-fix-all-json

public
5 stars
3 forks
5 issues

Commits

List of commits on branch main.
Unverified
7568eea1d82d7fe6b0bccfe9075a4347c21edd41

prepare changes to next

zzardoy committed 2 years ago
Unverified
952e50176746307c9f48bf827c2026329761be1f

fix: always ignore last line (fixes final newline with array)

zzardoy committed 2 years ago
Unverified
f7f8c0ef8b967a3916d42777b2f3c269b15786c7

update typescript to fix tsc

zzardoy committed 2 years ago
Unverified
8d79a03be1ad15e64043035a2a3cbef17e952ddf

provide a way to disable fixAllJson via `editor.codeActionsOnSave`

zzardoy committed 2 years ago
Unverified
638000999f9b602652086afb4b7bd0a050000ff3

refactor: reuse builtin function

zzardoy committed 2 years ago
Verified
4ed6bf99b0c69048353535dc595a2ec0716078aa

Merge pull request #15 from zardoy/refactor-test

zzardoy committed 2 years ago

README

The README file for this repository.

Fix All JSON

Simple & fast VSCode extension for fixing almost all annoying JSON (and even JSONC!) problems on typing / save.

  • supports virtual workspaces and web
  • simple and fast as it uses the errors you see
  • On-Type Fixes

Enabling Fixing on Save

To enable problems auto fixing on save (which is super useful), ensure you have the following in your settings.json (> Preferences: Open User Settings (JSON)):

"[json][jsonc]": {
  "editor.codeActionsOnSave": ["source.fixAll"]
}

What fixes

All these fixes are configurable and can be disabled in settings:

Error Message Action
Expected comma Insert missing comma
Colon expected Insert missing colon
Trailing comma Remove trailing comma
Comments are not permitted in JSON. (json only) Remove the whole comment (disabled by default)
Property keys must be doublequoted Remove quotes (if have ' or `) and doublequote

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

Note 2: this extension though doesn't do value autoquoting, there is vscode-fix-json for this.

Sometimes builtin JSON extension can be slow. In these cases you need to wait until errors are updated before fixing the file! We can do absolutely nothing about it.

Why not Prettier?

Prettier as formatter does great work on fixing trailing semicolons and quotes problems, however this extension is much faster and has more fixes.

Additional Features

On-Type Fixes

  • Insert missing comma on Enter (or Ctrl+Enter, enabled by default with fixAllJson.insertMissingCommaOnEnter)
  • Insert missing double quotes on : (enabled by default with fixAllJson.insertMissingDoubleQuotesOnColon)