Skip to content

Consider switching YAML libraries #13

@eemeli

Description

@eemeli

At the moment, YAML files are loaded with require('js-yaml').load(), while JSON uses JSON.parse(). It might make sense to switch both of these to use require('yaml').parse() instead. This would have the following benefits:

  • yaml has better YAML spec compliance; see the YAML Test Matrix, which shows results for js-yaml as "js-yaml-json" and yaml as "js-event" and "js-json".
  • Safer config data loading, as the js-yaml load() supports JavaScript being encoded in YAML files. Obviously NYC also supports .js files for config, but it might still be surprising for a config loaded from a YAML file not to be guaranteed inert.
  • Better error reporting, in particular for JSON files -- JSON is a subset of YAML, and can be loaded as such.
  • Support for # comments in JSON files.

As disclosure, I'm the developer of yaml, so my opinions may be a little biased here. I'm interested, as yaml itself ends up having @istanbuljs/load-nyc-config as a dev dependency. I would be quite willing to submit a PR for this change, but thought it'd be more polite to ask first.

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