Created
September 12, 2014 07:41
-
-
Save DjebbZ/ee6c50c7a155c5fd6cd4 to your computer and use it in GitHub Desktop.
Lint your React's JSX code with stock JSHint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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