From 3c5a726614ca698841eec69579022da3c46c9b82 Mon Sep 17 00:00:00 2001 From: Florian Mettetal Date: Mon, 24 Apr 2017 07:31:35 -0700 Subject: [PATCH] PX CONFIG eslint --- .eslintrc | 106 ++++++++++++++++----------- package.json | 14 +++- scripts/build-client.js | 12 +-- scripts/build-docker.js | 2 +- scripts/build-meteor.js | 6 +- scripts/build-server.js | 12 +-- scripts/build.js | 2 +- scripts/debug-brk.js | 2 +- scripts/debug.js | 2 +- scripts/devServer.js | 8 +- scripts/docker.js | 6 +- scripts/installMeteorDeps.js | 4 +- scripts/prod-debug-brk.js | 2 +- scripts/prod-debug.js | 2 +- scripts/prod.js | 26 +++---- scripts/start.js | 6 +- src/client/Root.js | 2 +- src/client/index.js | 4 +- src/client/makeStore.js | 6 +- src/index.js | 6 +- src/server/Html.js | 15 ++-- src/server/createSSR.js | 37 +++++----- src/server/index.js | 2 +- src/universal/collections/Counts.js | 2 +- src/universal/components/App.js | 16 ++-- src/universal/flowtypes/redux.js | 2 +- src/universal/redux/makeReducer.js | 2 +- src/universal/routes/home.js | 6 +- src/universal/routes/index.js | 4 +- test/integration/integrationTests.js | 80 ++++++++++---------- wdio.conf.js | 30 ++++---- webpack/webpack.config.dev.js | 90 +++++++++++------------ webpack/webpack.config.prod.js | 84 ++++++++++----------- webpack/webpack.config.server.js | 78 ++++++++++---------- 34 files changed, 354 insertions(+), 324 deletions(-) diff --git a/.eslintrc b/.eslintrc index 6118b1f..d026d03 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,66 +1,86 @@ { "parser": "babel-eslint", - "plugins": [ - "react", "babel", "flowtype" - ], "parserOptions": { + "sourceType": "module", + "allowImportExportEverywhere": false, "ecmaFeatures": { "jsx": true } }, + "plugins": [ + "babel", "compat", "flowtype", "react", "import" + ], + "import/resolver": { + "babel-module": {} + }, + "import/core-modules": ["meteor/"], "extends": ["eslint:recommended", "plugin:react/recommended"], "env": { "commonjs": true, "es6": true, - "node": true + "node": true, + "mongo": true + }, + "globals": { + "window": true, + "document": true }, "rules": { - "no-extra-semi": "error", - "semi": ["error", "never"], - "flowtype/boolean-style": [ - 2, - "boolean" - ], + "brace-style": [2, "1tbs", { "allowSingleLine": true }], + "class-methods-use-this": 0, + "comma-dangle": [2, "never"], + "compat/compat": 2, + "curly": [2, "all"], + "flowtype/boolean-style": [2, "boolean"], "flowtype/define-flow-type": 1, - "flowtype/generic-spacing": [ - 2, - "never" - ], + "flowtype/generic-spacing": [2, "never"], "flowtype/require-parameter-type": 2, - "flowtype/require-return-type": [ - 2, - "always", - { - "annotateUndefined": "never" - } - ], + "flowtype/require-return-type": [2, "always", { "annotateUndefined": "never" }], "flowtype/require-valid-file-annotation": 2, - "flowtype/semi": [ - 2, - "never" - ], - "flowtype/space-after-type-colon": [ - 2, - "always" - ], - "flowtype/space-before-generic-bracket": [ - 2, - "never" - ], - "flowtype/space-before-type-colon": [ - 2, - "never" - ], - "flowtype/union-intersection-spacing": [ - 2, - "always" - ], + "flowtype/semi": [2, "never"], + "flowtype/space-after-type-colon": [2, "always"], + "flowtype/space-before-generic-bracket": [2, "never"], + "flowtype/space-before-type-colon": [2, "never"], + "flowtype/union-intersection-spacing": [2, "always"], "flowtype/use-flow-type": 1, - "flowtype/valid-syntax": 1 + "flowtype/valid-syntax": 1, + "func-names": 0, + "import/extensions": [0, "always", { "js": "never", "jsx": "never" }], + "import/first": 0, + "import/no-extraneous-dependencies": 0, + "import/no-unresolved": [0, { "ignore": ["^meteor/"] }], + "import/prefer-default-export": 1, + "indent": [2, 2, { "SwitchCase": 1 }], + "key-spacing": [2, { "align": "colon" }], + "keyword-spacing": 0, + "linebreak-style": 1, + "max-len": [1, 120], + "no-case-declarations": 0, + "no-cond-assign": 2, + "no-console": [1, { "allow": ["warn", "error"] }], + "no-extra-semi": "error", + "no-param-reassign": 2, + "no-underscore-dangle": 0, + "no-unused-expressions": [2, { "allowShortCircuit": true }], + "no-unused-vars": [2, { "args": "all", "varsIgnorePattern": "[mM]eteor" }], + "no-use-before-define": [2, { "functions": false, "classes": true }], + "padding-blocks": 0, + "prefer-arrow-callback": 1, + "prefer-destructuring": [2, { "array": false, "object": true }, { "enforceForRenamedProperties": false }], + "prefer-spread": 2, + "react/jsx-filename-extension": 0, + "react/no-danger": 1, + "react/no-find-dom-node": 1, + "react/no-string-refs": 2, + "react/no-unused-prop-types": 1, + "react/prop-types": 1, + "react/sort-comp": 1, + "semi": ["error", "never"], + "space-before-function-paren": 1 }, "settings": { "flowtype": { "onlyFilesWithFlowAnnotation": false } } -} \ No newline at end of file +} diff --git a/package.json b/package.json index 04a210c..4848f67 100644 --- a/package.json +++ b/package.json @@ -13,11 +13,12 @@ "url": "https://github.com:Falieson/planetx-boilerplate-crater/issues" }, "keywords": [ - "meteor", - "babel", - "webpack", "react", - "crater" + "webpack2", + "meteor", + "planetx", + "crater", + "babel" ], "main": "index.js", "nyc": { @@ -115,8 +116,13 @@ "empty": "^0.10.1", "es6-promise": "^4.1.0", "eslint": "^3.19.0", + "eslint-config-airbnb": "^14.1.0", + "eslint-import-resolver-babel-module": "^3.0.0", "eslint-plugin-babel": "^4.1.1", + "eslint-plugin-compat": "^1.0.2", "eslint-plugin-flowtype": "^2.32.1", + "eslint-plugin-import": "^2.2.0", + "eslint-plugin-jsx-a11y": "^4.0.0", "eslint-plugin-react": "^6.10.3", "eslint-watch": "^3.1.0", "extract-text-webpack-plugin": "^2.1.0", diff --git a/scripts/build-client.js b/scripts/build-client.js index 5fdb52a..08905c0 100755 --- a/scripts/build-client.js +++ b/scripts/build-client.js @@ -12,20 +12,20 @@ import buildDir from '../buildDir' const root = path.resolve(__dirname, '..') const assets = path.join(buildDir, 'assets.json') -async function buildClient(): Promise { +async function buildClient (): Promise { if (await isNewerThan(path.join(root, 'webpack', 'webpack.config.prod.js'), assets) || await isNewerThan(path.join(root, 'src'), assets)) { console.log('building client bundle...') const compiler = webpack(webpackConfig) const stats = await promisify(compiler.run, compiler)() process.stdout.write(stats.toString({ - colors: true, - modules: false, + colors : true, + modules : false, chunkModules: false, - chunks: true, - errorDetails: true, + chunks : true, + errorDetails: true }) + "\n") - if (stats.toJson().errors.length) throw new Error("webpack build had errors") + if (stats.toJson().errors.length) {throw new Error("webpack build had errors")} } else { console.log('client assets are up to date') } diff --git a/scripts/build-docker.js b/scripts/build-docker.js index ba8e133..d722932 100755 --- a/scripts/build-docker.js +++ b/scripts/build-docker.js @@ -13,7 +13,7 @@ const root = path.resolve(__dirname, '..') process.on('SIGINT', (): any => process.exit(1)) const opts = { - cwd: root, + cwd : root, stdio: 'inherit' } diff --git a/scripts/build-meteor.js b/scripts/build-meteor.js index 6e6c319..5806c48 100755 --- a/scripts/build-meteor.js +++ b/scripts/build-meteor.js @@ -14,19 +14,19 @@ import buildDir from '../buildDir' const root = path.resolve(__dirname, '..') const meteor = path.join(root, 'meteor') -async function buildMeteor(): Promise { +async function buildMeteor (): Promise { await promisify(mkdirp)(buildDir) if (await isNewerThan([ ...await promisify(glob)(path.join(meteor, '**')), path.join(meteor, '.meteor', 'packages'), path.join(meteor, '.meteor', 'platforms'), path.join(meteor, '.meteor', 'release'), - path.join(meteor, '.meteor', 'versions'), + path.join(meteor, '.meteor', 'versions') ], path.join(buildDir, 'meteor'))) { console.log('building Meteor packages...') await promisify(rimraf)(path.join(buildDir, 'meteor')) await spawnAsync('meteor', ['build', path.join(path.relative(meteor, buildDir), 'meteor'), '--directory'], { - cwd: meteor, + cwd : meteor, stdio: 'inherit' }) } else { diff --git a/scripts/build-server.js b/scripts/build-server.js index 7762067..818af88 100755 --- a/scripts/build-server.js +++ b/scripts/build-server.js @@ -16,7 +16,7 @@ const prerender = path.join(buildDir, 'prerender.js') const opts = {cwd: root, stdio: 'inherit'} -async function buildServer(): Promise { +async function buildServer (): Promise { await promisify(mkdirp)(buildDir) await spawnAsync('babel', [path.join(root, 'src', 'index.js'), '-o', path.join(buildDir, 'index.js')], opts) if (await isNewerThan(path.join(root, 'webpack', 'webpack.config.server.js'), prerender) || @@ -25,13 +25,13 @@ async function buildServer(): Promise { const compiler = webpack(webpackConfig) const stats = await promisify(compiler.run, compiler)() process.stdout.write(stats.toString({ - colors: true, - modules: false, + colors : true, + modules : false, chunkModules: false, - chunks: true, - errorDetails: true, + chunks : true, + errorDetails: true }) + "\n") - if (stats.toJson().errors.length) throw new Error("webpack build had errors") + if (stats.toJson().errors.length) {throw new Error("webpack build had errors")} } else { console.log('server assets are up to date') } diff --git a/scripts/build.js b/scripts/build.js index 7189ac6..12e21c6 100755 --- a/scripts/build.js +++ b/scripts/build.js @@ -6,7 +6,7 @@ import buildMeteor from './build-meteor' import buildServer from './build-server' import buildClient from './build-client' -async function build(): Promise { +async function build (): Promise { await buildMeteor() await Promise.all([buildClient(), buildServer()]) } diff --git a/scripts/debug-brk.js b/scripts/debug-brk.js index 4894199..65cd293 100755 --- a/scripts/debug-brk.js +++ b/scripts/debug-brk.js @@ -8,6 +8,6 @@ import path from 'path' process.on('SIGINT', (): any => process.exit(1)) start({ - commandOptions: ['--debug-brk'], + commandOptions: ['--debug-brk'] }) spawn('node-inspector', [], {cwd: path.resolve(__dirname, '..'), stdio: 'inherit'}) diff --git a/scripts/debug.js b/scripts/debug.js index eab7e83..64570c9 100755 --- a/scripts/debug.js +++ b/scripts/debug.js @@ -8,6 +8,6 @@ import path from 'path' process.on('SIGINT', (): any => process.exit(1)) start({ - commandOptions: ['--debug'], + commandOptions: ['--debug'] }) spawn('node-inspector', [], {cwd: path.resolve(__dirname, '..'), stdio: 'inherit'}) diff --git a/scripts/devServer.js b/scripts/devServer.js index acc751e..91b0087 100644 --- a/scripts/devServer.js +++ b/scripts/devServer.js @@ -6,10 +6,10 @@ import createDebug from 'debug' const shutdownDebug = createDebug('crater:shutdown') -if (process.env.USE_DOTENV) require('dotenv').config() +if (process.env.USE_DOTENV) {require('dotenv').config()} const {PORT, ROOT_URL} = process.env -if (PORT == null) throw new Error("Missing process.env.PORT") -if (ROOT_URL) process.env.ROOT_URL = ROOT_URL.replace(`:${PORT}`, `:${webpackConfig.devServer.port}`) +if (PORT == null) {throw new Error("Missing process.env.PORT")} +if (ROOT_URL) {process.env.ROOT_URL = ROOT_URL.replace(`:${PORT}`, `:${webpackConfig.devServer.port}`)} const app = express() @@ -30,7 +30,7 @@ server.on('upgrade', (req: Object, socket: any, head: any): any => proxy.ws(req, console.log(`Dev server is listening on http://0.0.0.0:${webpackConfig.devServer.port}`) -function shutdown() { +function shutdown () { shutdownDebug('got signal, shutting down') server.close() process.exit(0) diff --git a/scripts/docker.js b/scripts/docker.js index 3af0483..0826201 100755 --- a/scripts/docker.js +++ b/scripts/docker.js @@ -17,9 +17,9 @@ asyncScript(async (): Promise => { ...process.env, NAME, ROOT_URL: 'http://localhost:3000', - TAG: commitHash, + TAG : commitHash }, - cwd: root, - stdio: 'inherit', + cwd : root, + stdio: 'inherit' }) }) diff --git a/scripts/installMeteorDeps.js b/scripts/installMeteorDeps.js index e3fa254..0777e16 100644 --- a/scripts/installMeteorDeps.js +++ b/scripts/installMeteorDeps.js @@ -8,11 +8,11 @@ import buildDir from '../buildDir' const programsServer = path.join(buildDir, 'meteor', 'bundle', 'programs', 'server') -async function installMeteorDeps(): Promise { +async function installMeteorDeps (): Promise { if (!(await isDirectory(path.join(programsServer, 'node_modules')))) { console.log('installing Meteor npm dependencies...') await spawnAsync('npm', ['install'], { - cwd: programsServer, + cwd : programsServer, stdio: 'inherit' }) } else { diff --git a/scripts/prod-debug-brk.js b/scripts/prod-debug-brk.js index 21ad283..92a121f 100755 --- a/scripts/prod-debug-brk.js +++ b/scripts/prod-debug-brk.js @@ -8,6 +8,6 @@ import path from 'path' process.on('SIGINT', (): any => process.exit(1)) prod({ - commandOptions: ['--debug'], + commandOptions: ['--debug'] }) spawn('node-inspector', [], {cwd: path.resolve(__dirname, '..'), stdio: 'inherit'}) diff --git a/scripts/prod-debug.js b/scripts/prod-debug.js index 21ad283..92a121f 100755 --- a/scripts/prod-debug.js +++ b/scripts/prod-debug.js @@ -8,6 +8,6 @@ import path from 'path' process.on('SIGINT', (): any => process.exit(1)) prod({ - commandOptions: ['--debug'], + commandOptions: ['--debug'] }) spawn('node-inspector', [], {cwd: path.resolve(__dirname, '..'), stdio: 'inherit'}) diff --git a/scripts/prod.js b/scripts/prod.js index ae69ba3..5422453 100644 --- a/scripts/prod.js +++ b/scripts/prod.js @@ -17,18 +17,18 @@ const root = path.resolve(__dirname, '..') process.env.NODE_ENV = 'production' process.env.USE_DOTENV = '1' -async function prod(options?: {commandOptions?: Array} = {}): Promise { +async function prod (options?: {commandOptions?: Array} = {}): Promise { await buildMeteor() await installMeteorDeps() await spawnAsync('babel', [path.join(root, 'src', 'index.js'), '-o', path.join(buildDir, 'index.js')], { - cwd: root, - stdio: 'inherit', + cwd : root, + stdio: 'inherit' }) - function launchWebpack(config: Object): Promise { + function launchWebpack (config: Object): Promise { return new Promise((_resolve: Function) => { let resolved = false - function resolve() { + function resolve () { if (!resolved) { resolved = true _resolve() @@ -41,13 +41,13 @@ async function prod(options?: {commandOptions?: Array} = {}): Promise} = {}): Promise process.exit(0)) process.on('SIGTERM', (): any => process.exit(0)) asyncScript(prod, { - exitOnSuccess: false, + exitOnSuccess: false }) } diff --git a/scripts/start.js b/scripts/start.js index c02b80a..10bfaa9 100644 --- a/scripts/start.js +++ b/scripts/start.js @@ -13,7 +13,7 @@ process.env.USE_DOTENV = '1' const root = path.resolve(__dirname, '..') const src = path.join(root, 'src') -async function start(options?: {commandOptions?: Array} = {}): Promise { +async function start (options?: {commandOptions?: Array} = {}): Promise { if (process.argv.indexOf('--fast') < 0) { await buildMeteor() await installMeteorDeps() @@ -21,7 +21,7 @@ async function start(options?: {commandOptions?: Array} = {}): Promise require('./devServer') launch({ commandOptions: options.commandOptions || [], - main: path.join(src, 'index.js'), + main : path.join(src, 'index.js') }) } @@ -31,7 +31,7 @@ if (!module.parent) { process.on('SIGINT', (): any => process.exit(0)) process.on('SIGTERM', (): any => process.exit(0)) asyncScript(start, { - exitOnSuccess: false, + exitOnSuccess: false }) } diff --git a/src/client/Root.js b/src/client/Root.js index 962bfce..fb4dde5 100644 --- a/src/client/Root.js +++ b/src/client/Root.js @@ -16,7 +16,7 @@ export default class Root extends Component { store: PropTypes.object.isRequired } - render(): React.Element { + render (): React.Element { const {store} = this.props const history = syncHistoryWithStore(browserHistory, store, { selectLocationState: (state: State): Object => state.get('router') diff --git a/src/client/index.js b/src/client/index.js index cab4e67..7fb83ae 100644 --- a/src/client/index.js +++ b/src/client/index.js @@ -7,14 +7,14 @@ import { Map as iMap } from 'immutable' import makeStore from './makeStore' import Root from './Root' -if (process.env.NODE_ENV !== 'production') require('es6-promise').polyfill() +if (process.env.NODE_ENV !== 'production') {require('es6-promise').polyfill()} Meteor.startup(() => { const { router } = window.__INITIAL_STATE__ // routing is currently a regualr JS object. This may change in the future const initialState = iMap({ - router, + router }) const store = makeStore(initialState) diff --git a/src/client/makeStore.js b/src/client/makeStore.js index e45354a..04ec860 100644 --- a/src/client/makeStore.js +++ b/src/client/makeStore.js @@ -12,7 +12,7 @@ export default (initialState: iMap): Store => { const reducer = makeReducer() const reduxRouterMiddleware = routerMiddleware(browserHistory) const middlewares = [ - reduxRouterMiddleware, + reduxRouterMiddleware ] if (process.env.NODE_ENV === 'production') { @@ -23,8 +23,8 @@ export default (initialState: iMap): Store => { // We don't have the Redux extension in the browser, show the Redux logger const createLogger = require('redux-logger') const logger = createLogger({ - level: 'info', - collapsed: true, + level : 'info', + collapsed: true }) middlewares.push(logger) } diff --git a/src/index.js b/src/index.js index c4a6c50..db2d85a 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,6 @@ global.__CLIENT__ = false -if (process.env.USE_DOTENV) require('dotenv').config() +if (process.env.USE_DOTENV) {require('dotenv').config()} global.__PRODUCTION__ = process.env.NODE_ENV === 'production' @@ -13,14 +13,14 @@ const cwd = process.cwd() // I'm not super happy about this, but Meteor's boot.js seems to require being run from the directory it's in const serverDir = path.join(buildDir, 'meteor', 'bundle', 'programs', 'server') process.chdir(serverDir) -const argv = process.argv +const {argv} = process process.argv = argv.slice(0, 2).concat('program.json') // .splice(2, 0, 'program.json') // Launch the usual Meteor server require(path.join(serverDir, 'boot.js')) process.argv = argv process.chdir(cwd) -if (process.env.NODE_ENV !== 'production') require('babel-register') +if (process.env.NODE_ENV !== 'production') {require('babel-register')} // eslint-disable-next-line no-undef Package.meteor.Meteor.startup(() => { diff --git a/src/server/Html.js b/src/server/Html.js index 901f2fb..d442365 100644 --- a/src/server/Html.js +++ b/src/server/Html.js @@ -1,5 +1,6 @@ /* @flow */ /* eslint react/no-danger:0 */ +/* eslint react/no-unused-prop-types:0 */ import React, {Component, PropTypes} from 'react' import {Provider} from 'react-redux' import {RouterContext} from 'react-router' @@ -9,15 +10,15 @@ import {renderToString} from 'react-dom-stream/server' export default class Html extends Component { static propTypes = { __meteor_runtime_config__: PropTypes.object.isRequired, - store: PropTypes.object.isRequired, - title: PropTypes.string.isRequired, - assets: PropTypes.object, - env: PropTypes.object, - settings: PropTypes.object, - renderProps: PropTypes.object, + store : PropTypes.object.isRequired, + title : PropTypes.string.isRequired, + assets : PropTypes.object, + env : PropTypes.object, + settings : PropTypes.object, + renderProps : PropTypes.object } - render(): React.Element { + render (): React.Element { const PROD = process.env.NODE_ENV === 'production' const {title, __meteor_runtime_config__, store, assets, renderProps} = this.props const {manifest, app, vendor, meteor} = assets || {} diff --git a/src/server/createSSR.js b/src/server/createSSR.js index d494c17..3521b11 100644 --- a/src/server/createSSR.js +++ b/src/server/createSSR.js @@ -16,18 +16,18 @@ import type {IncomingMessage, ServerResponse} from 'http' import type {Store} from '../universal/flowtypes/redux' const __meteor_runtime_config__ = { - PUBLIC_SETTINGS: Meteor.settings.public || {}, - ROOT_URL: process.env.ROOT_URL, + PUBLIC_SETTINGS : Meteor.settings.public || {}, + ROOT_URL : process.env.ROOT_URL, // Not everything is in place to support basename right now (e.g. react-router history config, webpack config) // but might as well go ahead and use the correct value here anyway ROOT_URL_PATH_PREFIX: url.parse(process.env.ROOT_URL).pathname.substring(1), - meteorEnv: { - NODE_ENV: process.env.NODE_ENV, + meteorEnv : { + NODE_ENV: process.env.NODE_ENV }, - meteorRelease: Meteor.release, + meteorRelease: Meteor.release } -function renderApp(res: ServerResponse, store: Store, assets?: Object, renderProps?: Object) { +function renderApp (res: ServerResponse, store: Store, assets?: Object, renderProps?: Object) { const location = renderProps && renderProps.location && renderProps.location.pathname || '/' // Needed so some components can render based on location store.dispatch(push(location)) @@ -45,7 +45,7 @@ function renderApp(res: ServerResponse, store: Store, assets?: Object, renderPro htmlStream.on('end', (): void => res.end()) } -async function createSSR(req: IncomingMessage, res: ServerResponse): Promise { +async function createSSR (req: IncomingMessage, res: ServerResponse): Promise { try { const store = createStore(makeReducer(), iMap()) if (process.env.NODE_ENV === 'production') { @@ -58,17 +58,18 @@ async function createSSR(req: IncomingMessage, res: ServerResponse): Promise { - if (error) { - res.status(500).send(error.message) - } else if (redirectLocation) { - res.redirect(redirectLocation.pathname + redirectLocation.search) - } else if (renderProps) { - renderApp(res, store, assets, renderProps) - } else { - res.status(404).send('Not found') - } - }) + match({routes, location: req.url}, + (error: ?Error, redirectLocation: {pathname: string, search: string}, renderProps: ?Object) => { + if (error) { + res.status(500).send(error.message) + } else if (redirectLocation) { + res.redirect(redirectLocation.pathname + redirectLocation.search) + } else if (renderProps) { + renderApp(res, store, assets, renderProps) + } else { + res.status(404).send('Not found') + } + }) } else { // just send a cheap html doc + stringified store renderApp(res, store) diff --git a/src/server/index.js b/src/server/index.js index 56f33c0..a4fb207 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -44,7 +44,7 @@ WebApp.onListening(() => { console.log(`App is listening on http://0.0.0.0:${process.env.PORT || '80'}`) // eslint-disable-line no-console }) -function shutdown() { +function shutdown () { shutdownDebug('got signal, shutting down') WebApp.httpServer.close() process.exit(0) diff --git a/src/universal/collections/Counts.js b/src/universal/collections/Counts.js index 45535c9..fab6f5c 100644 --- a/src/universal/collections/Counts.js +++ b/src/universal/collections/Counts.js @@ -9,7 +9,7 @@ export default Counts if (Meteor.isServer) { Meteor.publish({ - counts(_id: string): Mongo.Cursor { + counts (_id: string): Mongo.Cursor { Counts.upsert({_id}, {$set: {value: 0}}) this.ready() const interval = Meteor.setInterval(() => { diff --git a/src/universal/components/App.js b/src/universal/components/App.js index 6930ef4..37e6489 100644 --- a/src/universal/components/App.js +++ b/src/universal/components/App.js @@ -8,25 +8,25 @@ import styles from './App.css' export default class App extends Component { state = {value: 0}; - observer: ?{stop: Function}; + observer: ?{stop: Function}; //eslint-disable-line react/sort-comp sub: ?{stop: Function}; - componentWillMount() { + componentWillMount () { if (Meteor.isClient) { this.sub = Meteor.subscribe('counts', 'a') this.observer = Counts.find({_id: 'a'}).observeChanges({ - added: (id: string, fields: Object): any => this.setState(fields), - changed: (id: string, fields: Object): any => this.setState(fields), + added : (id: string, fields: Object): any => this.setState(fields), //eslint-disable-line no-unused-vars + changed: (id: string, fields: Object): any => this.setState(fields) //eslint-disable-line no-unused-vars }) } } - componentWillUnmount() { + componentWillUnmount () { if (Meteor.isClient) { - if (this.observer != null) this.observer.stop() - if (this.sub != null) this.sub.stop() + if (this.observer != null) {this.observer.stop()} + if (this.sub != null) {this.sub.stop()} } } - render(): React.Element { + render (): React.Element { return (

Welcome to Crater!

diff --git a/src/universal/flowtypes/redux.js b/src/universal/flowtypes/redux.js index 4ee86a8..5bd0a5a 100644 --- a/src/universal/flowtypes/redux.js +++ b/src/universal/flowtypes/redux.js @@ -2,7 +2,7 @@ import {Map as iMap} from 'immutable' import type { Store as _Store, Reducer as _Reducer, - Dispatch as _Dispatch, + Dispatch as _Dispatch } from 'redux' export type State = iMap diff --git a/src/universal/redux/makeReducer.js b/src/universal/redux/makeReducer.js index 46a5242..99ffa8e 100644 --- a/src/universal/redux/makeReducer.js +++ b/src/universal/redux/makeReducer.js @@ -5,7 +5,7 @@ import {routerReducer} from 'react-router-redux' import type {Reducer} from '../flowtypes/redux' const currentReducers: {[key: string]: Reducer} = { - router: routerReducer, + router: routerReducer } export default (newReducers?: {[key: string]: Reducer} = {}): Reducer => { diff --git a/src/universal/routes/home.js b/src/universal/routes/home.js index d49fcde..febd297 100644 --- a/src/universal/routes/home.js +++ b/src/universal/routes/home.js @@ -5,8 +5,8 @@ import type {Store} from '../flowtypes/redux' // eslint-disable-next-line no-unused-vars export default (store: Store): Object => ({ - path: '/', + path : '/', indexRoute: { - component: App, - }, + component: App + } }) diff --git a/src/universal/routes/index.js b/src/universal/routes/index.js index 046ab6e..eed946b 100644 --- a/src/universal/routes/index.js +++ b/src/universal/routes/index.js @@ -5,7 +5,7 @@ import type {Store} from '../flowtypes/redux' export default (store: Store): Object => { return { childRoutes: [ - require('./home').default(store), - ], + require('./home').default(store) + ] } } diff --git a/test/integration/integrationTests.js b/test/integration/integrationTests.js index bbb999f..934b823 100644 --- a/test/integration/integrationTests.js +++ b/test/integration/integrationTests.js @@ -1,3 +1,6 @@ +/* eslint max-len:0 */ +/* eslint no-unused-expressions:0 */ + import {expect, assert} from 'chai' import exec from 'crater-util/lib/exec' import {childPrinted} from 'async-child-process' @@ -21,22 +24,22 @@ const webpack = path.join(root, 'webpack') /* global browser: false */ -function delay(ms) { +function delay (ms) { return new Promise(resolve => setTimeout(resolve, ms)) } -function sharedTests() { - it('serves page with correct title', async function () { +function sharedTests () { + it('serves page with correct title', async () => { expect(await browser.getTitle()).to.equal('Crater') }) - it('serves page with correct header', async function () { + it('serves page with correct header', async () => { expect(await browser.getText('h1')).to.equal('Welcome to Crater!') }) - it('serves up client css', async function () { + it('serves up client css', async () => { const color = await browser.getCssProperty('h1', 'color') expect(color.parsed.hex).to.equal('#333333') }) - it('updates the counter', async function () { + it('updates the counter', async () => { const getCounter = async () => { const text = await browser.getText('.counter') const match = /(\d+)/.exec(text) @@ -47,20 +50,20 @@ function sharedTests() { await delay(2000) expect(await getCounter()).to.be.above(initCounter) }) - it('sends Meteor.settings.public to the client', async function () { + it('sends Meteor.settings.public to the client', async () => { expect(await browser.getText('.settings-test')).to.equal('success') }) } -function unlinkIfExists(path, callback) { +function unlinkIfExists (path, callback) { return fs.unlink(path, (err, result) => { - if (err && /ENOENT/.test(err.message)) err = null + if (err && /ENOENT/.test(err.message)) {err = null} //eslint-disable-line no-param-reassign return callback(err, result) }) } // istanbul ignore next -async function mergeClientCoverage() { +async function mergeClientCoverage () { if (process.env.BABEL_ENV === 'coverage') { const collector = new Collector() @@ -72,7 +75,7 @@ async function mergeClientCoverage() { } } -async function navigateTo(url) { +async function navigateTo (url) { if (process.env.DUMP_HTTP) { const popsicle = require('popsicle') const res = await popsicle.get(url) @@ -85,16 +88,16 @@ async function navigateTo(url) { await browser.url(url) } -async function logBrowserMessages() { +async function logBrowserMessages () { const logs = (await browser.log('browser')).value - if (!logs) return + if (!logs) {return} logs.forEach(({level, message, timestamp}) => { const time = new Date(timestamp).toLocaleTimeString() browserLogsDebug(`${time} ${level} ${message}`) }) } -describe('prod mode', function () { +describe('prod mode', () => { let server const appFile = path.join(src, 'universal', 'components', 'App.js') const serverFile = path.join(src, 'server', 'index.js') @@ -112,18 +115,18 @@ describe('prod mode', function () { after(async function () { this.timeout(600000) - if (server) await kill(server, 'SIGINT') + if (server) {await kill(server, 'SIGINT')} // restore code in App.js, which (may) have been changed by hot reloading test - if (appCode) await promisify(fs.writeFile)(appFile, appCode, 'utf8') - if (serverCode) await promisify(fs.writeFile)(serverFile, serverCode, 'utf8') - if (process.env.BABEL_ENV === 'coverage') await mergeClientCoverage() + if (appCode) {await promisify(fs.writeFile)(appFile, appCode, 'utf8')} + if (serverCode) {await promisify(fs.writeFile)(serverFile, serverCode, 'utf8')} + if (process.env.BABEL_ENV === 'coverage') {await mergeClientCoverage()} await logBrowserMessages() }) sharedTests() if (process.env.BABEL_ENV !== 'coverage') { - describe('hot reloading', function () { + describe('hot reloading', () => { it('server restarts when code is changed', async function () { this.timeout(60000) const serverModified = serverCode.replace(/express\(\)/, 'express()\napp.get("/test", (req, res) => res.send("hello world"))') @@ -139,7 +142,7 @@ describe('prod mode', function () { } }) -describe('prod mode with DISABLE_FULL_SSR=1', function () { +describe('prod mode with DISABLE_FULL_SSR=1', () => { let server before(async function () { @@ -147,8 +150,8 @@ describe('prod mode with DISABLE_FULL_SSR=1', function () { server = exec('npm run prod', { env: { ...process.env, - DISABLE_FULL_SSR: '1', - }, + DISABLE_FULL_SSR: '1' + } }) await childPrinted(server, /App is listening on http/i) await browser.reload() @@ -166,13 +169,13 @@ describe('prod mode with DISABLE_FULL_SSR=1', function () { after(async function () { this.timeout(30000) - if (server) await kill(server, 'SIGINT') - if (process.env.BABEL_ENV === 'coverage') await mergeClientCoverage() + if (server) {await kill(server, 'SIGINT')} + if (process.env.BABEL_ENV === 'coverage') {await mergeClientCoverage()} await logBrowserMessages() }) }) -describe('docker build', function () { +describe('docker build', () => { let server before(async function () { @@ -193,8 +196,7 @@ describe('docker build', function () { }) await childPrinted(server, /App is listening on http/i) let host - if (process.env.CI) host = (await execAsync('docker-compose port crater 80', {cwd: root})).stdout.trim() - else { + if (process.env.CI) {host = (await execAsync('docker-compose port crater 80', {cwd: root})).stdout.trim()} else { await execAsync('which docker-machine') .then(() => host = `192.168.99.100:${process.env.PORT}`) .catch(() => host = `localhost:${process.env.PORT}`) @@ -205,7 +207,7 @@ describe('docker build', function () { after(async function () { this.timeout(20000) - if (process.env.BABEL_ENV === 'coverage') await mergeClientCoverage() + if (process.env.BABEL_ENV === 'coverage') {await mergeClientCoverage()} await spawnAsync('docker-compose', ['down'], {cwd: root}) await logBrowserMessages() }) @@ -213,7 +215,7 @@ describe('docker build', function () { sharedTests() }) -describe('dev mode', function () { +describe('dev mode', () => { let server const appFile = path.join(src, 'universal', 'components', 'App.js') @@ -227,25 +229,25 @@ describe('dev mode', function () { server = exec('npm start', {cwd: root}) await Promise.all([ childPrinted(server, /webpack built [a-z0-9]+ in \d+ms/i), - childPrinted(server, /App is listening on http/i), + childPrinted(server, /App is listening on http/i) ]) await navigateTo(`http://localhost:${webpackConfig.devServer.port}`) }) after(async function () { this.timeout(15 * 60000) - if (server) await kill(server, 'SIGINT') + if (server) {await kill(server, 'SIGINT')} // restore code in App.js, which (may) have been changed by hot reloading test - if (appCode) await promisify(fs.writeFile)(appFile, appCode, 'utf8') - if (serverCode) await promisify(fs.writeFile)(serverFile, serverCode, 'utf8') - if (process.env.BABEL_ENV === 'coverage') await mergeClientCoverage() + if (appCode) {await promisify(fs.writeFile)(appFile, appCode, 'utf8')} + if (serverCode) {await promisify(fs.writeFile)(serverFile, serverCode, 'utf8')} + if (process.env.BABEL_ENV === 'coverage') {await mergeClientCoverage()} await logBrowserMessages() }) sharedTests() if (process.env.BABEL_ENV !== 'coverage') { - describe('hot reloading', function () { + describe('hot reloading', () => { it('works on the client', async function () { this.timeout(40000) const newHeader = 'Welcome to Crater! with hot reloading' @@ -268,8 +270,8 @@ describe('dev mode', function () { } }) -describe('build scripts', function () { - describe('build:meteor', function () { +describe('build scripts', () => { + describe('build:meteor', () => { it('only rebuilds when necessary', async function () { this.timeout(480000) @@ -283,7 +285,7 @@ describe('build scripts', function () { expect(/build\/meteor is up to date/i.test((await execAsync('npm run build:meteor', {cwd: root})).stdout)).to.be.true }) }) - describe('build:client', function () { + describe('build:client', () => { it('only rebuilds when necessary', async function () { this.timeout(480000) @@ -299,7 +301,7 @@ describe('build scripts', function () { expect(/client assets are up to date/.test((await execAsync('npm run build:client', {cwd: root})).stdout)).to.be.true }) }) - describe('build:server', function () { + describe('build:server', () => { it('only rebuilds when necessary', async function () { this.timeout(480000) diff --git a/wdio.conf.js b/wdio.conf.js index 89aa94d..a64bf11 100644 --- a/wdio.conf.js +++ b/wdio.conf.js @@ -12,7 +12,7 @@ exports.config = { // directory is where your package.json resides, so `wdio` will be called from there. // specs: [ - './test/integration/**/*.js', + './test/integration/**/*.js' ], // Patterns to exclude. exclude: [ @@ -46,7 +46,7 @@ exports.config = { // 5 instance gets started at a time. maxInstances: 5, // - browserName: 'phantomjs', + browserName : 'phantomjs' }], // // =================== @@ -57,30 +57,30 @@ exports.config = { // By default WebdriverIO commands are executed in a synchronous way using // the wdio-sync package. If you still want to run your tests in an async way // e.g. using promises you can set the sync option to false. - sync: true, + sync : true, // // Level of logging verbosity: silent | verbose | command | data | result | error - logLevel: 'command', + logLevel : 'command', // // Enables colors for log output. - coloredLogs: true, + coloredLogs : true, // // Saves a screenshot to a given path if a command fails. - screenshotPath: './errorShots/', + screenshotPath : './errorShots/', // // Set a base URL in order to shorten url command calls. If your url parameter starts // with "/", then the base url gets prepended. - baseUrl: process.env.ROOT_URL, + baseUrl : process.env.ROOT_URL, // // Default timeout for all waitFor* commands. - waitforTimeout: 10000, + waitforTimeout : 10000, // // Default timeout in milliseconds for request // if Selenium Grid doesn't send response connectionRetryTimeout: 90000, // // Default request retries count - connectionRetryCount: 3, + connectionRetryCount : 3, // // Initialize the browser instance with a WebdriverIO plugin. The object should have the // plugin name as key and the desired plugin options as properties. Make sure you have @@ -104,9 +104,9 @@ exports.config = { // Services take over a specific job you don't want to take care of. They enhance // your test setup with almost no effort. Unlike plugins, they don't add new // commands. Instead, they hook themselves up into the test process. - services: [ - 'phantomjs' - ], + services : [ + 'phantomjs' + ], // // Framework you want to run your specs with. // The following are supported: Mocha, Jasmine, and Cucumber @@ -124,9 +124,9 @@ exports.config = { // Options to be passed to Mocha. // See the full list at http://mochajs.org/ mochaOpts: { - ui: 'bdd', - compilers: ['js:babel-core/register'], - }, + ui : 'bdd', + compilers: ['js:babel-core/register'] + } // // ===== // Hooks diff --git a/webpack/webpack.config.dev.js b/webpack/webpack.config.dev.js index bfdff5b..7db6c89 100644 --- a/webpack/webpack.config.dev.js +++ b/webpack/webpack.config.dev.js @@ -16,47 +16,47 @@ const clientInclude = [srcDir] const { ROOT_URL } = process.env const meteorConfig = { - meteorProgramsFolder: path.resolve(buildDir, 'meteor', 'bundle', 'programs'), + meteorProgramsFolder : path.resolve(buildDir, 'meteor', 'bundle', 'programs'), injectMeteorRuntimeConfig: false, - exclude: [], + exclude : [] } const config = { context: root, devtool: 'eval', - entry: [ + entry : [ './src/client/index.js', 'react-hot-loader/patch', - 'webpack-hot-middleware/client', + 'webpack-hot-middleware/client' ], output: { // https://github.com/webpack/webpack/issues/1752 - filename: 'app.js', + filename : 'app.js', chunkFilename: '[name]_[chunkhash].js', - path: path.join(buildDir, 'static'), - publicPath: '/static/', + path : path.join(buildDir, 'static'), + publicPath : '/static/' }, plugins: [ new webpack.optimize.OccurrenceOrderPlugin(), new webpack.HotModuleReplacementPlugin(), new webpack.NoEmitOnErrorsPlugin(), new webpack.DefinePlugin({ - '__CLIENT__': true, - '__PRODUCTION__': false, - 'Meteor.isClient': true, - 'Meteor.isCordova': false, - 'Meteor.isServer': false, - 'process.env.TARGET': JSON.stringify(process.env.TARGET), - 'process.env.NODE_ENV': JSON.stringify('development'), + '__CLIENT__' : true, + '__PRODUCTION__' : false, + 'Meteor.isClient' : true, + 'Meteor.isCordova' : false, + 'Meteor.isServer' : false, + 'process.env.TARGET' : JSON.stringify(process.env.TARGET), + 'process.env.NODE_ENV': JSON.stringify('development') }), new HappyPack({ loaders: [{ - path: 'babel-loader', + path : 'babel-loader', options: { "presets": [["es2015", {loose: true, modules: false}], "stage-1", "react", "flow"], "plugins": [ "transform-runtime", - "react-hot-loader/babel", + "react-hot-loader/babel" ], "env": { "coverage": { @@ -67,73 +67,73 @@ const config = { } } }], - threads: 4, + threads: 4 }), new webpack.LoaderOptionsPlugin({ options: { postcss: [cssModulesValues] } }), - new MeteorImportsPlugin(meteorConfig), + new MeteorImportsPlugin(meteorConfig) ], module: { rules: [ { - test: /\.json$/, - loader: 'json-loader', + test : /\.json$/, + loader : 'json-loader', exclude: [ - path.join(root, 'build', 'meteor', 'bundle', 'programs'), + path.join(root, 'build', 'meteor', 'bundle', 'programs') ] }, {test: /\.txt$/, loader: 'raw-loader'}, { test: /\.(png|jpg|jpeg|gif|svg|woff|woff2)$/, - use: [{loader: 'url-loader', options: {limit: 10000}}] + use : [{loader: 'url-loader', options: {limit: 10000}}] }, {test: /\.(eot|ttf|wav|mp3)$/, loader: 'file-loader'}, { test: /\.css$/, - use: [ + use : [ {loader: 'style-loader'}, { - loader: 'css-loader', + loader : 'css-loader', options: { - modules: true, - importLoaders: 1, + modules : true, + importLoaders : 1, localIdentName: '[name]_[local]_[hash:base64:5]' } }, - {loader: 'postcss-loader'}, + {loader: 'postcss-loader'} ], exclude: globalCSS, - include: clientInclude, + include: clientInclude }, { - test: /\.css$/, - use: [{loader: 'style-loader'}, {loader: 'css-loader'}], - include: globalCSS, + test : /\.css$/, + use : [{loader: 'style-loader'}, {loader: 'css-loader'}], + include: globalCSS }, { - test: /\.js$/, - loader: 'happypack/loader', - include: clientInclude, - }, - ], + test : /\.js$/, + loader : 'happypack/loader', + include: clientInclude + } + ] }, - watch: true, + watch : true, devServer: { contentBase: ROOT_URL, - publicPath: '/static/', - noInfo: true, - port: 4000, - stats: { - colors: true, - }, - }, + publicPath : '/static/', + noInfo : true, + port : 4000, + stats : { + colors: true + } + } } /* istanbul ignore next */ -if (!process.env.CI) config.plugins.push(new ProgressBarPlugin()) +if (!process.env.CI) {config.plugins.push(new ProgressBarPlugin())} export default config diff --git a/webpack/webpack.config.prod.js b/webpack/webpack.config.prod.js index 6478d2e..b3db393 100644 --- a/webpack/webpack.config.prod.js +++ b/webpack/webpack.config.prod.js @@ -15,38 +15,38 @@ const globalCSS = path.join(srcDir, 'styles', 'global') const clientInclude = [srcDir] const meteorConfig = { - meteorProgramsFolder: path.resolve(buildDir, 'meteor', 'bundle', 'programs'), + meteorProgramsFolder : path.resolve(buildDir, 'meteor', 'bundle', 'programs'), injectMeteorRuntimeConfig: false, - exclude: [], + exclude : [] } const vendor = [ 'react', - 'react-dom', + 'react-dom' ] const config = { context: root, devtool: 'source-map', - entry: { - app: './src/client/index.js', + entry : { + app : './src/client/index.js', vendor, - meteor: ['meteor-imports'], + meteor: ['meteor-imports'] }, output: { - filename: '[name]_[chunkhash].js', + filename : '[name]_[chunkhash].js', chunkFilename: '[name]_[chunkhash].js', - path: path.join(buildDir, 'static'), - publicPath: '/static/', + path : path.join(buildDir, 'static'), + publicPath : '/static/' }, plugins: [ new webpack.NamedModulesPlugin(), new webpack.optimize.CommonsChunkPlugin({ - names: ['vendor', 'manifest'], - minChunks: Infinity, + names : ['vendor', 'manifest'], + minChunks: Infinity }), new webpack.optimize.CommonsChunkPlugin({ - name: 'meteor', + name : 'meteor', chunks: ['meteor'] }), new webpack.optimize.AggressiveMergingPlugin(), @@ -54,22 +54,22 @@ const config = { new webpack.NoEmitOnErrorsPlugin(), new AssetsPlugin({path: buildDir, filename: 'assets.json'}), new webpack.DefinePlugin({ - '__CLIENT__': true, - 'Meteor.isClient': true, - 'Meteor.isCordova': false, - 'Meteor.isServer': false, - 'process.env.TARGET': JSON.stringify(process.env.TARGET), - 'process.env.NODE_ENV': JSON.stringify('production'), + '__CLIENT__' : true, + 'Meteor.isClient' : true, + 'Meteor.isCordova' : false, + 'Meteor.isServer' : false, + 'process.env.TARGET' : JSON.stringify(process.env.TARGET), + 'process.env.NODE_ENV': JSON.stringify('production') }), new webpack.IgnorePlugin(/\/server\//), new HappyPack({ - cache: false, + cache : false, loaders: [{ - path: 'babel-loader', + path : 'babel-loader', options: { "presets": [["es2015", {loose: true, modules: false}], "stage-1", "react", "flow"], "plugins": [ - "transform-runtime", + "transform-runtime" ], "env": { "coverage": { @@ -80,24 +80,24 @@ const config = { } } }], - threads: 4, + threads: 4 }), new webpack.LoaderOptionsPlugin({ minimize: true, - options: { + options : { postcss: [cssModulesValues] } }), - new MeteorImportsPlugin(meteorConfig), + new MeteorImportsPlugin(meteorConfig) ], module: { rules: [ { - test: /\.json$/, - loader: 'json-loader', + test : /\.json$/, + loader : 'json-loader', exclude: [ - path.join(root, 'build', 'meteor', 'bundle', 'programs'), + path.join(root, 'build', 'meteor', 'bundle', 'programs') ] }, {test: /\.txt$/, loader: 'raw-loader'}, @@ -105,37 +105,37 @@ const config = { {test: /\.(eot|ttf|wav|mp3)$/, loader: 'file-loader'}, { test: /\.css$/, - use: [ + use : [ {loader: 'style-loader'}, { - loader: 'css-loader', + loader : 'css-loader', options: { - modules: true, - importLoaders: 1, + modules : true, + importLoaders : 1, localIdentName: '[name]_[local]_[hash:base64:5]' } }, {loader: 'postcss-loader'} ], exclude: globalCSS, - include: clientInclude, + include: clientInclude }, { - test: /\.css$/, - use: [{loader: 'style-loader'}, {loader: 'css-loader'}], - include: globalCSS, + test : /\.css$/, + use : [{loader: 'style-loader'}, {loader: 'css-loader'}], + include: globalCSS }, { - test: /\.js$/, - loader: 'happypack/loader', - include: clientInclude, - }, - ], - }, + test : /\.js$/, + loader : 'happypack/loader', + include: clientInclude + } + ] + } } /* istanbul ignore next */ -if (!process.env.CI) config.plugins.push(new ProgressBarPlugin()) +if (!process.env.CI) {config.plugins.push(new ProgressBarPlugin())} if (process.argv.indexOf('--no-uglify') < 0) { config.plugins.push(new webpack.optimize.UglifyJsPlugin({ compressor: { warnings: false } diff --git a/webpack/webpack.config.server.js b/webpack/webpack.config.server.js index 3415f50..e8c547d 100644 --- a/webpack/webpack.config.server.js +++ b/webpack/webpack.config.server.js @@ -15,26 +15,26 @@ const globalCSS = path.join(srcDir, 'styles', 'global') const config = { context: root, devtool: 'source-map', - entry: { - prerender: './src/server', + entry : { + prerender: './src/server' }, target: 'node', - node: { - __dirname: false, - __filename: false, + node : { + __dirname : false, + __filename: false }, output: { - path: buildDir, + path : buildDir, chunkFilename: '[name]_[chunkhash].js', - filename: '[name].js', + filename : '[name].js', libraryTarget: 'commonjs2', - publicPath: '/static/', + publicPath : '/static/' }, // ignore anything that throws warnings & doesn't affect the view externals: [ nodeExternals({ - modulesDir: path.join(root, 'node_modules'), - }), + modulesDir: path.join(root, 'node_modules') + }) // (context: string, request: string, callback: (error?: ?Error, result?: ?string) => any): any => { // const match = /^meteor\/(.*)$/.exec(request) // if (match) { @@ -48,20 +48,20 @@ const config = { new ExtractTextPlugin('/static/[name].css'), new webpack.optimize.LimitChunkCountPlugin({maxChunks: 1}), new webpack.DefinePlugin({ - '__CLIENT__': false, - '__PRODUCTION__': true, - 'Meteor.isClient': false, - 'Meteor.isCordova': false, - 'Meteor.isServer': true, - 'process.env.TARGET': JSON.stringify(process.env.TARGET), - 'process.env.NODE_ENV': JSON.stringify('production'), + '__CLIENT__' : false, + '__PRODUCTION__' : true, + 'Meteor.isClient' : false, + 'Meteor.isCordova' : false, + 'Meteor.isServer' : true, + 'process.env.TARGET' : JSON.stringify(process.env.TARGET), + 'process.env.NODE_ENV': JSON.stringify('production') // uncomment this line to hard-disable full SSR // 'process.env.DISABLE_FULL_SSR': JSON.stringify('1'), }), new HappyPack({ - cache: false, + cache : false, loaders: [{ - path: 'babel-loader', + path : 'babel-loader', options: { "presets": [["es2015", {loose: true, modules: false}], "stage-1", "react", "flow"], "plugins": [ @@ -77,8 +77,8 @@ const config = { } } }], - threads: 4, - }), + threads: 4 + }) ], module: { loaders: [ @@ -88,42 +88,42 @@ const config = { {test: /\.(eot|ttf|wav|mp3)$/, loader: 'file-loader'}, { test: /\.css$/, - use: ExtractTextPlugin.extract({ + use : ExtractTextPlugin.extract({ fallback: 'style-loader', - use: [ + use : [ { - loader: 'css-loader', + loader : 'css-loader', options: { - modules: true, - importLoaders: 1, - localIdentName: '[name]_[local]_[hash:base64:5]', + modules : true, + importLoaders : 1, + localIdentName: '[name]_[local]_[hash:base64:5]' } }, - {loader: 'postcss-loader'}, + {loader: 'postcss-loader'} ] }), include: srcDir, - exclude: globalCSS, + exclude: globalCSS }, { test: /\.css$/, - use: ExtractTextPlugin.extract({ + use : ExtractTextPlugin.extract({ fallback: "style-loader", - use: "css-loader" + use : "css-loader" }), - include: globalCSS, + include: globalCSS }, { - test: /\.js$/, - loader: 'happypack/loader', - include: srcDir, - }, - ], - }, + test : /\.js$/, + loader : 'happypack/loader', + include: srcDir + } + ] + } } /* istanbul ignore next */ -if (!process.env.CI) config.plugins.push(new ProgressBarPlugin()) +if (!process.env.CI) {config.plugins.push(new ProgressBarPlugin())} if (process.argv.indexOf('--no-uglify') < 0) { config.plugins.push(new webpack.optimize.UglifyJsPlugin({ compressor: { warnings: false }