diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..e229935 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,17 @@ +{ + "extends": "eslint-config-airbnb", + "rules": { + "indent": [2, 2, {"SwitchCase": 1}], + "no-console": [0], + "func-names": [0], + "semi": [2, "never"], + "no-extra-semi": [2], + "space-before-function-paren": [2, "always"], + "no-else-return": [0], + "space-infix-ops": [0], + "react/prefer-es6-class": [0], + }, + "globals": { + "__PREFIX_LINKS__": true, + }, +} diff --git a/app.js b/app.js index 148e5fd..07fd802 100644 --- a/app.js +++ b/app.js @@ -1,11 +1,10 @@ -exports.loadContext = function(callback) { - var context; - context = require.context('./pages', true); +exports.loadContext = function (callback) { + let context = require.context('./pages', true) if (module.hot) { - module.hot.accept(context.id, function() { - context = require.context('./pages', true); - return callback(context); - }); + module.hot.accept(context.id, () => { + context = require.context('./pages', true) + return callback(context) + }) } - return callback(context); -}; + return callback(context) +} diff --git a/components/ReadNext.jsx b/components/ReadNext.jsx index f00ef1c..5c517f7 100644 --- a/components/ReadNext.jsx +++ b/components/ReadNext.jsx @@ -1,28 +1,33 @@ -import React from 'react'; -import { Link } from 'react-router'; -import { prune, include as includes } from 'underscore.string'; -import find from 'lodash/collection/find'; +import React from 'react' +import { Link } from 'react-router' +import { prune, include as includes } from 'underscore.string' +import find from 'lodash/collection/find' import { rhythm, fontSizeToMS } from 'utils/typography' -import { link } from 'gatsby-helpers' -export default class extends React.Component { - render() { - let body, html, nextPost, readNext; - readNext = this.props.post.readNext; - if (readNext != null) { - nextPost = find(this.props.pages, function(page) { - return includes(page.path, readNext.slice(1, -1)); - }); +export default class ReadNext extends React.Component { + propTypes () { + return { + post: React.PropTypes.object, + pages: React.PropTypes.object, + } + } + render () { + const readNext = this.props.post.readNext + let nextPost + if (readNext !== null) { + nextPost = find(this.props.pages, (page) => + includes(page.path, readNext.slice(1, -1)) + ) } if (!nextPost) { - return React.createElement("noscript", null); + return React.createElement('noscript', null) } else { - nextPost = find(this.props.pages, function(page) { - return includes(page.path, readNext.slice(1, -1)); - }); + nextPost = find(this.props.pages, (page) => + includes(page.path, readNext.slice(1, -1)) + ) // Create pruned version of the body. - html = nextPost.data.body; - body = prune(html.replace(/<[^>]*>/g, ''), 200); + const html = nextPost.data.body + const body = prune(html.replace(/<[^>]*>/g, ''), 200) return (
{body}