-
-
Notifications
You must be signed in to change notification settings - Fork 776
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
Add "noArrayIndent" option #461
Conversation
lib/js-yaml/dumper.js
Outdated
@@ -107,6 +107,7 @@ function encodeHex(character) { | |||
function State(options) { | |||
this.schema = options['schema'] || DEFAULT_FULL_SCHEMA; | |||
this.indent = Math.max(1, (options['indent'] || 2)); | |||
this.indentArrays = (options['indentArrays'] === undefined) ? true : !!options['indentArrays']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defaulting to true to maintain backwards-compatibility.
.gitignore
Outdated
@@ -5,3 +5,4 @@ doc | |||
benchmark/implementations/* | |||
!/benchmark/implementations/current/ | |||
.idea | |||
package-lock.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The package lock should either be committed or ignored. Seeing as it isn't committed, I'm ignoring it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't touch configs if PR is not related
package.json
Outdated
@@ -1,6 +1,6 @@ | |||
{ | |||
"name": "js-yaml", | |||
"version": "3.12.0", | |||
"version": "3.13.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if I'm supposed to version bump or not...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't change configs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- squash all to single commit pleaze
.gitignore
Outdated
@@ -5,3 +5,4 @@ doc | |||
benchmark/implementations/* | |||
!/benchmark/implementations/current/ | |||
.idea | |||
package-lock.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't touch configs if PR is not related
lib/js-yaml/dumper.js
Outdated
@@ -107,6 +107,7 @@ function encodeHex(character) { | |||
function State(options) { | |||
this.schema = options['schema'] || DEFAULT_FULL_SCHEMA; | |||
this.indent = Math.max(1, (options['indent'] || 2)); | |||
this.indentArrays = (typeof options['indentArrays'] === 'undefined') ? true : !!options['indentArrays']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest noArrayIndent
instead of such logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing, done.
package.json
Outdated
@@ -1,6 +1,6 @@ | |||
{ | |||
"name": "js-yaml", | |||
"version": "3.12.0", | |||
"version": "3.13.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't change configs.
@puzrin I have completed all requested changes, and squashed all the commits down to a single commit as requested. Thanks |
FYI: I highly recommend you use "squash merges" functionality in the repository settings, rather than requiring contributors to rewrite history on their feature branches. |
Thanks! I know about "squash merges". But it just more convenient for review to to collapse long tail of commits, when only couple of files affected. |
@jacob-hd could you take a look at #468 (comment)? Seems indents become broken when top level array contains objects |
=>
One more example of bad behaviour. Seems initial PR has not enougth nested samples. |
Following on from what @puzrin said about the issue with noArrayIndent, the following also does not work:
=>
vs expected
I suspect that the issue might be resulting from an earlier fix by @diberry (namely https://github.com/diberry/js-yaml/commit/18a871cf69435309598393be86006e39abc9d492), where the level should be >= 0, rather than just > 0, but I am not entirely sure. Just trying to provide a pointer :) |
Addresses issue #432 by adding a
noArrayIndent
option to optionally not add an extra level of indentation to array elements.When
noArrayIndent
option is set tofalse
(or not provided), output is:When
noArrayIndent
option is set totrue
, output is:This helps avoid diffs when parsing, modifying, and generating valid yaml that does not use extra indentation for arrays.