From 837b8d77df59d4bcc776f5d8808a4bd0ee554577 Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Sat, 5 Jan 2019 12:27:13 -0500 Subject: [PATCH] Updating eslint rules and addressing issues --- .eslintrc.json | 40 +++++++++++++++++++++++++++ gatsby-config.js | 4 ++- src/components/Footer/index.js | 8 ++++-- src/components/Header/index.js | 8 ++++-- src/components/Message/index.js | 5 +++- src/components/SentryBoundary/test.js | 8 ++++-- src/components/SentryError/index.js | 3 +- src/components/SentryError/test.js | 4 +-- src/pages/index.js | 3 +- src/pages/privacy.js | 39 ++++++++++++++++++++++---- 10 files changed, 104 insertions(+), 18 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 6a8dfc6..2fde1cf 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -23,6 +23,27 @@ "jest" ], "rules": { + "arrow-parens": [ + "error", + "as-needed" + ], + "arrow-spacing": [ + "error", + { + "before": true, + "after": true + } + ], + "comma-dangle": [ + "error", + { + "objects": "never", + "arrays": "never", + "imports": "never", + "exports": "never", + "functions": "never" + } + ], "indent": [ "error", 2 @@ -31,6 +52,13 @@ "error", "unix" ], + "max-len": [ + "warn", + { + "code": 80 + } + ], + "no-var": "error", "quotes": [ "error", "single" @@ -38,6 +66,18 @@ "semi": [ "error", "always" + ], + "space-before-function-paren": [ + "error", + { + "named": "never", + "anonymous": "never", + "asyncArrow": "always" + } + ], + "template-curly-spacing": [ + "error", + "always" ] }, "settings": { diff --git a/gatsby-config.js b/gatsby-config.js index 4ed2f98..d490d09 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -2,7 +2,9 @@ const buildId = [ process.env.CI_COMMIT_REF_SLUG || 'prerelese', (process.env.CI_COMMIT_SHA || 'gitsha').slice(0, 7) ].join('-'); -const banner = (process.env.NODE_ENV === 'production') ? false : (process.env.NODE_ENV || 'development'); +const banner = (process.env.NODE_ENV === 'production') + ? false + : (process.env.NODE_ENV || 'development'); module.exports = { siteMetadata: { diff --git a/src/components/Footer/index.js b/src/components/Footer/index.js index 56256d6..a0ef4c1 100644 --- a/src/components/Footer/index.js +++ b/src/components/Footer/index.js @@ -21,8 +21,12 @@ export const FooterImpl = ({ site: { siteMetadata } }) => ( Created by Jeff Avallone
  • - Generated images licensed: - Creative Commons CC-BY-3.0 License + Generated images licensed: + Creative Commons CC-BY-3.0 License
  • diff --git a/src/components/Header/index.js b/src/components/Header/index.js index ce9c80e..506e42b 100644 --- a/src/components/Header/index.js +++ b/src/components/Header/index.js @@ -17,14 +17,18 @@ const query = graphql` `; export const HeaderImpl = ({ site: { siteMetadata } }) => ( -
    +

    Regexper

    • - + Source on GitLab diff --git a/src/components/Message/index.js b/src/components/Message/index.js index 69b5cb4..c59164b 100644 --- a/src/components/Message/index.js +++ b/src/components/Message/index.js @@ -24,7 +24,10 @@ const renderIcon = (type, icon) => { }; const Message = ({ type, icon, heading, children }) => ( -
      +
      { renderIcon(type, icon) }

      { heading }

      diff --git a/src/components/SentryBoundary/test.js b/src/components/SentryBoundary/test.js index 6d05208..e654e22 100644 --- a/src/components/SentryBoundary/test.js +++ b/src/components/SentryBoundary/test.js @@ -27,9 +27,13 @@ describe('SentryBoundary', () => { const error = new Error('Example error'); component.find('Child').simulateError(error); - component.setState({ hasError: true }); // NOTE: Enzyme doesn't call getDerivedStateFromError yet + // NOTE: Enzyme doesn't call getDerivedStateFromError yet, so we have to + // set the state manually + component.setState({ hasError: true }); - expect(Sentry.captureException).toHaveBeenCalledWith(error, expect.anything()); + expect(Sentry.captureException).toHaveBeenCalledWith( + error, + expect.anything()); expect(component).toMatchSnapshot(); }); }); diff --git a/src/components/SentryError/index.js b/src/components/SentryError/index.js index 3d72753..3fb414e 100644 --- a/src/components/SentryError/index.js +++ b/src/components/SentryError/index.js @@ -14,7 +14,8 @@ class SentryError extends React.Component { render() { return -

      This error has been logged. You may also fill out a report.

      +

      This error has been logged. You may also fill out a report.

      ; } } diff --git a/src/components/SentryError/test.js b/src/components/SentryError/test.js index d557df0..e01611a 100644 --- a/src/components/SentryError/test.js +++ b/src/components/SentryError/test.js @@ -15,7 +15,7 @@ describe('SentryError', () => { }); describe('error reporting', () => { - test('clicking to fill out a report when an event has been logged', () => { + test('fill out a report when an event has been logged', () => { Sentry.lastEventId.mockReturnValue(1); const component = shallow( @@ -27,7 +27,7 @@ describe('SentryError', () => { expect(Sentry.showReportDialog).toHaveBeenCalled(); }); - test('clicking to fill out a report when an event has not been logged', () => { + test('fill out a report when an event has not been logged', () => { Sentry.lastEventId.mockReturnValue(false); const component = shallow( diff --git a/src/pages/index.js b/src/pages/index.js index 5e8b2cc..6d48ffe 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -8,7 +8,8 @@ const IndexPage = () =>
      Hello world
      diff --git a/src/pages/privacy.js b/src/pages/privacy.js index 9df604f..3b67fe1 100644 --- a/src/pages/privacy.js +++ b/src/pages/privacy.js @@ -5,14 +5,41 @@ import Message from 'components/Message'; const PrivacyPage = () => -

      Regexper and the tools used to create it are all open source. If you are concerned that the JavaScript being delivered is in any way malicious, please inspect the source in the GitLab repository.

      -

      There are two data collection tools integrated in the app. These tools are not used to collect personal information:

      +

      + Regexper and the tools used to create it are all open source. If you are + concerned that the JavaScript being delivered is in any way malicious, + please inspect the source in the GitLab repository. +

      +

      + There are two data collection tools integrated in the app. These tools + are not used to collect personal information: +

        -
      • Google Analytics is used to track browser usage data and application performance. It is configured to anonymize the client IP address.
      • -
      • Sentry.io is a tool used to capture and report client-side JavaScript errors. It is configured to not store the client IP address.
      • +
      • + Google Analytics is used to track browser usage data and + application performance. It is configured to anonymize the client IP + address. +
      • +
      • + Sentry.io is a tool used to capture and report client-side + JavaScript errors. It is configured to not store the client IP address. +
      -

      Regexper honors the browser “Do Not Track” setting and will not enable these data collection tools if that setting is enabled. Also, most popular ad blockers will prevent these tools from sending any tracking data. Disabling or blocking these data collection tools will not impact the performance of this app. The information collected by these tools is used to monitor application performance, determine browser support, and collect error reports.

      -

      Regexper is not supported by ad revenue or sales of any kind.

      +

      + Regexper honors the browser “Do Not Track” setting and + will not enable these data collection tools if that setting is enabled. + Also, most popular ad blockers will prevent these tools from sending any + tracking data. Disabling or blocking these data collection tools + will not impact the performance of this app. The information + collected by these tools is used to monitor application performance, + determine browser support, and collect error reports. +

      +

      + Regexper is not supported by ad revenue or sales of any kind. +

      ;