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).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With