This Symfony 2 Bundle registers an Assetic filter to pass JavaScript files through JsHint on compilation.
Install the bundle using composer (see http://getcomposer.org/ for more information about composer) by adding it to your composer.json
file and running composer update
:
// composer.json
"require": {
// ...
"codelovers/assetic-jshint": "dev-master",
"codelovers/assetic-jshint-bundle": "dev-master"
}
Then just add the bundle to your AppKernel.php
file:
<?php
// in AppKernel::registerBundles()
$bundles = array(
// ...
new CodeLovers\JsHintBundle\CodeLoversJsHintBundle(),
// ...
);
You will need to install JsHint to use this bundle. We assume you already have installed node.js:
npm install -g jshint
All you need to configure is the path to your jshint binary. Most likely it will be /usr/bin/jshint
(that's the default value of the bundle's configuration) or /usr/local/bin/jshint
code_lovers_js_hint:
jshint_bin: ~
Simply apply the filter to your JavaScript assets:
{% javascripts
'@AcmeDemoBundle/Resources/js/app.js'
filter='jshint' output='compiled/js/app.js' %} ... {% endjavascripts %}