[openstack-dev] [horizon] adding jshint to qunit tests (was: Javascript development improvement)
Radomir Dopieralski
openstack at sheep.art.pl
Mon Nov 25 09:46:21 UTC 2013
On 22/11/13 16:08, Imre Farkas wrote:
> There's a jslint fork called jshint which is able to run in the browser
> without any node.js dependency.
>
> I created a POC patch [1] long time ago to demonstrate its capabilities.
> It's integrated with qunit and runs automatically with the horizon test
> suite.
>
> The patch also contains a .jshintrc file for the node.js package but you
> can remove it since it's not used by the qunit+jshint test at all.
This is excellent, just as I wanted to raise the issue of inconsistent
style in js in Horizon. Running jshint as part of the qunit tests is a
great solution that I didn't even think about. I think we should
definitely use that.
For people who don't have everyday contact with JavaScript, jshint is
not just a style checker similar to pep8 or flake8. JavaScript is a
language that wasn't fortunate enough to have its syntax designed and
tested for a long time by a crowd of very intelligent and careful
people, like Python's. It's full of traps, things that look very
innocent on the surface and seem to work without any errors, but turn
out to be horribly wrong -- and all because of a missing semicolon or an
extra comma or even a newline in a wrong spot. Jshint catches at least
the most common mistakes like that, and I honestly can't imagine writing
JavaScript without having it enabled in my editor. We definitely want to
use it sooner or later, and preferably sooner.
Whether we need node.js for it or not is a technical issue -- as Imre
demonstrated here, this one can be solved without node.js, so there is
really nothing stopping us from adopting it.
--
Radomir Dopieralski
More information about the OpenStack-dev
mailing list