From de3bd87f4b3c5d370fe97e7eb65ef673e002404b Mon Sep 17 00:00:00 2001 From: jxom Date: Tue, 10 Oct 2017 08:41:44 +1100 Subject: [PATCH] Added fbjs eslint config, fixed lint errors and warnings --- .eslintrc | 7 +++++-- package.json | 6 +++++- .../StickyResponsiveSidebar/StickyResponsiveSidebar.js | 4 +++- src/html.js | 2 +- src/templates/components/MetaTitle/index.js | 4 +++- src/templates/components/Sidebar/Section.js | 1 + src/utils/isItemActive.js | 5 ++--- 7 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.eslintrc b/.eslintrc index 28d87f00..a51454ef 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,13 +1,16 @@ { "extends": [ - "eslint:recommended", - "plugin:react/recommended" + "fbjs" ], "plugins": [ "prettier", "react" ], "parser": "babel-eslint", + "rules": { + "relay/graphql-naming": 0, + "max-len": 0 + }, "env": { "node": true, "browser": true diff --git a/package.json b/package.json index 8541b89c..1d214c9f 100644 --- a/package.json +++ b/package.json @@ -16,10 +16,14 @@ "array-from": "^2.1.1", "babel-eslint": "^8.0.1", "eslint": "^4.8.0", + "eslint-config-fbjs": "^2.0.0", "eslint-config-react": "^1.1.7", - "eslint-plugin-flowtype": "^2.37.0", + "eslint-plugin-babel": "^4.1.2", + "eslint-plugin-flowtype": "^2.39.1", + "eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-prettier": "^2.3.1", "eslint-plugin-react": "^7.4.0", + "eslint-plugin-relay": "^0.0.19", "flow-bin": "^0.56.0", "gatsby": "^1.9.9", "gatsby-link": "^1.6.9", diff --git a/src/components/StickyResponsiveSidebar/StickyResponsiveSidebar.js b/src/components/StickyResponsiveSidebar/StickyResponsiveSidebar.js index d92e6ab9..d2981de3 100644 --- a/src/components/StickyResponsiveSidebar/StickyResponsiveSidebar.js +++ b/src/components/StickyResponsiveSidebar/StickyResponsiveSidebar.js @@ -147,7 +147,9 @@ class StickyResponsiveSidebar extends Component { boxShadow: '0 0 20px rgba(0, 0, 0, 0.3)', [media.lessThan('small')]: smallScreenBottomBarStyles, }} - onClick={this._openNavMenu}> + onClick={this._openNavMenu} + role="button" + tabIndex="-1">
+ }} + role="link" + tabIndex="-1"> {children}
); diff --git a/src/templates/components/Sidebar/Section.js b/src/templates/components/Sidebar/Section.js index 83b9917c..517a89dd 100644 --- a/src/templates/components/Sidebar/Section.js +++ b/src/templates/components/Sidebar/Section.js @@ -9,6 +9,7 @@ 'use strict'; +import React from 'react'; import {colors, media} from 'theme'; import isItemActive from 'utils/isItemActive'; import MetaTitle from '../MetaTitle'; diff --git a/src/utils/isItemActive.js b/src/utils/isItemActive.js index d5e501cd..ad0dfe11 100644 --- a/src/utils/isItemActive.js +++ b/src/utils/isItemActive.js @@ -26,10 +26,9 @@ const isItemActive = (location, item) => { } } else if (item.id.includes('html')) { return location.pathname.includes(item.id); - } else { - const slugId = location.pathname.split('/').slice(-1)[0]; - return slugId === slugify(item.id); } + const slugId = location.pathname.split('/').slice(-1)[0]; + return slugId === slugify(item.id); }; export default isItemActive;