LaravelTest
47 строк · 1.4 Кб
1// CodeMirror, copyright (c) by Marijn Haverbeke and others
2// Distributed under an MIT license: https://codemirror.net/LICENSE
3
4// Depends on coffeelint.js from http://www.coffeelint.org/js/coffeelint.js
5
6// declare global: coffeelint
7
8(function(mod) {9if (typeof exports == "object" && typeof module == "object") // CommonJS10mod(require("../../lib/codemirror"));11else if (typeof define == "function" && define.amd) // AMD12define(["../../lib/codemirror"], mod);13else // Plain browser env14mod(CodeMirror);15})(function(CodeMirror) {16"use strict";17
18CodeMirror.registerHelper("lint", "coffeescript", function(text) {19var found = [];20if (!window.coffeelint) {21if (window.console) {22window.console.error("Error: window.coffeelint not defined, CodeMirror CoffeeScript linting cannot run.");23}24return found;25}26var parseError = function(err) {27var loc = err.lineNumber;28found.push({from: CodeMirror.Pos(loc-1, 0),29to: CodeMirror.Pos(loc, 0),30severity: err.level,31message: err.message});32};33try {34var res = coffeelint.lint(text);35for(var i = 0; i < res.length; i++) {36parseError(res[i]);37}38} catch(e) {39found.push({from: CodeMirror.Pos(e.location.first_line, 0),40to: CodeMirror.Pos(e.location.last_line, e.location.last_column),41severity: 'error',42message: e.message});43}44return found;45});46
47});48