Skip to content

Commit

Permalink
Makes more eslint related changes and minor cleaning up.
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlplusb committed Sep 12, 2016
1 parent 7f842aa commit b9f06a6
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 41 deletions.
2 changes: 1 addition & 1 deletion example/src/MySizeAwareComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { PropTypes } from 'react';
let sizeMe;

if (process.env.NODE_ENV === 'development') {
sizeMe = require('../../src/index.js').default;
sizeMe = require('../../src/sizeMe.js').default;
} else {
sizeMe = require('react-sizeme').default;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/react-sizeme.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/index.js

This file was deleted.

14 changes: 8 additions & 6 deletions src/SizeMe.js → src/sizeMe.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const renderWrapper = (WrappedComponent) => {
*
* @return The wrapped component.
*/
function SizeMe(config = defaultConfig) {
function sizeMe(config = defaultConfig) {
const { monitorWidth = true, monitorHeight = false, refreshRate = 16 } = config;

invariant(
Expand Down Expand Up @@ -161,8 +161,10 @@ function SizeMe(config = defaultConfig) {
}

handleDOMNode() {
const found = this.element &&
ReactDOM.findDOMNode(this.element);
const found = this.element
// One day this will be deprecated then I will be forced into wrapping
// the component with a div or such in order to get a dome element handle.
&& ReactDOM.findDOMNode(this.element); // eslint-disable-line react/no-find-dom-node

/* istanbul ignore next */
if (!found) {
Expand Down Expand Up @@ -213,7 +215,7 @@ function SizeMe(config = defaultConfig) {
<SizeMeRenderWrapper
explicitRef={this.refCallback}
size={{ width, height }}
disablePlaceholder={!!SizeMe.enableSSRBehaviour}
disablePlaceholder={!!sizeMe.enableSSRBehaviour}
{...this.props}
/>
);
Expand All @@ -234,6 +236,6 @@ function SizeMe(config = defaultConfig) {
* extra render cycles to happen within your components depending on the logic
* contained within them around the usage of the `size` data.
*/
SizeMe.enableSSRBehaviour = false;
sizeMe.enableSSRBehaviour = false;

export default SizeMe;
export default sizeMe;
2 changes: 1 addition & 1 deletion test/SizeMe.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describeWithDOM('Given the SizeMe library', () => {
const placeholderHtml = '<div style="width: 100%; height: 100%;"></div>';

beforeEach(() => {
sizeMe = require('../src/index').default;
sizeMe = require('../src/sizeMe').default;

// Set up our mocks.
SizeMeRewireAPI = sizeMe.__RewireAPI__;
Expand Down
64 changes: 33 additions & 31 deletions webpack.config.babel.js
Original file line number Diff line number Diff line change
@@ -1,92 +1,94 @@
/* eslint-disable import/no-extraneous-dependencies */

import webpack from 'webpack';
import path from 'path';
import WebpackStatsPlugin from 'stats-webpack-plugin';
import LodashModuleReplacementPlugin from 'lodash-webpack-plugin';

const env = process.env.NODE_ENV;
const generateStats = process.env.WEBPACK_STATS || false;
const libraryName = `react-sizeme`;
const libraryName = 'react-sizeme';
const outputFileName = `${libraryName}.js`;

const reactExternal = {
root: `React`,
commonjs2: `react`,
commonjs: `react`,
amd: `react`
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react',
};

const reactDOMExternal = {
root: `ReactDOM`,
commonjs2: `react-dom`,
commonjs: `react-dom`,
amd: `react-dom`
root: 'ReactDOM',
commonjs2: 'react-dom',
commonjs: 'react-dom',
amd: 'react-dom',
};

const config = {
entry: path.resolve(__dirname, `./src/index.js`),
entry: path.resolve(__dirname, './src/sizeMe.js'),
externals: {
react: reactExternal,
'react-dom': reactDOMExternal
'react-dom': reactDOMExternal,
},
module: {
preLoaders: [
{ test: /\.js$/, loaders: [`eslint-loader`], exclude: /node_modules/ }
{ test: /\.js$/, loaders: ['eslint-loader'], exclude: /node_modules/ },
],
loaders: [
{
test: /\.js$/,
loaders: [`babel-loader`],
include: [path.resolve(__dirname, `./src`)],
exclude: /node_modules/
}
]
loaders: ['babel-loader'],
include: [path.resolve(__dirname, './src')],
exclude: /node_modules/,
},
],
},
output: {
path: path.resolve(__dirname, `./lib`),
path: path.resolve(__dirname, './lib'),
filename: outputFileName,
library: libraryName,
libraryTarget: `umd`,
umdNamedDefine: true
libraryTarget: 'umd',
umdNamedDefine: true,
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(env)
})
'process.env.NODE_ENV': JSON.stringify(env),
}),
],
eslint: {
failOnError: true,
failOnWarning: true
}
failOnWarning: true,
},
};

if (env === `production`) {
if (env === 'production') {
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
output: {
comments: false
comments: false,
},
compressor: {
pure_getters: true,
unsafe: true,
unsafe_comps: true,
screw_ie8: true,
warnings: false
}
warnings: false,
},
})
);

config.plugins.push(
new LodashModuleReplacementPlugin
new LodashModuleReplacementPlugin()
);
}

if (generateStats) {
config.plugins.push(
new WebpackStatsPlugin(`stats.json`, {
new WebpackStatsPlugin('stats.json', {
chunkModules: true,
exclude: [/node_modules[\\\/]react/]
exclude: [/node_modules[\\\/]react/],
})
);
}
Expand Down

0 comments on commit b9f06a6

Please sign in to comment.