1
0

yaml-lint.js 848 B

12345678910111213141516171819202122232425262728
  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: http://codemirror.net/LICENSE
  3. (function(mod) {
  4. if (typeof exports == "object" && typeof module == "object") // CommonJS
  5. mod(require("../../lib/codemirror"));
  6. else if (typeof define == "function" && define.amd) // AMD
  7. define(["../../lib/codemirror"], mod);
  8. else // Plain browser env
  9. mod(CodeMirror);
  10. })(function(CodeMirror) {
  11. "use strict";
  12. // Depends on js-yaml.js from https://github.com/nodeca/js-yaml
  13. // declare global: jsyaml
  14. CodeMirror.registerHelper("lint", "yaml", function(text) {
  15. var found = [];
  16. try { jsyaml.load(text); }
  17. catch(e) {
  18. var loc = e.mark;
  19. found.push({ from: CodeMirror.Pos(loc.line, loc.column), to: CodeMirror.Pos(loc.line, loc.column), message: e.message });
  20. }
  21. return found;
  22. });
  23. });