Categories
Uncategorized

Practical Fascism

On my recent project at work, I’ve instigated a number of features:

  • An XSLT stylesheet that strips out all inline JavaScript and inline CSS before it ever hits the browser. Go-go Unobtrusive JavaScript!
  • Lots of jUnit tests:
    • Every piece of static HTML gets validated via RelaxNG (we had to use RelaxNG in order to allow mixed namespaces).
    • Ditto for every piece of XSLT.
    • A well-formedness test for every piece of XML.
    • A jslint test to check every file of JavaScript isn’t doing anything silly.
    • A “no tabs” test to ensure that there are no literal tabs in any piece of source code (in accordance with our local conventions).

I haven’t yet gotten around to integrating checkstyle. And I really need to write an XQuery parser that understands the ancient dialect we seem to be saddled with.

On the whole, these tests have proved to be a minor inconvenience up-front, often leading to groans around the office when the build breaks. But as a whole they’ve kept the code base clean and managed to detect problems early. So on the whole they’re a win. I’ll definitely be dragging them along to my next project.

Categories
Uncategorized

jslint4java 1.1

I’ve put out a new version of jslint4java. The changes aren’t huge, but there are a couple of note:

  • Fix Issue 1: a NullPointerException when jslint gives up. This is doubly annoying because it’s both documented and it caught me out when writing the Perl wrapper, JavaScript-JSLint.
  • I’ve added an ant task so you can verify a bunch of JavaScript files as part of a built. I was really surprised at how easy this was to throw together.
  • I’ve upgraded to the latest version of jslint. It seems to be pickier about whitespace. I do wish Douglas Crockford kept a changelog…

In the meantime, I’ve also been working on an Eclipse plugin. It’s in a “works for me” state at the moment, and needs some more love before it gets published. In particular, it needs to be able to choose whether or not to validate on a file-by-file basis, in case you have a packed JavaScript file.