Skip to content

Commit

Permalink
update eslint, clean up some dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
bdefore committed Jan 9, 2016
1 parent d0e6412 commit e9827ce
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 31 deletions.
6 changes: 4 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
"indent": [2, 2, {"SwitchCase": 1}],
"no-console": 0,
"no-alert": 0,
"no-nested-ternary": 0
"no-nested-ternary": 0,
"max-len": 0
},
"plugins": [
"react", "import"
"react",
"import"
],
"settings": {
"import/parser": "babel-eslint",
Expand Down
12 changes: 6 additions & 6 deletions bin/merge-babel-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ module.exports = (userBabelConfig, verbose) => {

const hmrConfig = [
'react-transform', {
'transforms': [
transforms: [
{
'transform': 'react-transform-hmr',
'imports': ['react'],
'locals': ['module']
transform: 'react-transform-hmr',
imports: ['react'],
locals: ['module']
},
{
'transform': 'react-transform-catch-errors',
'imports': ['react', 'redbox-react']
transform: 'react-transform-catch-errors',
imports: ['react', 'redbox-react']
}
]
}
Expand Down
14 changes: 5 additions & 9 deletions bin/merge-configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const mergeWebpack = require('webpack-config-merger');
const baseWebpackConfig = require('../config/webpack.config.js');
const baseDevConfig = mergeWebpack(baseWebpackConfig.common, baseWebpackConfig.development);
const baseProdConfig = mergeWebpack(baseWebpackConfig.common, baseWebpackConfig.production);
const baseToolsConfig = require('../config/webpack-isomorphic-tools-config');
const baseToolsConfig = require('../config/webpack-isomorphic-tools.config.js');
const WebpackErrorNotificationPlugin = require('webpack-error-notification');

const isProduction = process.env.NODE_ENV === 'production';
Expand All @@ -25,7 +25,6 @@ function inspect(obj) {

module.exports = (userConfig) => {
// derive root and sourceDir, alowing for absolute, relative, or not provided
// TODO: create helper for deriving root, also in src/server.js
const root = userConfig.root ? userConfig.root[0] === '/' ? userConfig.root : path.resolve(__dirname, '../..', userConfig.root) : path.resolve(__dirname, '../../..');
const sourceDir = userConfig.sourceDir ? userConfig.sourceDir[0] === '/' ? userConfig.sourceDir : path.resolve(root, userConfig.sourceDir) : path.resolve(root, './src');

Expand All @@ -46,11 +45,8 @@ module.exports = (userConfig) => {
combinedWebpackConfig.module.loaders.unshift({ test: /\.jsx?$/, exclude: /node_modules/, loaders: babelConfig });

// gather tools config
const combinedToolsConfig = baseToolsConfig;
if (universalReduxConfig.toolsConfigPath) {
const userToolsConfig = require(path.resolve(universalReduxConfig.toolsConfigPath));
combinedToolsConfig = lodash.merge(baseToolsConfig, userToolsConfig);
}
const userToolsConfig = require(path.resolve(universalReduxConfig.toolsConfigPath));
const combinedToolsConfig = lodash.merge(baseToolsConfig, userToolsConfig);
combinedToolsConfig.webpack_assets_file_path = 'node_modules/universal-redux/webpack-assets.json';

// add tools settings to combined weback config
Expand All @@ -61,7 +57,7 @@ module.exports = (userConfig) => {
combinedWebpackConfig.plugins.push(isProduction ? toolsPlugin : toolsPlugin.development());

// turn on linting per webpack build, unless directed not to
if (universalReduxConfig.lint && universalReduxConfig.lint.enabled !== false && !isProduction) {
if (universalReduxConfig.lint.enabled !== false && !isProduction) {
combinedWebpackConfig.module.loaders[0].loaders.push('eslint-loader');
const lintConfigPath = universalReduxConfig.lint.config || path.resolve(__dirname, '../.eslintrc');
combinedWebpackConfig.eslint = {
Expand Down Expand Up @@ -93,7 +89,7 @@ module.exports = (userConfig) => {
if (universalReduxConfig.redux.middleware) {
combinedWebpackConfig.resolve.alias.middleware = universalReduxConfig.redux.middleware;
} else {
combinedWebpackConfig.resolve.alias.middleware = path.resolve(__dirname, '../lib/redux/middleware/index.js');
combinedWebpackConfig.resolve.alias.middleware = path.resolve(__dirname, '../lib/helpers/empty.js');
}

// add project level vendor libs
Expand Down
4 changes: 2 additions & 2 deletions bin/webpack-dev-server_es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const serverOptions = {
inline: true,
lazy: false,
publicPath: webpackConfig.output.publicPath,
headers: {'Access-Control-Allow-Origin': '*'},
stats: {colors: true}
headers: { 'Access-Control-Allow-Origin': '*' },
stats: { colors: true }
};

const app = new Express();
Expand Down
2 changes: 1 addition & 1 deletion config/universal-redux.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ module.exports = (projectRoot, sourceRoot) => {
//
// Expects: String
*/
// toolsConfigPath: __dirname + '/webpack-isomorphic-tools.config.js',
toolsConfigPath: __dirname + '/webpack-isomorphic-tools.config.js',

/*
// When eneabled, will output Webpack and Webpack Isomorphic
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = {
common: {
context: path.resolve(__dirname, '..'),
entry: {
'main': [
main: [
path.resolve(__dirname, '..', 'lib/client.js')
]
},
Expand Down Expand Up @@ -59,7 +59,7 @@ module.exports = {
development: {
devtool: 'inline-source-map',
entry: {
'main': [
main: [
'webpack-hot-middleware/client?path=http://' + host + ':' + port + '/__webpack_hmr',
]
},
Expand Down Expand Up @@ -97,14 +97,14 @@ module.exports = {
},
module: {
loaders: [
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style', 'css')},
{ test: /\.css$/, loader: ExtractTextPlugin.extract('style', 'css') },
{ test: /\.less$/, loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=2&sourceMap!autoprefixer?browsers=last 2 version!less?outputStyle=expanded&sourceMap=true&sourceMapContents=true') },
{ test: /\.scss$/, loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=2&sourceMap!autoprefixer?browsers=last 2 version!sass?outputStyle=expanded&sourceMap=true&sourceMapContents=true') }
]
},
plugins: [
// css files from the extract-text-plugin loader
new ExtractTextPlugin('[name]-[chunkhash].css', {allChunks: true}),
new ExtractTextPlugin('[name]-[chunkhash].css', { allChunks: true }),
new webpack.DefinePlugin({
__CLIENT__: true,
__SERVER__: false
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
"compression": "^1.6.0",
"css-loader": "^0.23.0",
"eslint": "1.10.3",
"eslint-config-airbnb": "0.1.0",
"eslint-config-airbnb": "0.1.1",
"eslint-loader": "^1.0.0",
"eslint-plugin-import": "0.12.1",
"eslint-plugin-react": "^3.5.0",
"eslint-plugin-import": "0.12.0",
"eslint-plugin-react": "^3.7.1",
"express": "^4.13.3",
"extract-text-webpack-plugin": "1.0.1",
"file-loader": "^0.8.5",
Expand Down
5 changes: 5 additions & 0 deletions src/helpers/empty.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// so that we can use webpack aliases for optional
// features like specifying custom redux middleware
// without blowing up when they are imported on the
// client and the path cannot be resolved
export default {};
2 changes: 0 additions & 2 deletions src/redux/middleware/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/server/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default (projectConfig, projectToolsConfig) => {
return;
}

match({ history: history, routes: getRoutes(), location: req.originalUrl }, (error, redirectLocation, renderProps) => {
match({ history, routes: getRoutes(), location: req.originalUrl }, (error, redirectLocation, renderProps) => {
if (redirectLocation) {
res.redirect(redirectLocation.pathname + redirectLocation.search);
} else if (error) {
Expand Down
2 changes: 1 addition & 1 deletion src/server/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import configure from '../configure';

export default (projectConfig, projectToolsConfig) => {
const config = configure(projectConfig);
const toolsConfig = projectToolsConfig || require('../../config/webpack-isomorphic-tools-config');
const toolsConfig = projectToolsConfig || require('../../config/webpack-isomorphic-tools.config.js');

// bury it here rather than pollute the project directory
toolsConfig.webpack_assets_file_path = 'node_modules/universal-redux/webpack-assets.json';
Expand Down

0 comments on commit e9827ce

Please sign in to comment.