From 75de16079fd845c18e8826767b13b04c7f87a1b2 Mon Sep 17 00:00:00 2001 From: Jake Marsh Date: Wed, 11 May 2016 22:24:14 -0700 Subject: [PATCH 1/4] bump linter package versions --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 85491b2..fa96855 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ ], "devDependencies": { "babel-core": "^6.3.15", - "babel-eslint": "^5.0.0-beta4", + "babel-eslint": "^6.0.4", "babel-plugin-transform-object-rest-spread": "^6.3.13", "babel-preset-es2015": "^6.3.13", "babel-preset-react": "^6.3.13", @@ -27,10 +27,10 @@ "change-case": "^2.3.1", "debowerify": "^1.3.1", "del": "^2.2.0", - "eslint-plugin-react": "^3.6.3", + "eslint-plugin-react": "^5.1.1", "gulp": "^3.9.0", "gulp-autoprefixer": "^3.1.0", - "gulp-eslint": "^1.1.1", + "gulp-eslint": "^2.0.0", "gulp-if": "^2.0.0", "gulp-imagemin": "^2.3.0", "gulp-jsx-coverage": "^0.3.5", From 29df528490cd20091715c1b81fa80b78b93075b5 Mon Sep 17 00:00:00 2001 From: Jake Marsh Date: Wed, 11 May 2016 22:24:27 -0700 Subject: [PATCH 2/4] update eslint rules and config --- .eslintrc | 17 +++++++++++------ tests/.eslintrc | 4 ++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.eslintrc b/.eslintrc index e0e97a7..93fdf39 100644 --- a/.eslintrc +++ b/.eslintrc @@ -9,23 +9,28 @@ }, "env": { "browser": true, - "node": true + "es6": true, + "node": true, }, "rules": { "quotes": [2, "single"], - "eol-last": 0, + "eol-last": 2, "no-debugger": 1, "no-mixed-requires": 0, "no-underscore-dangle": 0, "no-multi-spaces": 0, "no-trailing-spaces": 0, "no-extra-boolean-cast": 0, - "no-unused-vars": 1, + "no-undef": 2, + "no-unused-vars": 2, + "no-var": 2, + "prefer-const": 2, "new-cap": 0, - "camelcase": 1, + "camelcase": 2, + "semi": 2, "react/jsx-uses-react": 2, "react/jsx-uses-vars": 2, - "react/react-in-jsx-scope": 0, + "react/react-in-jsx-scope": 2, "react/prop-types": 2 } -} \ No newline at end of file +} diff --git a/tests/.eslintrc b/tests/.eslintrc index 9039b52..e2c436b 100644 --- a/tests/.eslintrc +++ b/tests/.eslintrc @@ -6,6 +6,6 @@ "globals": { "sinon": true, "sandbox": true, - "Should": true + "assert": true } -} \ No newline at end of file +} From e0a124e432b777d0bf0944c84cddd6859589aca9 Mon Sep 17 00:00:00 2001 From: Jake Marsh Date: Wed, 11 May 2016 22:27:14 -0700 Subject: [PATCH 3/4] clean up gulp tasks --- gulp/config.js | 4 +++- gulp/tasks/lint.js | 4 ++-- gulp/tasks/test.js | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gulp/config.js b/gulp/config.js index c2f9f60..438c8ff 100644 --- a/gulp/config.js +++ b/gulp/config.js @@ -7,7 +7,9 @@ const config = { scripts: { src: './app/js/**/*.js', - dest: './build/js/' + dest: './build/js/', + test: './tests/**/*.js', + gulp: './gulp/**/*.js' }, images: { diff --git a/gulp/tasks/lint.js b/gulp/tasks/lint.js index d50a83a..4ff64e7 100644 --- a/gulp/tasks/lint.js +++ b/gulp/tasks/lint.js @@ -6,9 +6,9 @@ import config from '../config'; gulp.task('lint', function() { - return gulp.src([config.scripts.src, config.testFiles, './*.js']) + return gulp.src([config.scripts.src, config.scripts.test, config.scripts.gulp]) .pipe(eslint()) .pipe(eslint.format()) .pipe(eslint.failAfterError()); -}); \ No newline at end of file +}); diff --git a/gulp/tasks/test.js b/gulp/tasks/test.js index 8436ddd..22c28fe 100644 --- a/gulp/tasks/test.js +++ b/gulp/tasks/test.js @@ -22,7 +22,7 @@ gulp.task('test', () => { files = ['tests/helper.js', singleFile]; } else { // Default to all test files - files = [config.testFiles]; + files = [config.scripts.test]; } // Ensure that all window/DOM related properties From 836904727653789e169972645da1fe9b03780664 Mon Sep 17 00:00:00 2001 From: Jake Marsh Date: Wed, 11 May 2016 22:31:45 -0700 Subject: [PATCH 4/4] fix new linter violations --- app/js/App.js | 2 +- app/js/actions/CurrentUserActions.js | 2 +- app/js/components/Footer.js | 2 +- app/js/components/Header.js | 2 +- app/js/index.js | 2 +- app/js/pages/HomePage.js | 2 +- app/js/pages/NotFoundPage.js | 2 +- app/js/pages/SearchPage.js | 2 +- app/js/utils/AuthAPI.js | 2 +- gulp/index.js | 11 ++++++----- gulp/tasks/browserSync.js | 4 ++-- gulp/tasks/browserify.js | 4 ++-- gulp/tasks/clean.js | 2 +- gulp/tasks/copyIcons.js | 1 - gulp/tasks/copyIndex.js | 2 +- gulp/tasks/deploy.js | 3 +-- gulp/tasks/development.js | 3 +-- gulp/tasks/imagemin.js | 3 +-- gulp/tasks/production.js | 2 +- gulp/tasks/watch.js | 8 ++++---- gulp/util/handle-errors.js | 8 ++++---- gulp/util/script-filter.js | 6 +++--- tests/helper.js | 2 +- 23 files changed, 37 insertions(+), 40 deletions(-) diff --git a/app/js/App.js b/app/js/App.js index df6df5f..021291c 100644 --- a/app/js/App.js +++ b/app/js/App.js @@ -75,4 +75,4 @@ class App extends React.Component { App.propTypes = propTypes; -export default App; \ No newline at end of file +export default App; diff --git a/app/js/actions/CurrentUserActions.js b/app/js/actions/CurrentUserActions.js index 003d77c..88d1259 100644 --- a/app/js/actions/CurrentUserActions.js +++ b/app/js/actions/CurrentUserActions.js @@ -10,4 +10,4 @@ const CurrentUserActions = Reflux.createActions([ ]); -export default CurrentUserActions; \ No newline at end of file +export default CurrentUserActions; diff --git a/app/js/components/Footer.js b/app/js/components/Footer.js index 3adc488..07a319e 100644 --- a/app/js/components/Footer.js +++ b/app/js/components/Footer.js @@ -20,4 +20,4 @@ class Footer extends React.Component{ } -export default Footer; \ No newline at end of file +export default Footer; diff --git a/app/js/components/Header.js b/app/js/components/Header.js index b5d839f..3b8057d 100644 --- a/app/js/components/Header.js +++ b/app/js/components/Header.js @@ -20,4 +20,4 @@ class Header extends React.Component { } -export default Header; \ No newline at end of file +export default Header; diff --git a/app/js/index.js b/app/js/index.js index 3d8dc70..2f7a057 100644 --- a/app/js/index.js +++ b/app/js/index.js @@ -10,4 +10,4 @@ if ( process.env.NODE_ENV !== 'production' ) { window.React = React; } -ReactDOM.render(Routes, document.getElementById('app')); \ No newline at end of file +ReactDOM.render(Routes, document.getElementById('app')); diff --git a/app/js/pages/HomePage.js b/app/js/pages/HomePage.js index a8c0d63..c0a7636 100644 --- a/app/js/pages/HomePage.js +++ b/app/js/pages/HomePage.js @@ -36,4 +36,4 @@ class HomePage extends React.Component { HomePage.propTypes = propTypes; -export default HomePage; \ No newline at end of file +export default HomePage; diff --git a/app/js/pages/NotFoundPage.js b/app/js/pages/NotFoundPage.js index 8399382..12d51f8 100644 --- a/app/js/pages/NotFoundPage.js +++ b/app/js/pages/NotFoundPage.js @@ -29,4 +29,4 @@ class NotFoundPage extends React.Component { NotFoundPage.propTypes = propTypes; -export default NotFoundPage; \ No newline at end of file +export default NotFoundPage; diff --git a/app/js/pages/SearchPage.js b/app/js/pages/SearchPage.js index 8cac077..34c22c1 100644 --- a/app/js/pages/SearchPage.js +++ b/app/js/pages/SearchPage.js @@ -52,4 +52,4 @@ class SearchPage extends React.Component { SearchPage.propTypes = propTypes; -export default SearchPage; \ No newline at end of file +export default SearchPage; diff --git a/app/js/utils/AuthAPI.js b/app/js/utils/AuthAPI.js index b1d9a1c..c7ee21e 100644 --- a/app/js/utils/AuthAPI.js +++ b/app/js/utils/AuthAPI.js @@ -18,4 +18,4 @@ const AuthAPI = { }; -export default AuthAPI; \ No newline at end of file +export default AuthAPI; diff --git a/gulp/index.js b/gulp/index.js index 6039b89..4be0b19 100644 --- a/gulp/index.js +++ b/gulp/index.js @@ -1,9 +1,10 @@ 'use strict'; -var fs = require('fs'); -var onlyScripts = require('./util/script-filter'); -var tasks = fs.readdirSync('./gulp/tasks/').filter(onlyScripts); +import fs from 'fs'; +import onlyScripts from './util/script-filter'; -tasks.forEach(function(task) { +const TASKS = fs.readdirSync('./gulp/tasks/').filter(onlyScripts); + +TASKS.forEach(function(task) { require('./tasks/' + task); -}); \ No newline at end of file +}); diff --git a/gulp/tasks/browserSync.js b/gulp/tasks/browserSync.js index 9cebe37..b566d3c 100644 --- a/gulp/tasks/browserSync.js +++ b/gulp/tasks/browserSync.js @@ -14,7 +14,7 @@ gulp.task('browserSync', function() { server: { baseDir: config.buildDir, middleware: function(req, res, next) { - let fileHref = url.parse(req.url).href; + const fileHref = url.parse(req.url).href; if ( !ASSET_EXTENSION_REGEX.test(fileHref)) { req.url = '/' + DEFAULT_FILE; @@ -32,4 +32,4 @@ gulp.task('browserSync', function() { } }); -}); \ No newline at end of file +}); diff --git a/gulp/tasks/browserify.js b/gulp/tasks/browserify.js index 45f31de..7d2a247 100644 --- a/gulp/tasks/browserify.js +++ b/gulp/tasks/browserify.js @@ -19,7 +19,7 @@ import config from '../config'; // Based on: http://blog.avisi.nl/2014/04/25/how-to-keep-a-fast-build-with-browserify-and-reactjs/ function buildScript(file, watch) { - var bundler = browserify({ + let bundler = browserify({ entries: [config.sourceDir + 'js/' + file], debug: !global.isProd, cache: {}, @@ -36,7 +36,7 @@ function buildScript(file, watch) { bundler.transform(debowerify); function rebundle() { - let stream = bundler.bundle(); + const stream = bundler.bundle(); gutil.log('Rebundle...'); diff --git a/gulp/tasks/clean.js b/gulp/tasks/clean.js index 6df5528..bcd171e 100644 --- a/gulp/tasks/clean.js +++ b/gulp/tasks/clean.js @@ -8,4 +8,4 @@ gulp.task('clean', function() { return del([config.buildDir]); -}); \ No newline at end of file +}); diff --git a/gulp/tasks/copyIcons.js b/gulp/tasks/copyIcons.js index 2af6f8f..b771593 100644 --- a/gulp/tasks/copyIcons.js +++ b/gulp/tasks/copyIcons.js @@ -5,7 +5,6 @@ import config from '../config'; gulp.task('copyIcons', function() { - // Copy icons from root directory to build/ return gulp.src(['./*.png', './favicon.ico']) .pipe(gulp.dest(config.buildDir)); diff --git a/gulp/tasks/copyIndex.js b/gulp/tasks/copyIndex.js index 03de0c8..45fbe60 100644 --- a/gulp/tasks/copyIndex.js +++ b/gulp/tasks/copyIndex.js @@ -7,4 +7,4 @@ gulp.task('copyIndex', function() { gulp.src(config.sourceDir + 'index.html').pipe(gulp.dest(config.buildDir)); -}); \ No newline at end of file +}); diff --git a/gulp/tasks/deploy.js b/gulp/tasks/deploy.js index 8bf693f..a39b0e6 100644 --- a/gulp/tasks/deploy.js +++ b/gulp/tasks/deploy.js @@ -1,10 +1,9 @@ 'use strict'; import gulp from 'gulp'; -//import config from '../config'; gulp.task('deploy', ['prod'], function() { // Deploy to hosting environment -}); \ No newline at end of file +}); diff --git a/gulp/tasks/development.js b/gulp/tasks/development.js index 955d25c..b761fe3 100644 --- a/gulp/tasks/development.js +++ b/gulp/tasks/development.js @@ -9,7 +9,6 @@ gulp.task('dev', ['clean'], function(cb) { global.isProd = false; - // Run all tasks once return runSequence(['sass', 'imagemin', 'browserify', 'copyFonts', 'copyIndex', 'copyIcons'], 'watch', cb); -}); \ No newline at end of file +}); diff --git a/gulp/tasks/imagemin.js b/gulp/tasks/imagemin.js index 164b91f..48c9bf8 100644 --- a/gulp/tasks/imagemin.js +++ b/gulp/tasks/imagemin.js @@ -8,10 +8,9 @@ import config from '../config'; gulp.task('imagemin', function() { - // Run imagemin task on all images return gulp.src(config.images.src) .pipe(gulpif(global.isProd, imagemin())) .pipe(gulp.dest(config.images.dest)) .pipe(gulpif(browserSync.active, browserSync.reload({ stream: true, once: true }))); -}); \ No newline at end of file +}); diff --git a/gulp/tasks/production.js b/gulp/tasks/production.js index 3e86401..89c2f53 100644 --- a/gulp/tasks/production.js +++ b/gulp/tasks/production.js @@ -11,4 +11,4 @@ gulp.task('prod', ['clean'], function(cb) { runSequence(['sass', 'imagemin', 'browserify', 'copyFonts', 'copyIndex', 'copyIcons'], cb); -}); \ No newline at end of file +}); diff --git a/gulp/tasks/watch.js b/gulp/tasks/watch.js index c9b65bc..f142f2f 100644 --- a/gulp/tasks/watch.js +++ b/gulp/tasks/watch.js @@ -6,8 +6,8 @@ import config from '../config'; gulp.task('watch', ['browserSync'], function() { // Scripts are automatically watched by Watchify inside Browserify task - gulp.watch(config.styles.src, ['sass']); - gulp.watch(config.images.src, ['imagemin']); - gulp.watch(config.sourceDir + 'index.html', ['copyIndex']); + gulp.watch(config.styles.src, ['sass']); + gulp.watch(config.images.src, ['imagemin']); + gulp.watch(config.sourceDir + 'index.html', ['copyIndex']); -}); \ No newline at end of file +}); diff --git a/gulp/util/handle-errors.js b/gulp/util/handle-errors.js index 3cf398a..ca5a24f 100644 --- a/gulp/util/handle-errors.js +++ b/gulp/util/handle-errors.js @@ -1,12 +1,12 @@ 'use strict'; -var notify = require('gulp-notify'); +import notify from 'gulp-notify'; -module.exports = function(error) { +export default function(error) { if( !global.isProd ) { - var args = Array.prototype.slice.call(arguments); + const args = Array.prototype.slice.call(arguments); // Send error to notification center with gulp-notify notify.onError({ @@ -24,4 +24,4 @@ module.exports = function(error) { process.exit(1); } -}; \ No newline at end of file +}; diff --git a/gulp/util/script-filter.js b/gulp/util/script-filter.js index 3157bf6..3f86791 100644 --- a/gulp/util/script-filter.js +++ b/gulp/util/script-filter.js @@ -1,9 +1,9 @@ 'use strict'; -var path = require('path'); +import path from 'path'; // Filters out non .coffee and .js files. Prevents // accidental inclusion of possible hidden files -module.exports = function(name) { +export default function(name) { return /(\.(js|coffee)$)/i.test(path.extname(name)); -}; \ No newline at end of file +}; diff --git a/tests/helper.js b/tests/helper.js index d7a2096..a3b729a 100644 --- a/tests/helper.js +++ b/tests/helper.js @@ -6,4 +6,4 @@ beforeEach(function() { afterEach(function() { global.sandbox.restore(); -}); \ No newline at end of file +});