Opened 4 years ago
Last modified 3 months ago
#55429 new feature request
Coding Standard: Use spaces for JSON instead of tabs
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Build/Test Tools | Keywords: | needs-refresh |
| Focuses: | Cc: |
Description
When PHP outputs JSON using json_encode, there's no option to output it with tabs instead of spaces. This is particularly relevant in since https://github.com/WordPress/gutenberg/pull/39048 merged - we now convert theme.json files that were using tabs to spaces.
We could use a regex to convert these spaces back to tabs, but maybe its simpler to default to spaces for JSON files since that is the format that PHP uses.
Opening this ticket to start the discussion...
Attachments (1)
Change History (5)
This ticket was mentioned in Slack in #core-editor by scruffian. View the logs.
4 years ago
#3
@
4 years ago
- Component changed from General to Build/Test Tools
We all know this is an age-old discussion, but I recently learned that there's an accessibility benefit to tabs instead of spaces. It allows developers with vision difficulties to control the spacing in their editor which they cannot do with spaces: https://twitter.com/johnbillion/status/1380173004307595266.
#4
@
3 months ago
Reviewed the current state of trunk, The editorconfig change for JSON has not been applied yet. The unrelated parts of the original patch (block theme template detection) were addressed separately.
All JSON files in core already use tabs for indentation. The json_encode spaces-to-tabs workaround already exists.
I think we should explicitly add [*.json] with indent_style = tab to editorconfig, this formalizes the existing convention, requires no file changes, and preserves the accessibility benefit of tabs noted in comment #3
I am open to discussing and scrutinising this further, or I'll go ahead and test this out whenever I next get the bandwidth.
Coding standards change