Construct 2 exports and JSLint

Discussion and feedback on Construct 2

Post » Tue May 15, 2012 6:29 am

For anyone unaware, JSLint is a JavaScript code quality tool created by JavaScript guru Douglas Crockford. I fully realize JSLint is one developer's perspective on how JavaScript code should be structured, but thought it would be a potentially good marketing piece for Construct 2 if it perfectly passed JSLint inspection.

That said, I just ran an exported c2runtime.js through JSLint (via Notepad++) and it had nearly no issues. The following illustrates one such issue.

Here's a portion of the original exported code:


And here's an adjusted version that passes JSLint:


Just that small change in the structure allows that one item to pass through JSLint. And with that adjustment, there were only a few small issues left over, as illustrated in the following:


Of course, I'm not expecting changes to be made to C2 to accommodate JSLint. I was just thinking that since it's so very close to passing JSLint inspection, it'd be a pretty nice thing to be able to advertise that it does so.
B
126
S
7
G
4
Posts: 185
Reputation: 7,233

Post » Tue May 15, 2012 6:49 am

If you're interested in JavaScript lint, check out this recent article: JavaScript Style Guides

It is primarily about style guides, but mentions some other lint tools.

I just wish Crockford was a better writer. But he does cover why the code you singled out doesn't always work and you're better to put everything in curly braces. Crock reminds me all too much of K&R - everything is there but not easy to find or read.Bob Thulfram2012-05-15 06:51:37
Check out my HTML5 Firefox OS Game Programming and Game Playing blog at http://firefoxosgaming.blogspot.com/ and my book on Amazon at http://www.amazon.com/dp/B00IZUYIGO. I wrote a newer post on using Construct for Firefox OS at http://firefoxosgaming.blogspot.com/201 ... -game.html.
B
16
S
4
G
4
Posts: 181
Reputation: 3,837

Post » Tue May 15, 2012 8:55 am

@Bob Thulfram, good article, thanks for linking to it! For anyone further interested, there's an excellent talk on all of this from Douglas Crockford, focusing on the "good parts" of JavaScript, via the following video:

[TUBE]http://www.youtube.com/watch?v=hQVTIJBZook[/TUBE]

I was actually meaning to create a post here in the forums highlighting the fact that with C2, you don't need to worry at all about these things. Generally, you don't need to worry about syntax errors as well. In my opinion, this method of scripting really does lend very well to workflow, ala less debugging.

I also forgot to mention in my original post, it would be a bit ironic if C2 was made to pass JSLint, yet it relies on jQuery which doesn't quite. ;)



B
126
S
7
G
4
Posts: 185
Reputation: 7,233

Post » Tue May 15, 2012 2:17 pm

JSLint is a useful tool for web development, but I don't think it is useful for C2. It wasn't designed for our type of use, and it only makes source-formatting type suggestions, which is not really important to end users. Nobody can usefully work with the Javascript output from export, but you can use the plugin SDK which is much neater and easier to work with.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544


Return to Construct 2 General

Who is online

Users browsing this forum: digitalsoapbox, saiyadjin and 16 guests