Skip to content

[writer] Prevent unnecessary space at end of lines with three-space indent #342

@jthomerson

Description

@jthomerson

When you indent with three spaces (our coding standard), you get a weird trailing EOL space on lines with array indicators.

For example, this script:

'use strict';

var fs = require('fs'),
    path = require('path'),
    yaml = require('js-yaml'),
    data = { values: [ { a: 1 }, { b: 2 }, { c: 'three' } ] };

fs.writeFile(path.join(__dirname, 'sample.yml'), yaml.safeDump(data, { indent: 3 }), function(err) {
   if (err) {
      console.log('ERROR:', err, err.stack);
   }
   console.log('complete');
});

Results in this (note that I added $ at the end of each line so that the space is apparent).

values:$
   - $
      a: 1$
   - $
      b: 2$
   - $
      c: three$

Similar to #68

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions