Construct 2 exports and JSLint

0 favourites
  • 4 posts
From the Asset Store
Casino? money? who knows? but the target is the same!
  • 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:

    <img src="" border="0" />

    And here's an adjusted version that passes JSLint:

    <img src="" border="0" />

    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:

    <img src="" border="0" />

    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.

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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:


    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. ;)

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)