Closed (outdated)
Project:
Drupal core
Version:
main
Component:
other
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
3 Jul 2018 at 11:33 UTC
Updated:
19 Jul 2026 at 12:11 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
webflo commentedComment #3
tstoecklerYup, scanned through the file and it all looks good to me. Thanks!
Comment #4
cilefen commentedIs there a way we could prevent code style drift in these files?
Comment #5
idebr commentedI suppose it would be enforced by adding a CodeSniffer rule. It is currently only added as a setting in .editorconfig
Comment #6
mile23I'm not sure we should use PHPCS for JSON.
We have eslint etc but there are a few problems:
1) There's no build step for it.
2) There's no build step for it.
We also have this: #2708751: Run composer validate --strict if a composer.json exists It addresses malformed JSON but not CS stuff like indentation.
Comment #7
webflo commentedThis could be a follow-up issue?
Comment #13
mpp commentedIsn't a .json file a type of javascript and doesn't Drupal expect those to be indented with 2 spaces?
I don't want to complicate the discussion but I couldn't find where composer states that it requires an indentation of 4 spaces. On the contrary there has been a discussion that they don't want to enforce it. See https://github.com/composer/composer/issues/5494
Comment #17
quietone commented@webflo, thanks for the patch!
Coding standard issues are tasks not bugs, changing category.
I searched for json coding standards in the JavaScript coding standards and did not find any mention of json. Nor could I find it mentioned in any of the code standard documentation.
I asked in #coding-standards and #documentation and got somewhat different answers. In #bugsmash, longware wasn't aware or any and in #documentation bradjones1 assumed that json would be covered as 'an extension of the JS standards'. So, I don't know either.
I do know that, if this were to be done, it would be changed after there was some checking of the json files so that they stayed compliant with the Drupal Standard. Since that isn't available right now I am postponing this on #3252380: Coding standard for json.
Comment #18
webflo commentedThanks for the follow-up issue.
I think composer.json files are somewhat special, because you can edit it with your editor and with composer cli. If you run composer require drupal/something, composer will insert the package into the composer.json file and uses 4 spaces for format the file.
This issue is about switching to 4 spaces for composer.json to minimize the diff in workflows where version control is used.
Comment #19
mile23IIRC, Composer will figure out the indentation and use that when it adds things.
Also, there's an issue in that components live outside the places our tools are normally scanning. We have an issue about that but I can't seem to find it right now.
Comment #20
mile23Related: #3272110: Drupal 9 and 10's Drupal\Component composer.json files are totally out of date
Moving forward all the components will at least be somewhat auto-generated, along with the project metapackages.
This means the path of least resistance is whatever json_encode()'s JSON_PRETTY_PRINT gives us.
Comment #25
quietone commentedThe formatting of these files was fixed in #3272110: Drupal 9 and 10's Drupal\Component composer.json files are totally out of date