diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..4d0cfbed --- /dev/null +++ b/.eslintrc @@ -0,0 +1,37 @@ +{ + "parser": "babel-eslint", + "env": { + "browser": true, + "es6": true + }, + "rules": { + "quotes": [2, "single"], + "eol-last": [0], + "no-mixed-requires": [0], + "no-underscore-dangle": [0], + "react/display-name": 1, + "react/jsx-boolean-value": 1, + "react/jsx-no-undef": 1, + "react/jsx-quotes": 1, + "react/jsx-sort-prop-types": 1, + "react/jsx-sort-props": 1, + "react/jsx-uses-react": 1, + "react/jsx-uses-vars": 1, + "react/no-did-mount-set-state": 1, + "react/no-did-update-set-state": 1, + "react/no-multi-comp": 1, + "react/no-unknown-property": 1, + "react/prop-types": 1, + "react/react-in-jsx-scope": 1, + "react/self-closing-comp": 1, + "react/sort-comp": 1, + "react/wrap-multilines": 1 + }, + "plugins": [ + "react" + ], + "ecmaFeatures": { + "jsx": true, + "modules": true + } +} \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index a685ea56..1790e3ff 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -12,6 +12,7 @@ var notify = require('gulp-notify'); var sass = require('gulp-sass'); var concat = require('gulp-concat'); var _ = require('lodash'); +var eslint = require('gulp-eslint'); var config = { bootstrapDir: './node_modules/bootstrap-sass' @@ -21,7 +22,7 @@ gulp.task('build', function() { bundle(false); }); -gulp.task('serve', ['browser-sync', 'sass', 'sass:watch', 'copy'], function() { +gulp.task('serve', ['browser-sync', 'sass', 'sass:watch', 'copy', 'lint'], function() { bundle(true); }); @@ -64,6 +65,19 @@ gulp.task('copy', function () { .pipe(gulp.dest('./build/fonts')); }); +gulp.task('lint', function () { + return gulp.src(['js/**/*.js']) + // eslint() attaches the lint output to the eslint property + // of the file object so it can be used by other modules. + .pipe(eslint()) + // eslint.format() outputs the lint results to the console. + // Alternatively use eslint.formatEach() (see Docs). + .pipe(eslint.format()) + // To have the process exit with an error code (1) on + // lint error, return the stream and pipe to failOnError last. + .pipe(eslint.failOnError()); +}); + function bundle(watch) { var bro; diff --git a/package.json b/package.json index 99f8f431..5de03b4e 100644 --- a/package.json +++ b/package.json @@ -3,18 +3,25 @@ "version": "0.0.1", "description": "Das neue web client for Ascribe", "main": "js/app.js", + "scripts": { + "lint": "eslint ./js" + }, "author": "Ascribe", "license": "Copyright", "private": true, "devDependencies": { + "babel-eslint": "^3.1.11", "babel-jest": "^4.0.0", "babelify": "^6.1.2", "bootstrap-sass": "^3.3.4", "browser-sync": "^2.7.5", "browserify": "^9.0.8", "envify": "^3.4.0", + "eslint": "^0.22.1", + "eslint-plugin-react": "^2.5.0", "gulp": "^3.8.11", "gulp-concat": "^2.5.2", + "gulp-eslint": "^0.13.2", "gulp-if": "^1.2.5", "gulp-notify": "^2.2.0", "gulp-sass": "^2.0.1", @@ -37,7 +44,6 @@ "react-bootstrap": "~0.22.6", "react-router": "^0.13.3", "uglifyjs": "^2.4.10", - "react-bootstrap": "~0.22.6", "react-datepicker": "~0.8.0" }, "jest": {