Commit 0b7ed9ad authored by Jérome Perrin's avatar Jérome Perrin

monaco_editor: also lint javascript with jslint

parent 9b86cf7b
......@@ -7,6 +7,7 @@
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="jslint.js" type="text/javascript"></script>
<script src="monaco-editor/prettier@1.14.0/standalone.js"></script>
<script src="monaco-editor/prettier@1.14.0/parser-babylon.js"></script>
......
/*jslint nomen: true, indent: 2 */
/*global window, rJS, monaco*/
/*global window, rJS, monaco, JSLINT */
(function(window, rJS, monaco) {
'use strict';
......@@ -49,6 +49,29 @@
editor.getModel().onDidChangeContent(deferNotifyChange);
})
.declareJob('runJsLint', function () {
var context = this;
return new RSVP.Queue()
.push(function () { return RSVP.delay(500); })
.push(function () {
if (context.state.model_language === 'javascript') {
JSLINT(context.editor.getValue(), {});
monaco.editor.setModelMarkers(
context.editor.getModel(),
'jslint',
JSLINT.data()
.errors.filter(Boolean)
.map(err => ({
startLineNumber: err.line,
startColumn: err.character,
message: err.reason,
severity: monaco.Severity.Error,
source: 'jslint'
}))
);
}
});
})
.declareMethod('render', function(options) {
var model_language,
state_dict = {
......@@ -112,7 +135,11 @@
}
);
// Annotations for javascript
// lint with jslint
this.editor.getModel().onDidChangeContent(this.runJsLint.bind(this));
this.runJsLint();
// lint with typescript compiler
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
noSemanticValidation: false,
noSyntaxValidation: false
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment