How To Add Some Known Objects To Ace Editors Syntax Checker?
we're using the ACE editor to write javascript code that's interpreted on the server side. So the server has a JavaScript interface and can execute submitted code to accomplish som
Solution 1:
Ace uses jshint, which have an option to set a list of global variables. Ace supports changeOptions call on worker to modify default options it passes to jshint, but doesn't have a way to pass list of gloabals
You can add it by changing line at https://github.com/ajaxorg/ace/blob/v1.1.8/lib/ace/mode/javascript_worker.js#L130
to lint(value, this.options, this.options.globals);
and from your code calling
editor.session.$worker.call("changeOptions", [{
globals: {foo: false, bar: false...},
undef: true, // enable warnings on undefined variables// other jshint options go here check jshint site for more info
}]);
the change to worker.js#L130 is simple enough and should be accepted if you make a pull request to ace
Post a Comment for "How To Add Some Known Objects To Ace Editors Syntax Checker?"