coffeescript-lint.js
11 years ago
coffeescript-lint.min.js
8 years ago
css-lint.js
9 years ago
css-lint.min.js
10 years ago
html-lint.js
10 years ago
html-lint.min.js
10 years ago
javascript-lint.js
11 years ago
javascript-lint.min.js
8 years ago
json-lint.js
11 years ago
json-lint.min.js
8 years ago
lint.css
9 years ago
lint.js
9 years ago
lint.min.js
8 years ago
yaml-lint.js
9 years ago
yaml-lint.min.js
8 years ago
coffeescript-lint.js
42 lines
| 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others |
| 2 | // Distributed under an MIT license: http://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) { |
| 9 | if (typeof exports == "object" && typeof module == "object") // CommonJS |
| 10 | mod(require("../../lib/codemirror")); |
| 11 | else if (typeof define == "function" && define.amd) // AMD |
| 12 | define(["../../lib/codemirror"], mod); |
| 13 | else // Plain browser env |
| 14 | mod(CodeMirror); |
| 15 | })(function(CodeMirror) { |
| 16 | "use strict"; |
| 17 | |
| 18 | CodeMirror.registerHelper("lint", "coffeescript", function(text) { |
| 19 | var found = []; |
| 20 | var parseError = function(err) { |
| 21 | var loc = err.lineNumber; |
| 22 | found.push({from: CodeMirror.Pos(loc-1, 0), |
| 23 | to: CodeMirror.Pos(loc, 0), |
| 24 | severity: err.level, |
| 25 | message: err.message}); |
| 26 | }; |
| 27 | try { |
| 28 | var res = coffeelint.lint(text); |
| 29 | for(var i = 0; i < res.length; i++) { |
| 30 | parseError(res[i]); |
| 31 | } |
| 32 | } catch(e) { |
| 33 | found.push({from: CodeMirror.Pos(e.location.first_line, 0), |
| 34 | to: CodeMirror.Pos(e.location.last_line, e.location.last_column), |
| 35 | severity: 'error', |
| 36 | message: e.message}); |
| 37 | } |
| 38 | return found; |
| 39 | }); |
| 40 | |
| 41 | }); |
| 42 |