When I use npm install -g jsxhint
I am able to use it to lint my jsx code, like so:
But when I try to use grunt-jsxhint
to setup a lint command, it fails:
My Gruntfile is super simple:
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-jsxhint');
/* Project configuration */
grunt.initConfig({
options: {
jshintrc: '.jshintrc',
ignores: [],
additionalSuffixes: ['.js', '.ios.js']
},
jshint: {
all: ['./app/index.ios.js']
}
});
/* Test Tasks */
grunt.registerTask('test', ['jshint']);
};
Why are these outputting different results?
JsxHint and JSHint arent the best tools for linting JSX. JSHint does not support JSX and all JsxHint does is transforms JSX and then runs JSHint on the transformed code. I have been using (and would highly recommend) ESLint with the React plugin. This is better since Eslint can parse any Javascript flavor using custom parsers (like esprima-fb)
Sample
.eslintrc
file: