commit fecafc1c8f285442ed18b7986be7428ce547fa30
parent 2ee147bdc29ee231423199872548eb6ee991ec80
Author: Vladimir Kutepov <frenzzy.man@gmail.com>
Date: Sun, 21 Feb 2016 14:03:44 +0300
Update ESLint to v2, eslint-config-airbnb to v6, eslint-plugin-react to v4
Changelog:
- [eslint 2.0.0 (2016-02-19)](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [eslint-plugin-react 4.0.0 (2016-02-19)](https://github.com/yannickcr/eslint-plugin-react/blob/master/CHANGELOG.md#400---2016-02-19)
- [eslint-config-airbnb 6.0.0 (2016-02-21)](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb/CHANGELOG.md#600--2016-02-21)
close #455
Diffstat:
11 files changed, 27 insertions(+), 20 deletions(-)
diff --git a/.eslintrc b/.eslintrc
@@ -5,6 +5,7 @@
"__DEV__": true
},
"rules": {
+ "no-confusing-arrow": 0,
"react/jsx-quotes": 0,
"jsx-quotes": [2, "prefer-double"]
}
diff --git a/package.json b/package.json
@@ -41,10 +41,10 @@
"css-loader": "^0.23.1",
"csscomb": "^3.1.8",
"del": "^2.2.0",
- "eslint": "^1.10.3",
- "eslint-config-airbnb": "^5.0.1",
+ "eslint": "^2.2.0",
+ "eslint-config-airbnb": "^6.0.0",
"eslint-loader": "^1.3.0",
- "eslint-plugin-react": "^3.16.1",
+ "eslint-plugin-react": "^4.0.0",
"extend": "^3.0.0",
"file-loader": "^0.8.5",
"gaze": "^0.5.2",
diff --git a/src/api/content.js b/src/api/content.js
@@ -36,7 +36,7 @@ router.get('/', async (req, res, next) => {
const path = req.query.path;
if (!path || path === 'undefined') {
- res.status(400).send({ error: `The 'path' query parameter cannot be empty.` });
+ res.status(400).send({ error: 'The \'path\' query parameter cannot be empty.' });
return;
}
diff --git a/src/client.js b/src/client.js
@@ -18,12 +18,12 @@ let cssContainer = document.getElementById('css');
const appContainer = document.getElementById('app');
const context = {
insertCss: styles => styles._insertCss(),
- onSetTitle: value => document.title = value,
+ onSetTitle: value => (document.title = value),
onSetMeta: (name, content) => {
// Remove and create a new <meta /> tag in order to make it work
// with bookmarks in Safari
const elements = document.getElementsByTagName('meta');
- [].slice.call(elements).forEach((element) => {
+ Array.from(elements).forEach((element) => {
if (element.getAttribute('name') === name) {
element.parentNode.removeChild(element);
}
@@ -31,13 +31,15 @@ const context = {
const meta = document.createElement('meta');
meta.setAttribute('name', name);
meta.setAttribute('content', content);
- document.getElementsByTagName('head')[0].appendChild(meta);
+ document
+ .getElementsByTagName('head')[0]
+ .appendChild(meta);
},
};
// Google Analytics tracking. Don't send 'pageview' event after the first
// rendering, as it was already sent by the Html component.
-let trackPageview = () => trackPageview = () => window.ga('send', 'pageview');
+let trackPageview = () => (trackPageview = () => window.ga('send', 'pageview'));
function render(state) {
Router.dispatch(state, (newState, component) => {
diff --git a/src/components/App/App.js b/src/components/App/App.js
@@ -45,7 +45,8 @@ class App extends Component {
}
componentWillMount() {
- this.removeCss = this.props.context.insertCss(s);
+ const { insertCss } = this.props.context;
+ this.removeCss = insertCss(s);
}
componentWillUnmount() {
diff --git a/src/components/Html/Html.js b/src/components/Html/Html.js
@@ -12,7 +12,7 @@ import { analytics } from '../../config';
// https://analytics.google.com/
const trackingCode =
- `window.ga=function(){ga.q.push(arguments)};ga.q=[];ga.l=+new Date;` +
+ 'window.ga=function(){ga.q.push(arguments)};ga.q=[];ga.l=+new Date;' +
`ga('create','${analytics.google.trackingId}','auto');ga('send','pageview')`;
class Html extends Component {
diff --git a/src/components/Link/Link.js b/src/components/Link/Link.js
@@ -54,7 +54,7 @@ class Link extends Component {
};
render() {
- const { to, ...props } = this.props;
+ const { to, ...props } = this.props; // eslint-disable-line no-use-before-define
return <a href={Location.createHref(to)} {...props} onClick={this.handleClick} />;
}
diff --git a/src/components/withViewport.js b/src/components/withViewport.js
@@ -53,7 +53,7 @@ function withViewport(ComposedComponent) {
}
render() {
- return <ComposedComponent {...this.props} viewport={this.state.viewport}/>;
+ return <ComposedComponent {...this.props} viewport={this.state.viewport} />;
}
handleResize(value) {
diff --git a/src/server.js b/src/server.js
@@ -46,9 +46,9 @@ server.get('*', async (req, res, next) => {
const css = [];
const context = {
insertCss: styles => css.push(styles._getCss()),
- onSetTitle: value => data.title = value,
- onSetMeta: (key, value) => data[key] = value,
- onPageNotFound: () => statusCode = 404,
+ onSetTitle: value => (data.title = value),
+ onSetMeta: (key, value) => (data[key] = value),
+ onPageNotFound: () => (statusCode = 404),
};
await Router.dispatch({ path: req.path, query: req.query, context }, (state, component) => {
diff --git a/tools/bundle.js b/tools/bundle.js
@@ -21,7 +21,7 @@ function bundle() {
}
console.log(stats.toString(webpackConfig[0].stats));
- resolve();
+ return resolve();
});
});
}
diff --git a/tools/start.js b/tools/start.js
@@ -38,9 +38,11 @@ async function start() {
config.plugins.push(new webpack.HotModuleReplacementPlugin());
config.plugins.push(new webpack.NoErrorsPlugin());
- config.module.loaders
+ config
+ .module
+ .loaders
.filter(x => x.loader === 'babel-loader')
- .forEach(x => x.query = { // eslint-disable-line no-param-reassign
+ .forEach(x => (x.query = { // eslint-disable-line no-param-reassign
// Wraps all React components into arbitrary transforms
// https://github.com/gaearon/babel-plugin-react-transform
plugins: [
@@ -58,7 +60,7 @@ async function start() {
},
],
],
- });
+ }));
});
const bundler = webpack(webpackConfig);
@@ -74,7 +76,8 @@ async function start() {
// For other settings see
// https://webpack.github.io/docs/webpack-dev-middleware
});
- const hotMiddlewares = bundler.compilers
+ const hotMiddlewares = bundler
+ .compilers
.filter(compiler => compiler.options.target !== 'node')
.map(compiler => webpackHotMiddleware(compiler));