Adding ESLint with gulp.js for React.JS

[sourcecode language=”bash”]
$ npm install babel-eslint — save-dev 
$ npm install gulp — save
$ npm install gulp-eslint — save
[/sourcecode]
gulpfile.js will contains like this:
[sourcecode language=”javascript”]
var gulp = require(‘gulp’);
var eslint = require(‘gulp-eslint’);

gulp.task(‘lint’, function() {
 return gulp.src(‘src/**’)
 .pipe(eslint({
 useEslintrc: true,
 envs: [‘node’]
 }))
 .pipe(eslint.format())
 // Brick on failure to be super strict
 .pipe(eslint.failAfterError());
});

[/sourcecode]

.eslintrc file:
[sourcecode language=”javascript”]
{
 “parser”: “babel-eslint”,
 “env”: {
 “node”: true
 },
 “rules”: {
 “array-bracket-spacing”: [2, “never”],
 “computed-property-spacing”: [2, “never”],
 “eol-last”: 2,
 “no-extend-native”: 2,
 “no-mixed-spaces-and-tabs”: 2,
 “no-trailing-spaces”: 2,
 “object-curly-spacing”: [2, “never”],
 “quotes”: [2, “single”, “avoid-escape”],
 “semi”: [2, “always”],
 “keyword-spacing”: [2, {“before”: true, “after”: true}],
 “space-unary-ops”: 2,
 ‘indent’: [‘error’, 2, { “SwitchCase”: 1, “MemberExpression”: 1, “VariableDeclarator”: 1}]
 }
}
[/sourcecode]

If you encountered an error Parsing error: The keyword ‘import’ is reserved then you need to install babel-eslint package.
$ npm install — save-dev babel-eslint