Like grunt-contrib-jshint but compatible with react's jsx

Getting Started

This plugin requires Grunt ~0.4.0

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-jsxhint --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt . loadNpmTasks ( ' grunt-jsxhint ' ) ;

Jshint task

This grunt plugin works exactly like grunt-contrib-jshint. In fact it's even using grunt-contrib-jshint . The only difference to grunt-contrib-jshint is that this plugin runs require('bable-core').transform(code, {plugins: ["transform-react-jsx"]}); on every file passed in. This will transform the jsx syntax to regular JavaScript. Non jsx-files will be unchanged. Line numbers are preserved by jsx so the line numbers outputted by jshint will be correct.

This is a drop in replacement for grunt-contrib-jshint . So you can just replace the grunt-contrib-jshint dependency in your package.json with grunt-jsxhint .

grunt-jsxhint needs bable-core and babel-plugin-transform-react-jsx to work. If you don't have either installed run

npm install babel-core babel-plugin-transform-react-jsx --save-dev

Use exactly like grunt-contrib-jshint :

jshint : { }

Parsed filed extensions

By default, your jsx files need to have a .jsx or .react.js file extension. In order to parse other files, add the following into your jshint options object:

jshint : { options : { jshintrc : ' .jshintrc ' , ignores : [ ] , additionalSuffixes : [ ' .js ' ] } , }

These suffixes are concatenated onto .jsx and .react.js.

Contributing

If grunt-jsxhint is lacking a feature or if you found bug (or a typo in the README) feel free to submit a pull request or file an issue.

Release History