-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Labels
lang:yamlIssues affecting YAMLIssues affecting YAMLlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.scope:dependencyIssues that cannot be solved inside Prettier itself, and must be fixed in a dependencyIssues that cannot be solved inside Prettier itself, and must be fixed in a dependency
Description
Prettier 2.2.1
Playground link
Input:
key1: &default
subkey1: value1
key2:
<<: *defaultOutput:
test.yml[error] test.yml: SyntaxError: Nested mappings are not allowed in compact mappings (1:7)
[error] > 1 | key1: &default
[error] | ^^^^^^^^
[error] > 2 |
[error] | ^
[error] > 3 | subkey1: value1
[error] | ^
[error] > 4 |
[error] | ^
[error] 5 | key2:
[error] 6 | <<: *default
[error] 7 |
Expected behavior:
No error. The file should be formatted.
Both Python and Ruby YAML libraries load this file with the expected results.
In my production code, the blank line exists there to separate a comment.
key1: &default
# This key ...
subkey1: value1
key2:
<<: *defaultWhich actually results in a different error:
test.yml[error] test.yml: SyntaxError: All collection items must start at the same column (1:1)
[error] > 1 | key1: &default
[error] | ^^^^^^^^^^^^^^
[error] > 2 |
[error] | ^
[error] > 3 | # This key ...
[error] | ^
[error] > 4 | subkey1: value1
[error] | ^
[error] > 5 |
[error] | ^
[error] > 6 | key2:
[error] | ^
[error] > 7 | <<: *default
[error] | ^
[error] > 8 |
[error] | ^
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
lang:yamlIssues affecting YAMLIssues affecting YAMLlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.scope:dependencyIssues that cannot be solved inside Prettier itself, and must be fixed in a dependencyIssues that cannot be solved inside Prettier itself, and must be fixed in a dependency