blockMappings
Prefer block-style mappings over flow-style mappings.
✅ This rule is included in the yaml stylistic presets.
Flow-style mappings (e.g., {key: value}) can be harder to read and maintain, especially with nested structures.
Block-style mappings use indentation to show structure, making the YAML more readable and consistent with common YAML conventions.
Examples
Section titled “Examples”key: { nested: value }outer: { inner: value, another: data }key: nested: valueouter: inner: value another: dataOptions
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If you’re working with a large existing YAML codebase that predominantly uses flow-style mappings and refactoring would be too disruptive, you might choose to disable this rule. However, block-style mappings are generally more readable and maintainable, especially as configurations grow in complexity.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- ESLint:
yml/block-mapping
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.