js-yaml
js-yaml copied to clipboard
Redundant quotes added
const yaml = require('js-yaml');
const file = `
name: Node CI
on:
- push
`;
const json = yaml.load(file);
console.log(yaml.dump(json));
Output:
name: Node CI
'on':
- push
on
without quotes is a boolean true
value in YAML 1.0, old version of the spec: https://yaml.org/type/bool.html
so it's intentional, but we probably should drop support for that at some point
The solution for now is to use noCompatMode
as explained in other issue.
yaml.dump(json, {noCompatMode: true});
https://runkit.com/abitrolly/62f3a3ccbc61df0008be5b4e