From 1e87dfdb6b179587f52eee8145ce98bbee25730c Mon Sep 17 00:00:00 2001 From: Simon Reinsperger Date: Tue, 7 Mar 2017 16:12:39 +0100 Subject: [PATCH 01/12] feat: eslint config (airbnb), adds cache option for lint npm script --- .eslintrc | 8 ++++++++ .gitignore | 2 ++ package.json | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .eslintrc diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..99f7c65 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,8 @@ +{ + "extends": "airbnb", + "plugins": [ + "react", + "jsx-a11y", + "import" + ] +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index a312296..13532a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ node_modules/ +npm-debug.log + public .gatsby-context.js diff --git a/package.json b/package.json index 0f22038..638e3c4 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "clean": "npm run clean:public", "copy:files": "find ./pages -maxdepth 1 -type f -regextype posix-extended -regex '.+\\.(pdf|txt|png|jpg|jpeg|gif)$' -exec cp -v {} ./public ';'", "copy": "npm run copy:files", - "lint": "./node_modules/.bin/eslint --ext .js,.jsx --ignore-pattern public .", + "lint": "./node_modules/.bin/eslint --cache --ext .js,.jsx --ignore-pattern public .", "test": "echo \"Error: no test specified\" && exit 1", "deploy": "gatsby build --prefix-links && gh-pages -d public" }, From 84cd888614f38947091eb8e83e80bab1a3acf3fb Mon Sep 17 00:00:00 2001 From: Simon Reinsperger Date: Tue, 7 Mar 2017 16:46:07 +0100 Subject: [PATCH 02/12] refactor: linting html.js --- .eslintrc | 12 +++++++++- html.js | 69 ++++++++++++++++++++++++++++--------------------------- 2 files changed, 46 insertions(+), 35 deletions(-) diff --git a/.eslintrc b/.eslintrc index 99f7c65..3374c94 100644 --- a/.eslintrc +++ b/.eslintrc @@ -4,5 +4,15 @@ "react", "jsx-a11y", "import" - ] + ], + "rules": { + "react/jsx-filename-extension": [0], + "react/prefer-es6-class": [0], + "global-require": [0], + "react/prefer-stateless-function": [0], + /* to allow importing 'gatsby-helpers' */ + "import/no-extraneous-dependencies": [0], + "import/no-unresolved": [0], + "import/extensions": [0] + } } \ No newline at end of file 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 =