Applying flow style to the elements of the YAML sequence when there is enough width
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 52.3k
- Forks
- 5k
- Avg merge
- 19h 2m
- Merged PRs (30d)
- 117
Description
Prettier 3.3.3
Playground link
--parser yaml
Input:
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
ports:
- protocol: TCP
port: 10000
targetPort: 20000
- protocol: TCP
port: 10001
targetPort: 20001
- protocol: TCP
port: 10002
targetPort: 20002
- protocol: TCP
port: 10003
targetPort: 20003
- protocol: TCP
port: 10004
targetPort: 20004
- protocol: TCP
port: 10005
targetPort: 20005
- protocol: TCP
port: 10006
targetPort: 20006
Output:
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
ports:
- protocol: TCP
port: 10000
targetPort: 20000
- protocol: TCP
port: 10001
targetPort: 20001
- protocol: TCP
port: 10002
targetPort: 20002
- protocol: TCP
port: 10003
targetPort: 20003
- protocol: TCP
port: 10004
targetPort: 20004
- protocol: TCP
port: 10005
targetPort: 20005
- protocol: TCP
port: 10006
targetPort: 20006
Expected output:
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
ports:
- {protocol: TCP, port: 10000, targetPort: 20000}
- {protocol: TCP, port: 10001, targetPort: 20001}
- {protocol: TCP, port: 10002, targetPort: 20002}
- {protocol: TCP, port: 10003, targetPort: 20003}
- {protocol: TCP, port: 10004, targetPort: 20004}
- {protocol: TCP, port: 10005, targetPort: 20005}
- {protocol: TCP, port: 10006, targetPort: 20006}
Why?
In sequences, similar structures are often repeated.
When there are sufficiently few keys for the elements, a compact flow-style format on a single line can reduce the amount of scrolling, making it easier to compare elements and potentially improving visibility.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the YAML example with the linked Playground configuration and the yaml parser. Trace the formatter's YAML sequence handling from the parser entry point, then add coverage for the shown input and expected flow-style output. Done means the repeated short mappings format compactly without changing unrelated YAML output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100