| 1 |
// Depends on coffeelint.js from http://www.coffeelint.org/js/coffeelint.js |
| 2 |
|
| 3 |
CodeMirror.registerHelper("lint", "coffeescript", function(text) { |
| 4 |
var found = []; |
| 5 |
var parseError = function(err) { |
| 6 |
var loc = err.lineNumber; |
| 7 |
found.push({from: CodeMirror.Pos(loc-1, 0), |
| 8 |
to: CodeMirror.Pos(loc, 0), |
| 9 |
severity: err.level, |
| 10 |
message: err.message}); |
| 11 |
}; |
| 12 |
try { |
| 13 |
var res = coffeelint.lint(text); |
| 14 |
for(var i = 0; i < res.length; i++) { |
| 15 |
parseError(res[i]); |
| 16 |
} |
| 17 |
} catch(e) { |
| 18 |
found.push({from: CodeMirror.Pos(e.location.first_line, 0), |
| 19 |
to: CodeMirror.Pos(e.location.last_line, e.location.last_column), |
| 20 |
severity: 'error', |
| 21 |
message: e.message}); |
| 22 |
} |
| 23 |
return found; |
| 24 |
}); |
| 25 |
CodeMirror.coffeeValidator = CodeMirror.lint.coffeescript; // deprecated |
| 26 |
|