Thursday, October 11, 2012

ACE JavaScript Lint

‹prev | My Chain | next›

Last night I was able to get the ACE editor working fairly well with my fork of Mr Doob's code editor.

There is still one thing that bugs me about ACE. Tab markers:


They are not even tab markers since I have disabled tabs with setUseSoftTabs(true). They are more extra indent markers and they seem unnecessary.

To turn them off, I eventually find setDisplayIndentGuides():
var ace = ace.edit("editor");
ace.setTheme("ace/theme/chrome");
ace.getSession().setMode("ace/mode/javascript");
ace.getSession().setUseWrapMode(true);
ace.getSession().setUseSoftTabs(true);
ace.setPrintMarginColumn(false);
ace.setDisplayIndentGuides(false);
With that, I am ready to look at something a little more interesting: JavaScript syntax checking.

In Gaming JavaScript, I had planned to introduce kids to the joys of the Chrome JavaScript console. But ACE supports syntax checking that might not make that necessary. Actually, I'll almost certainly include that anyway because I think it a fun introduction to hacking, but syntax checking can only help.

But, if I set the editor mode to JavaScript:
ace.getSession().setMode("ace/mode/javascript");
I am not seeing anything—even if I intentionally add an error.

Eventually, I notice the following in the JavaScript console:


Well, that is easy enough to fix. I copy the JavaScript worker from the ACE source that I downloaded the other day:
➜  code-editor git:(ace) ✗ cp ../ace-builds/src/worker-javascript.js js/ace 
With that, I see an error. Only not the right one:


Darn. I really want to include HTML tags in the Gaming JavaScript editor. I think that I helps to give a better perspective of how all of this fits together. But unfortunately ACE in JavaScript mode sees that HTML as a JavaScript syntax error.

I try switching to HTML/mixed mode instead:
var ace = ace.edit("editor");
ace.setTheme("ace/theme/chrome");
ace.getSession().setMode("ace/mode/html");
But now there are no errors at all:


I do not know how important this really is to me. I may fiddle with the JavaScript worker to see if I can convince it to ignore HTML. I may also investigate Esprima a bit as an alternative. Tomorrow.

Day #537

1 comment:

  1. Japh(R) By Chris Strom: Ace Javascript Lint >>>>> Download Now

    >>>>> Download Full

    Japh(R) By Chris Strom: Ace Javascript Lint >>>>> Download LINK

    >>>>> Download Now

    Japh(R) By Chris Strom: Ace Javascript Lint >>>>> Download Full

    >>>>> Download LINK zY

    ReplyDelete