"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];

var _jsYaml = _interopRequireDefault(require("js-yaml"));

if (typeof window !== 'undefined') {
  require('codemirror/addon/lint/lint.css');

  require('codemirror/addon/lint/lint'); // eslint-disable-next-line @typescript-eslint/no-var-requires


  var CodeMirror = require('codemirror');

  CodeMirror.registerHelper('lint', 'yaml', function (text) {
    var found = [];

    try {
      _jsYaml["default"].loadAll(text);
    } catch (e) {
      var loc = e.mark,
          message = e.message; // js-yaml YAMLException doesn't always provide an accurate lineno
      // e.g., when there are multiple yaml docs
      // ---
      // ---
      // foo:bar

      var from = loc ? CodeMirror.Pos(loc.line, loc.column) : CodeMirror.Pos(0, 0);
      var to = from;
      found.push({
        from: from,
        to: to,
        message: message
      });
    }

    return found;
  });
}
//# sourceMappingURL=yaml.js.map
