Ticket #2571 (new enhancement)

Opened 21 months ago

Last modified 6 weeks ago

[patch] [ccla] syntax checking feature

Reported by: csawyer@… Owned by: jburke
Priority: normal Milestone: future
Component: Core Version: 0.9
Severity: normal Keywords:
Cc:

Description (last modified by jburke) (diff)

Alter dojo.require() so that when code is pulled in from sources, we verify it against a syntax checker.. the beauty is then, your code STAYS clean because everytime you run it, it will get mad if you write bad syntax like I do. This is only true if you load dojo.syntax.*. Uses jslint.com's syntax checker currently. Other checkers could be used, but no others are supported currently.

it will only start checking after you have dojo.syntax.* loaded.

features:

allow stopping on error, or just warning on error. djConfig.syntaxWarn? Follow dojo JS guidelines as much as possible. allow it to skip dojo srcs, and only get upset with stuff in your custom namespace.

current implementation at: http://www.yuma.ca/tech/js/dojo/src/syntax/

demo/testcase: http://www.yuma.ca/tech/js/testsyntax.html

Attachments

syntax.diff (100.4 kB) - added by csawyer@… 21 months ago.
patch of demo implementation.
syntaxDiff.txt (102.1 kB) - added by guest 20 months ago.
2007-4-12 revision of syntax checker.

Change History

Changed 21 months ago by csawyer@…

patch of demo implementation.

Changed 20 months ago by jburke

csawyer: sorry for not taking a look sooner at this. I've been busy with 0.9 changes and work. I won't be dealing with this patch soon, but some comments:

You don't need loader enhancements to plug this in. You can override dojo.hostenv.getText(), and look at the file extension. If it ends in .js, run it through the syntax checker before returning the value. Something like:

{{{{ dojo.syntax._realGetText = dojo.hostenv.getText; dojo.syntax.getText = function(uri, async_cb, fail_ok){

var contents = dojo.syntax._realGetText.apply(this.hostenv, arguments); if(contents && /*do checking for if syntax is loaded and is a .js file*/){

//Do syntax checking in here.

} return contents;

} dojo.hostenv.getText = dojo.syntax.getText; }}}

Since dojo.syntax is always included after the real getText() is defined, this should work out, and allow the module to stand on its own.

Changed 20 months ago by jburke

Ack. I messed up the formatting. Hopefully you get the idea.

Changed 20 months ago by guest

Find a new attachment that brings syntax checking hopefully up to par. I got the idea jburke, thank you!

This changes a lot in the checker as well, plus overrides getText.

Changed 20 months ago by guest

2007-4-12 revision of syntax checker.

Changed 17 months ago by peller

  • milestone changed from 0.9beta to 0.9

we can't hold up beta for this. Moving to 0.9

Changed 16 months ago by peller

This needs to go in dojox, due to external packages and varying licenses. Seems like the right place for it anyhow. I suppose the issue then is just getting the right hook for dojo.require()? It would be neat if we could use an aspect-oriented approach rather than hacking up dojo.require. Can we use after advice and resurrect the path from the return value of require()?

I suggest we resolve that issue then get an updated patch for dojox. Probably shouldn't be a 0.9 deliverable at this point.

Changed 16 months ago by jburke

peller: I agree. I've been talking with Tom about the right place for this in dojox. I was keeping it as a 0.9 issue for now, because I feel bad about letting a patch sit this long. But I agree, if I run out of time (which seems likely), I can push to 1.0.

Changed 16 months ago by jburke

  • milestone changed from 0.9 to 1.0

I wanted to get this in for 0.9, but I'm not going to make it. Sorry to hold this off for so long.

Changed 16 months ago by peller

Cathy, sorry to ask you this after us all waiting so long, but would you be interested in helping us get this updated to 1.0 APIs and experimenting with solutions for the dojo.require hooks/AOP?

Changed 14 months ago by peller

suggest we push to 2.0 or punt

Changed 14 months ago by peller

  • milestone changed from 1.0 to 2.0

Changed 9 months ago by alex

  • milestone changed from 2.0 to 1.3

Milestone 2.0 deleted

Changed 6 weeks ago by jburke

  • description modified (diff)
  • milestone changed from 1.3 to future
Note: See TracTickets for help on using tickets.