diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..8edd7ed --- /dev/null +++ b/.eslintrc @@ -0,0 +1,19 @@ +{ + "extends": "airbnb", + "plugins": [ + "react", + "jsx-a11y", + "import" + ], + "rules": { + "global-require": [0], + "react/jsx-filename-extension": [0], + "react/prefer-es6-class": [0], + "react/prefer-stateless-function": [0], + "react/forbid-prop-types": [0], + /* to allow importing 'gatsby-helpers' */ + "import/no-extraneous-dependencies": [0], + "import/no-unresolved": [0], + "import/extensions": [0] + } +} diff --git a/.gitignore b/.gitignore index a312296..d5769d3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,8 @@ node_modules/ +npm-debug.log + +.eslintcache + public .gatsby-context.js diff --git a/components/ReadNext/index.jsx b/components/ReadNext/index.jsx index d3baaa6..21deaef 100644 --- a/components/ReadNext/index.jsx +++ b/components/ReadNext/index.jsx @@ -1,44 +1,48 @@ -import React from 'react' -import { Link } from 'react-router' -import { prune, include as includes } from 'underscore.string' -import find from 'lodash/find' +import React from 'react'; +import { Link } from 'react-router'; +import { include as includes } from 'underscore.string'; +import find from 'lodash/find'; -import './style.css' +import './style.css'; class ReadNext extends React.Component { - render() { - const {post} = this.props - const {pages} = this.props.route - const {readNext} = post + render() { + const { post } = this.props; + const { pages } = this.props.route; + const { readNext } = post; - let nextPost - if (readNext) { - nextPost = find(pages, (page) => includes(page.path, readNext) - ) - } - if (!nextPost) { - return React.createElement('noscript', null) - } else { - nextPost = find(pages, (page) => includes(page.path, readNext.slice(1, -1)) - ) - const description = nextPost.data.description - - return ( -
-
READ THIS NEXT:
-

{ nextPost.data.title }

-

- { description } -

-
- ); - } + let nextPost; + if (readNext) { + nextPost = find(pages, page => includes(page.path, readNext)); } + if (!nextPost) { + return React.createElement('noscript', null); + } + + nextPost = find(pages, page => includes(page.path, readNext.slice(1, -1))); + const description = nextPost.data.description; + + return ( +
+
READ THIS NEXT:
+

+ + {nextPost.data.title} + +

+

+ {description} +

+
+ ); + } } ReadNext.propTypes = { - post: React.PropTypes.object.isRequired, - pages: React.PropTypes.array, -} + post: React.PropTypes.object.isRequired, + pages: React.PropTypes.array, + route: React.PropTypes.object, +}; + +export default ReadNext; -export default ReadNext diff --git a/components/SiteLinks/index.jsx b/components/SiteLinks/index.jsx index efcf74c..cd56af1 100644 --- a/components/SiteLinks/index.jsx +++ b/components/SiteLinks/index.jsx @@ -1,62 +1,59 @@ -import React from 'react' -import { RouteHandler, Link } from 'react-router' -import { prefixLink } from 'gatsby-helpers' -import { config } from 'config' -import './style.css' -import '../../static/fonts/fontawesome/style.css' +import React from 'react'; +import { config } from 'config'; +import './style.css'; +import '../../static/fonts/fontawesome/style.css'; class SiteLinks extends React.Component { - render () { - - return ( -
- -
    - {config.siteEmailUrl && ( -
  • - - - -
  • - )} - {config.siteTelegramUrl && ( -
  • - - - -
  • - )} -
-
    - {config.siteRssUrl && ( -
  • - -
  • - )} -
-
- ) + render() { + return ( +
+
    + {config.siteTwitterUrl && ( +
  • + + + +
  • + )} + {config.siteGithubUrl && ( +
  • + + + +
  • + )} + {config.siteVkUrl && ( +
  • + +
  • + )} +
+
    + {config.siteEmailUrl && ( +
  • + + + +
  • + )} + {config.siteTelegramUrl && ( +
  • + + + +
  • + )} +
+
    + {config.siteRssUrl && ( +
  • + +
  • + )} +
+
+ ); } } -export default SiteLinks +export default SiteLinks; diff --git a/components/SiteNav/index.jsx b/components/SiteNav/index.jsx index 7468fe3..be7ffd8 100644 --- a/components/SiteNav/index.jsx +++ b/components/SiteNav/index.jsx @@ -1,34 +1,29 @@ -import React from 'react' -import { RouteHandler, Link } from 'react-router' -import { prefixLink } from 'gatsby-helpers' -import './style.css' +import React from 'react'; +import { Link } from 'react-router'; +import { prefixLink } from 'gatsby-helpers'; +import './style.css'; class SiteNav extends React.Component { - render() { - const {location} = this.props - return ( - - ); - } + render() { + return ( + + ); + } } -SiteNav.propTypes = { - location: React.PropTypes.object, -} - -export default SiteNav +export default SiteNav; diff --git a/components/SitePage/index.jsx b/components/SitePage/index.jsx index f92ad56..b58e1ad 100644 --- a/components/SitePage/index.jsx +++ b/components/SitePage/index.jsx @@ -1,39 +1,34 @@ -import React from 'react' -import moment from 'moment' -import { RouteHandler, Link } from 'react-router' -import { prefixLink } from 'gatsby-helpers' -import access from 'safe-access' -import { config } from 'config' -import SiteSidebar from '../SiteSidebar' +import React from 'react'; +import SiteSidebar from '../SiteSidebar'; import './style.css'; class SitePage extends React.Component { - render() { - const {route} = this.props - const post = route.page.data + render() { + const { route } = this.props; + const post = route.page.data; - return ( -
- -
-
-
-
-
-

{ post.title }

-
-
-
-
+ return ( +
+ +
+
+
+
+
+

{post.title}

+
- ); - } +
+
+
+ ); + } } SitePage.propTypes = { - route: React.PropTypes.object.isRequired, -} + route: React.PropTypes.object.isRequired, +}; -export default SitePage +export default SitePage; diff --git a/components/SitePost/index.jsx b/components/SitePost/index.jsx index 01a693a..c92aec7 100644 --- a/components/SitePost/index.jsx +++ b/components/SitePost/index.jsx @@ -1,52 +1,51 @@ -import React from 'react' -import moment from 'moment' -import { RouteHandler, Link } from 'react-router' -import { prefixLink } from 'gatsby-helpers' -import access from 'safe-access' -import { config } from 'config' -import ReadNext from '../ReadNext' -import './style.css' -import '../../static/css/highlight.css' +import React from 'react'; +import moment from 'moment'; +import { Link } from 'react-router'; +import { prefixLink } from 'gatsby-helpers'; +import { config } from 'config'; +import ReadNext from '../ReadNext'; +import './style.css'; +import '../../static/css/highlight.css'; class SitePost extends React.Component { - render() { - const {route} = this.props - const post = route.page.data - const home = ( -
- All Articles - -
- ) + render() { + const { route } = this.props; + const post = route.page.data; + const home = ( +
+ All Articles +
+ ); - return ( -
- { home } -
-
-

{ post.title }

-
-
- Published { moment(post.date).format('D MMM YYYY') } -
-
-
- -
-

- { config.siteDescr } - -

{ config.siteAuthor } on Twitter
-

-
-
+ return ( +
+ {home} +
+
+

{post.title}

+
+
+ Published {moment(post.date).format('D MMM YYYY')}
- ); - } +
+
+ +
+

+ {config.siteDescr} + +
{config.siteAuthor} on Twitter +
+

+
+
+
+ ); + } } SitePost.propTypes = { - route: React.PropTypes.object.isRequired -} + route: React.PropTypes.object.isRequired, +}; -export default SitePost +export default SitePost; diff --git a/components/SiteSidebar/index.jsx b/components/SiteSidebar/index.jsx index 03ed8e7..5726111 100644 --- a/components/SiteSidebar/index.jsx +++ b/components/SiteSidebar/index.jsx @@ -1,58 +1,64 @@ -import React from 'react' -import { RouteHandler, Link } from 'react-router' -import { prefixLink } from 'gatsby-helpers' -import { config } from 'config' -import SiteNav from '../SiteNav' -import SiteLinks from '../SiteLinks' -import './style.css' -import profilePic from '../../pages/photo.jpg' +import React from 'react'; +import { Link } from 'react-router'; +import { prefixLink } from 'gatsby-helpers'; +import { config } from 'config'; +import SiteNav from '../SiteNav'; +import SiteLinks from '../SiteLinks'; +import './style.css'; +import profilePic from '../../pages/photo.jpg'; class SiteSidebar extends React.Component { - render() { - const {location, children} = this.props - const isHome = location.pathname === prefixLink('/') + render() { + const { location } = this.props; + const isHome = location.pathname === prefixLink('/'); - let header = ( -
- - - - { isHome ? ( -

{ config.siteAuthor }

- ) : -

{ config.siteAuthor }

} -

- { config.siteDescr } -

-
- ) + /* eslint-disable jsx-a11y/img-redundant-alt*/ + const header = ( +
+ + Profile picture of the author + + { isHome ? ( +

{config.siteAuthor}

+ ) : +

{config.siteAuthor}

} +

+ {config.siteDescr} +

+
+ ); + /* eslint-enable jsx-a11y/img-redundant-alt*/ - return ( -
-
-
-
- { header } -
-
-
- -
- -

- © All rights reserved. -

-
-
-
-
- ); - } + return ( +
+
+
+
+ {header} +
+
+
+ +
+ +

+ © All rights reserved. +

+
+
+
+
+ ); + } } SiteSidebar.propTypes = { - children: React.PropTypes.any, - location: React.PropTypes.object, -} + location: React.PropTypes.object, +}; + +export default SiteSidebar; -export default SiteSidebar diff --git a/gatsby-browser.js b/gatsby-browser.js index 8ba7f29..e5fdf07 100644 --- a/gatsby-browser.js +++ b/gatsby-browser.js @@ -1,8 +1,8 @@ -import ReactGA from 'react-ga' -import {config} from 'config' +import ReactGA from 'react-ga'; +import { config } from 'config'; ReactGA.initialize(config.googleAnalyticsId); -exports.onRouteUpdate = (state, page, pages) => { +exports.onRouteUpdate = (state) => { ReactGA.pageview(state.pathname); -}; \ No newline at end of file +}; diff --git a/gatsby-node.js b/gatsby-node.js index e391fe1..0e71008 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -1,22 +1,22 @@ -var rucksack = require('rucksack-css') -var lost = require("lost") -var cssnext = require("postcss-cssnext") +const rucksack = require('rucksack-css'); +const lost = require('lost'); +const cssnext = require('postcss-cssnext'); -exports.modifyWebpackConfig = function(config, env) { - config.merge({ - postcss: [ - lost(), - rucksack(), - cssnext({ - browsers: ['>1%', 'last 2 versions'] - }) - ] - }) +exports.modifyWebpackConfig = function (config) { + config.merge({ + postcss: [ + lost(), + rucksack(), + cssnext({ + browsers: ['>1%', 'last 2 versions'], + }), + ], + }); - config.loader('svg', { - test: /\.(svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, - loader: 'file-loader', - }) + config.loader('svg', { + test: /\.(svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, + loader: 'file-loader', + }); - return config -}; \ No newline at end of file + return config; +}; diff --git a/html.js b/html.js index fbef134..e9bec80 100644 --- a/html.js +++ b/html.js @@ -1,38 +1,39 @@ -import React from 'react' -import Helmet from 'react-helmet' -import { prefixLink } from 'gatsby-helpers' +import React from 'react'; +import Helmet from 'react-helmet'; +import { prefixLink } from 'gatsby-helpers'; -const BUILD_TIME = new Date().getTime() +const BUILD_TIME = new Date().getTime(); module.exports = React.createClass({ - displayName: 'HTML', - propTypes: { - body: React.PropTypes.string, - }, - render() { - const {body, route} = this.props - const {title} = Helmet.rewind() - const font = - let css - if (process.env.NODE_ENV === 'production') { - css =