Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSSTidy, HTMLTidy, JSlint pre-commit hooks(Hg) - automation tools

I am looking for a way to test/validate my html, css, js before they are committed to a repository.

Is there any way to automate this process. Ideally, I would like to have the ability to exclude certain files (js libraries for example).

like image 475
Eeyore Avatar asked Dec 31 '25 04:12

Eeyore


1 Answers

I've written jslint4java, which wraps Doug Crockford's JSLint in a way which makes it simply to invoke from a command line or ant build. That should be fairly easy to plug into a pre-commit hook. Have a look at this example of a JSLint pre-commit hook. Excluding files should be a fairly small addition.

I'm less sure about CSS and HTML validation. You can download the W3C CSS validator, and again set up a pre-commit hook to call that on CSS files. The W3C HTML validator is slightly harder to get running as it relies on nsgmls being installed (part of OpenJade, I think). You may have better luck with the HTML5 validator. You may have better luck with the HTML5 validator.

like image 61
Dominic Mitchell Avatar answered Jan 05 '26 10:01

Dominic Mitchell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!