diff --git a/.eslintrc.js b/.eslintrc.js index 05b2937fd..278ed31c2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -10,6 +10,9 @@ module.exports = { rules: { semi: [2, 'never'], 'jsx-a11y/href-no-hash': ['off'], + 'react/prop-types': ['off'], + 'react/jsx-props-no-spreading': ['off'], + 'react/no-danger': ['off'], 'react/jsx-filename-extension': ['warn', { extensions: ['.js', '.jsx'] }], 'max-len': [ 'warn', diff --git a/README.md b/README.md index ba8d0cda0..bb7d74f54 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ gatsby develop The site is now running at `http://localhost:8000`. Any changes you make to code is live-updated. There is a GraphQL preview tool available at `http://localhost:8000/___graphql` to see what data is exposed to the website. +Note that any changes you make while running Gatsby will automatically checked with [ESLint](https://eslint.org/), so check your console as you save files. + ## Storybook All common components throughout the site are documented in [Storybook](https://storybook.js.org/). You can find all our component stories in `/src/stories`. diff --git a/gatsby-config.js b/gatsby-config.js index 5a7bc6029..167f6ee41 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -25,34 +25,35 @@ module.exports = { }, }, plugins: [ - `gatsby-plugin-react-helmet`, - `gatsby-plugin-sass`, - `gatsby-plugin-mdx`, - `gatsby-transformer-yaml`, + 'gatsby-plugin-react-helmet', + 'gatsby-plugin-sass', + 'gatsby-plugin-mdx', + 'gatsby-transformer-yaml', + 'gatsby-plugin-eslint', { - resolve: `gatsby-transformer-remark`, + resolve: 'gatsby-transformer-remark', options: { - plugins: [`gatsby-remark-autolink-headers`], + plugins: ['gatsby-remark-autolink-headers'], }, }, { - resolve: `gatsby-source-filesystem`, + resolve: 'gatsby-source-filesystem', options: { - name: `content`, + name: 'content', path: `${__dirname}/src/content/pages/`, }, }, { - resolve: `gatsby-source-filesystem`, + resolve: 'gatsby-source-filesystem', options: { - name: `snippets`, + name: 'snippets', path: `${__dirname}/src/content/snippets/`, }, }, { - resolve: `gatsby-source-filesystem`, + resolve: 'gatsby-source-filesystem', options: { - name: `navigation`, + name: 'navigation', path: `${__dirname}/src/data/navigation`, }, }, @@ -61,7 +62,7 @@ module.exports = { options: { typePrefix: 'covid__', name: 'state', - url: `https://covidtracking.com/api/states`, + url: 'https://covidtracking.com/api/states', }, }, { @@ -69,7 +70,7 @@ module.exports = { options: { typePrefix: 'covid__', name: 'stateInfo', - url: `https://covidtracking.com/api/states/info`, + url: 'https://covidtracking.com/api/states/info', }, }, { @@ -77,7 +78,7 @@ module.exports = { options: { typePrefix: 'covid__', name: 'stateDaily', - url: `https://covidtracking.com/api/states/daily`, + url: 'https://covidtracking.com/api/states/daily', }, }, { @@ -85,7 +86,7 @@ module.exports = { options: { typePrefix: 'covid__', name: 'us', - url: `https://covidtracking.com/api/us`, + url: 'https://covidtracking.com/api/us', }, }, { @@ -93,7 +94,7 @@ module.exports = { options: { typePrefix: 'covid__', name: 'usDaily', - url: `https://covidtracking.com/api/us/daily`, + url: 'https://covidtracking.com/api/us/daily', }, }, { @@ -101,7 +102,7 @@ module.exports = { options: { typePrefix: 'covid__', name: 'screenshots', - url: `https://covidtracking.com/api/screenshots`, + url: 'https://covidtracking.com/api/screenshots', }, }, { @@ -109,19 +110,19 @@ module.exports = { options: { typePrefix: 'covid__', name: 'press', - url: `https://covidtracking.com/api/press`, + url: 'https://covidtracking.com/api/press', }, }, { - resolve: `gatsby-plugin-manifest`, + resolve: 'gatsby-plugin-manifest', options: { - name: `The COVID Tracking Project`, - short_name: `COVID Tracking Project`, - start_url: `/`, - background_color: `#ffffff`, - theme_color: `#ffffff`, - display: `minimal-ui`, - icon: `src/images/icons/icon-512.png`, // This path is relative to the root of the site. + name: 'The COVID Tracking Project', + short_name: 'COVID Tracking Project', + start_url: '/', + background_color: '#ffffff', + theme_color: '#ffffff', + display: 'minimal-ui', + icon: 'src/images/icons/icon-512.png', // This path is relative to the root of the site. }, }, ], diff --git a/package-lock.json b/package-lock.json index 1ae6e3559..ef1e04f28 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9307,6 +9307,45 @@ } } }, + "eslint-config-airbnb": { + "version": "18.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb/-/eslint-config-airbnb-18.1.0.tgz", + "integrity": "sha512-kZFuQC/MPnH7KJp6v95xsLBf63G/w7YqdPfQ0MUanxQ7zcKUNG8j+sSY860g3NwCBOa62apw16J6pRN+AOgXzw==", + "dev": true, + "requires": { + "eslint-config-airbnb-base": "^14.1.0", + "object.assign": "^4.1.0", + "object.entries": "^1.1.1" + } + }, + "eslint-config-airbnb-base": { + "version": "14.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-14.1.0.tgz", + "integrity": "sha512-+XCcfGyCnbzOnktDVhwsCAx+9DmrzEmuwxyHUJpw+kqBVT744OUBrB09khgFKlK1lshVww6qXGsYPZpavoNjJw==", + "dev": true, + "requires": { + "confusing-browser-globals": "^1.0.9", + "object.assign": "^4.1.0", + "object.entries": "^1.1.1" + } + }, + "eslint-config-prettier": { + "version": "6.10.1", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-6.10.1.tgz", + "integrity": "sha512-svTy6zh1ecQojvpbJSgH3aei/Rt7C6i090l5f2WQ4aB05lYHeZIR1qL4wZyyILTbtmnbHP5Yn8MrsOJMGa8RkQ==", + "dev": true, + "requires": { + "get-stdin": "^6.0.0" + }, + "dependencies": { + "get-stdin": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz", + "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==", + "dev": true + } + } + }, "eslint-config-react-app": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/eslint-config-react-app/-/eslint-config-react-app-5.2.1.tgz", @@ -9340,25 +9379,16 @@ } }, "eslint-loader": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/eslint-loader/-/eslint-loader-2.2.1.tgz", - "integrity": "sha512-RLgV9hoCVsMLvOxCuNjdqOrUqIj9oJg8hF44vzJaYqsAHuY9G2YAeN3joQ9nxP0p5Th9iFSIpKo+SD8KISxXRg==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/eslint-loader/-/eslint-loader-3.0.3.tgz", + "integrity": "sha512-+YRqB95PnNvxNp1HEjQmvf9KNvCin5HXYYseOXVC2U0KEcw4IkQ2IQEBG46j7+gW39bMzeu0GsUhVbBY3Votpw==", + "dev": true, "requires": { - "loader-fs-cache": "^1.0.0", - "loader-utils": "^1.0.2", - "object-assign": "^4.0.1", - "object-hash": "^1.1.4", - "rimraf": "^2.6.1" - }, - "dependencies": { - "rimraf": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", - "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", - "requires": { - "glob": "^7.1.3" - } - } + "fs-extra": "^8.1.0", + "loader-fs-cache": "^1.0.2", + "loader-utils": "^1.2.3", + "object-hash": "^2.0.1", + "schema-utils": "^2.6.1" } }, "eslint-module-utils": { @@ -9507,6 +9537,15 @@ "jsx-ast-utils": "^2.2.1" } }, + "eslint-plugin-prettier": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.2.tgz", + "integrity": "sha512-GlolCC9y3XZfv3RQfwGew7NnuFDKsfI4lbvRK+PIIo23SFH+LemGs4cKwzAaRa+Mdb+lQO/STaIayno8T5sJJA==", + "dev": true, + "requires": { + "prettier-linter-helpers": "^1.0.0" + } + }, "eslint-plugin-react": { "version": "7.19.0", "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.19.0.tgz", @@ -10179,6 +10218,12 @@ "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz", "integrity": "sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA==" }, + "fast-diff": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz", + "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==", + "dev": true + }, "fast-glob": { "version": "2.2.7", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-2.2.7.tgz", @@ -11435,6 +11480,18 @@ "ms": "^2.1.1" } }, + "eslint-loader": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/eslint-loader/-/eslint-loader-2.2.1.tgz", + "integrity": "sha512-RLgV9hoCVsMLvOxCuNjdqOrUqIj9oJg8hF44vzJaYqsAHuY9G2YAeN3joQ9nxP0p5Th9iFSIpKo+SD8KISxXRg==", + "requires": { + "loader-fs-cache": "^1.0.0", + "loader-utils": "^1.0.2", + "object-assign": "^4.0.1", + "object-hash": "^1.1.4", + "rimraf": "^2.6.1" + } + }, "gatsby-cli": { "version": "2.11.1", "resolved": "https://registry.npmjs.org/gatsby-cli/-/gatsby-cli-2.11.1.tgz", @@ -11529,11 +11586,24 @@ "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" }, + "object-hash": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-1.3.1.tgz", + "integrity": "sha512-OSuu/pU4ENM9kmREg0BdNrUDIl1heYa4mBZacJc+vVWz4GtAwu7jO8s4AIt2aGRUTqxykpWzI3Oqnsm13tTMDA==" + }, "require-main-filename": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=" }, + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "requires": { + "glob": "^7.1.3" + } + }, "strip-ansi": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", @@ -11664,6 +11734,11 @@ "micromatch": "^3.1.10" } }, + "gatsby-plugin-eslint": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/gatsby-plugin-eslint/-/gatsby-plugin-eslint-2.0.8.tgz", + "integrity": "sha512-vAMy37povmQJNg6ZxY78fkWR3pKwG8MNMhO3u+4vXj2MYT5avhFvHPJTAb126ZCuygf30gAWlpwbV50zP894Jw==" + }, "gatsby-plugin-manifest": { "version": "2.2.48", "resolved": "https://registry.npmjs.org/gatsby-plugin-manifest/-/gatsby-plugin-manifest-2.2.48.tgz", @@ -16593,9 +16668,10 @@ "integrity": "sha512-G+7LzpYfTfqUyrZlfrou/PLLLAPNC52FTy5y1CBywX+1/FkxIloOyQXBmZ3Zxa2AWO+lMF0JTuvqbr7G5e5CWg==" }, "object-hash": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-1.3.1.tgz", - "integrity": "sha512-OSuu/pU4ENM9kmREg0BdNrUDIl1heYa4mBZacJc+vVWz4GtAwu7jO8s4AIt2aGRUTqxykpWzI3Oqnsm13tTMDA==" + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-2.0.3.tgz", + "integrity": "sha512-JPKn0GMu+Fa3zt3Bmr66JhokJU5BaNBIh4ZeTlaCBzrBsOeXzwcKKAK1tbLiPKgvwmPXsDvvLHoWh5Bm7ofIYg==", + "dev": true }, "object-inspect": { "version": "1.7.0", @@ -18213,6 +18289,15 @@ "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", "dev": true }, + "prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "requires": { + "fast-diff": "^1.1.2" + } + }, "pretty-bytes": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.3.0.tgz", diff --git a/package.json b/package.json index 2443c8904..430b02918 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "@storybook/addon-info": "^5.3.17", "gatsby": "^2.19.45", "gatsby-image": "^2.2.44", + "gatsby-plugin-eslint": "^2.0.8", "gatsby-plugin-manifest": "^2.2.48", "gatsby-plugin-mdx": "^1.1.1", "gatsby-plugin-offline": "^3.0.41", @@ -41,6 +42,11 @@ "@storybook/addons": "^5.3.17", "@storybook/react": "^5.3.17", "babel-loader": "^8.1.0", + "eslint": "^6.8.0", + "eslint-config-airbnb": "^18.1.0", + "eslint-config-prettier": "^6.10.1", + "eslint-loader": "^3.0.3", + "eslint-plugin-prettier": "^3.1.2", "prettier": "^1.19.1" }, "keywords": [ diff --git a/src/components/common/button.js b/src/components/common/button.js index e04ce98bd..7e9962166 100644 --- a/src/components/common/button.js +++ b/src/components/common/button.js @@ -1,5 +1,4 @@ import React from 'react' -import PropTypes from 'prop-types' import { Link } from 'gatsby' const ButtonLink = ({ big, to, children }) => ( @@ -8,28 +7,16 @@ const ButtonLink = ({ big, to, children }) => ( ) -ButtonLink.propTypes = { - big: PropTypes.bool, - to: PropTypes.string, -} - const ButtonAnchor = ({ big, href, children }) => ( {children} ) -ButtonAnchor.propTypes = { - big: PropTypes.bool, - href: PropTypes.string, -} - const Button = ({ big, children }) => ( - + ) -Button.propTypes = { - big: PropTypes.bool, -} - export { ButtonAnchor, ButtonLink, Button } diff --git a/src/components/common/summary-table.js b/src/components/common/summary-table.js index 317dce060..687a23775 100644 --- a/src/components/common/summary-table.js +++ b/src/components/common/summary-table.js @@ -1,5 +1,5 @@ import React from 'react' -import Table from '../../components/common/table' +import Table from './table' import thousands from '../../utilities/format-thousands' export default ({ data }) => ( diff --git a/src/components/layout/footer.js b/src/components/layout/footer.js index dc9f6c9ab..c10f05b80 100644 --- a/src/components/layout/footer.js +++ b/src/components/layout/footer.js @@ -36,7 +36,7 @@ const Footer = () => ( navigation={data.allNavigationYaml.edges[0].node.items} /> )} - > + /> External links: