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