diff --git a/.eslintrc b/.eslintrc index 4b66b72..66eaf0a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -5,7 +5,7 @@ "plugin:react/recommended", "plugin:prettier/recommended" ], - "plugins": ["react", "graphql", "prettier"], + "plugins": ["react", "graphql", "prettier", "react-hooks"], "parserOptions": { "sourceType": "module", "ecmaFeatures": { @@ -23,7 +23,9 @@ "quotes": ["error", "single"], "semi": ["error", "never"], "object-curly-spacing": ["error", "always"], - "prettier/prettier": "error" + "prettier/prettier": "error", + "react-hooks/rules-of-hooks": "error", + "react-hooks/exhaustive-deps": "warn" }, "settings": { "react": { diff --git a/package.json b/package.json index efad4b0..c6adfd3 100644 --- a/package.json +++ b/package.json @@ -25,22 +25,22 @@ "dependencies": { "classnames": "^2.2.6", "file-saver": "^2.0.1", - "gatsby": "^2.3.31", - "gatsby-image": "^2.0.40", + "gatsby": "^2.7.1", + "gatsby-image": "^2.1.1", "gatsby-plugin-favicon": "^3.1.6", "gatsby-plugin-matomo": "^0.7.0", "gatsby-plugin-offline": "^2.0.25", "gatsby-plugin-react-helmet": "^3.0.12", "gatsby-plugin-sass": "^2.0.11", - "gatsby-plugin-sharp": "^2.0.35", + "gatsby-plugin-sharp": "^2.1.1", "gatsby-plugin-sitemap": "^2.0.12", "gatsby-plugin-svgr": "^2.0.2", - "gatsby-source-filesystem": "^2.0.32", + "gatsby-source-filesystem": "^2.0.37", "gatsby-transformer-json": "^2.1.11", "gatsby-transformer-sharp": "^2.1.18", "gatsby-transformer-yaml": "^2.1.12", "giphy-js-sdk-core": "^1.0.6", - "graphql": "^14.2.1", + "graphql": "^14.3.1", "intersection-observer": "^0.7.0", "js-yaml": "^3.13.1", "node-sass": "^4.12.0", @@ -56,9 +56,9 @@ "vcf": "^2.0.4" }, "devDependencies": { - "@babel/core": "^7.4.4", - "@babel/node": "^7.2.2", - "@babel/preset-env": "^7.4.4", + "@babel/core": "^7.4.5", + "@babel/node": "^7.4.5", + "@babel/preset-env": "^7.4.5", "@svgr/webpack": "^4.2.0", "babel-eslint": "^10.0.1", "babel-jest": "^24.7.1", @@ -69,15 +69,16 @@ "eslint-plugin-graphql": "^3.0.3", "eslint-plugin-prettier": "^3.0.1", "eslint-plugin-react": "^7.12.4", + "eslint-plugin-react-hooks": "^1.6.0", "identity-obj-proxy": "^3.0.0", "jest": "^24.7.1", "jest-canvas-mock": "^2.0.0", - "jest-dom": "^3.1.3", + "jest-dom": "^3.4.0", "ora": "^3.4.0", "prepend": "^1.0.2", "prettier": "^1.17.0", "prettier-stylelint": "^0.4.2", - "react-testing-library": "^7.0.0", + "react-testing-library": "^7.0.1", "slugify": "^1.3.4", "stylelint": "^10.0.1", "stylelint-config-css-modules": "^1.3.0", diff --git a/src/store/AppProvider.jsx b/src/store/AppProvider.jsx index 76cebaa..dd659d0 100644 --- a/src/store/AppProvider.jsx +++ b/src/store/AppProvider.jsx @@ -8,7 +8,7 @@ export default class AppProvider extends PureComponent { state = { dark: false, toggleDark: () => this.toggleDark, - location: null + geolocation: null } static propTypes = { @@ -21,8 +21,8 @@ export default class AppProvider extends PureComponent { async componentDidMount() { this.mounted = true - const location = await getCountry() - this.setState({ location }) + const geolocation = await getCountry() + this.setState({ geolocation }) this.checkDark() } @@ -46,8 +46,8 @@ export default class AppProvider extends PureComponent { // All the checks to see if we should go dark or light // async checkTimes() { - const { location, dark } = this.state - const { sunset, sunrise } = await getLocationTimes(location) + const { geolocation, dark } = this.state + const { sunset, sunrise } = await getLocationTimes(geolocation) const now = new Date().getHours() const weWantItDarkTimes = now >= sunset || now <= sunrise