Skip to content

Instantly share code, notes, and snippets.

@DjebbZ
Created September 12, 2014 07:41
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DjebbZ/ee6c50c7a155c5fd6cd4 to your computer and use it in GitHub Desktop.
Save DjebbZ/ee6c50c7a155c5fd6cd4 to your computer and use it in GitHub Desktop.
Lint your React's JSX code with stock JSHint
/*
As JSX code is not lintable by JSHint, we simply transform
JSX to Javascript with react-tools then lint the resulting Javascript.
Bonus : as a JSX tag is just a Javascript function,
you get 1:1 match on line errors !
*/
var gulp = require("gulp"),
jshint = require("gulp-jshint"),
react = require("gulp-react");
var JS_SRC_DIR = "./src/**/*.js";
gulp.task("lint", function() {
return gulp.src(JS_SRC_DIR)
.pipe(react())
.pipe(jshint())
.pipe(jshint.reporter("default", {verbose: true}))
.pipe(jshint.reporter("fail"));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment