-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RRFC] format package.json
based on config values
#423
Comments
Any reason why this is specific to Some other prior art (the module we use to organize package-lock.json): https://github.com/isaacs/json-stringify-nice Note that changes to the defaults, if it causes churn in the git history, will be cause for much user outrage! |
I see value in |
Yes, the goal is to have no churn in git history when running any commands unless config values have been changed. For
|
Changes to defaults should cause no churn, because they will not affect old files, only new files. Or do you see it differently? |
@diogoeichert defaults include "editing package.json when you run |
Oh, I see. I think @lukekarrys' proposal would prevent that, though:
|
Summarizing discussion:
Getting the configs:
|
|
For "would be changed", the critical part is that it exits 0 when no changes, and exits nonzero when changes. |
This is now being tracked in npm/statusboard#384. |
Motivation ("The Why")
Allow
package.json
to be formatted according to a set of config values. This will establish default config values for howpackage.json
is written and add a command to rewrite an existingpackage.json
files based on those config values. Since these config values will live in an.npmrc
file, it will allow for users to format theirpackage.json
differently per project or globally.Example
How
In the initial implementation, default config values will be set to mirror current behavior where possible, with the goal being that formatting during commands that write to
package.json
will not be a breaking change.Sorting will be done via
localeCompare
.Configs
pkg-format-indent
current
(current
|n
|tabs
)current
is new behavior based on the discussion in [RRFC] Don't expand tabs by default #420. To not have this change any behavior, the default would be2
.pkg-format-eol
current
(current
|lf
|cr
|crlf
)current
is new behavior based on the discussion in [RRFC] Don't expand tabs by default #420. To not have this change any behavior, the default would belf
.pkg-format-sort-children
dependencies,devDependencies,peerDependencies,optionalDependencies
pkg-format-keys-start
package.json
pkg-format-keys-end
package.json
pkg-format-keys-sort
keys-start
andkeys-end
will be sortedfalse
(true
|false
)Open Questions
indent_style|indent_size
andend_of_line
fromEditorConfig
affect the comparable config values? The EditorConfig spec relies on walking the directory tree to get the values.pkg-format-indent
andpkg-format-eol
be applied topackage-lock.json
as well?References
package.json
file.fixpack
also will warn/error on missing top level keys, which is not covered by this RFC.The text was updated successfully, but these errors were encountered: