From f0a752f555ec22ea19cd5e4e51375f3b72740f3f Mon Sep 17 00:00:00 2001 From: Manu Ramirez Date: Wed, 3 Mar 2021 16:46:37 -0600 Subject: [PATCH 1/5] chore(FDS-147) - fix eslint errors for 'react/prop-types' and react/forbid-prop-types' --- .eslintrc.js | 13 ------------- docs/src/components/Code/Code.js | 8 ++++---- docs/src/lib/MDX_COMPONENTS.js | 2 +- .../cascara/src/modules/ModuleError/ModuleError.js | 3 +-- packages/cascara/src/ui/Chat/ChatProvider.js | 6 +++++- .../cascara/src/ui/Form/context/FormProvider.js | 3 +-- packages/cascara/src/ui/Pagination/Pagination.js | 10 ++++------ 7 files changed, 16 insertions(+), 29 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 29efa2f03..458efaef3 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -12,17 +12,4 @@ module.exports = { }, ], root: true, - rules: { - // TODO: Remove each of these lines below until there are 10 files with errors and resolve with --fix or manually, then submit a PR and repeat - 'consistent-return': 0, - 'eslint-comments/disable-enable-pair': 0, - 'eslint-comments/no-unused-disable': 0, - 'eslint-comments/require-description': 0, - 'jest/no-done-callback': 0, - 'react/jsx-key': 0, - 'react/jsx-no-bind': 0, - 'react/no-unknown-property': 0, - 'sort-imports': 0, - 'sort-keys': 0, - }, }; diff --git a/docs/src/components/Code/Code.js b/docs/src/components/Code/Code.js index fd1e7c7ab..c95fafa0c 100644 --- a/docs/src/components/Code/Code.js +++ b/docs/src/components/Code/Code.js @@ -25,16 +25,16 @@ const Code = ({ children, className, live = true, title, ...rest }) => { const [editorCode, setEditorCode] = useState(children.trim()); - const handleEditorToggle = () => { + function handleEditorToggle() { // TODO: Make cursor focus on editor when opening // should also update styles for focus on editor so it is easier to see that it // is actually editable setEditorOpen(!editorOpen); - }; + } - const handleCodeChange = (code) => { + function handleCodeChange(code) { setEditorCode(code.trim()); - }; + } useEffect(() => { setEditorCode(children.trim()); diff --git a/docs/src/lib/MDX_COMPONENTS.js b/docs/src/lib/MDX_COMPONENTS.js index 242db2365..fa4b39df7 100644 --- a/docs/src/lib/MDX_COMPONENTS.js +++ b/docs/src/lib/MDX_COMPONENTS.js @@ -29,7 +29,7 @@ import { import { Asciagram, Code, Placeholder } from '../components'; -/* eslint-disable react/display-name, react/no-multi-comp -- We need to do this in order to get all of our components into MDX */ +/* eslint-disable eslint-comments/disable-enable-pair, react/display-name, react/no-multi-comp -- We need to do this in order to get all of our components into MDX */ const docsComponents = { Asciagram: (props) => , Playground: (props) => , diff --git a/packages/cascara/src/modules/ModuleError/ModuleError.js b/packages/cascara/src/modules/ModuleError/ModuleError.js index a9bce5c85..1e254cdca 100644 --- a/packages/cascara/src/modules/ModuleError/ModuleError.js +++ b/packages/cascara/src/modules/ModuleError/ModuleError.js @@ -4,7 +4,6 @@ import styles from '../DataModule.module.scss'; const propTypes = { moduleName: pt.string.isRequired, - // eslint-disable-next-line react/forbid-prop-types -- We do not know what the object params might be in this case moduleOptions: pt.arrayOf(pt.object).isRequired, }; @@ -12,7 +11,7 @@ const ModuleError = ({ moduleName, moduleOptions }) => { const message = `${moduleName} is not a valid value for module. Try using one of [${moduleOptions.join( ', ' )}]`; - // eslint-disable-next-line no-console + // eslint-disable-next-line no-console -- we need to display this error to develop console.error(message); return ( diff --git a/packages/cascara/src/ui/Chat/ChatProvider.js b/packages/cascara/src/ui/Chat/ChatProvider.js index bd8894366..cbfe072b0 100644 --- a/packages/cascara/src/ui/Chat/ChatProvider.js +++ b/packages/cascara/src/ui/Chat/ChatProvider.js @@ -72,6 +72,10 @@ const propTypes = { const ChatProvider = ({ children, inputComponent, isThemeSelectable }) => { const [theme, setTheme] = useState(items[DEFAULT_THEME_INDEX].value); + function handleDropdownChange(e, data) { + setTheme(data.value.value); + } + return ( @@ -83,7 +87,7 @@ const ChatProvider = ({ children, inputComponent, isThemeSelectable }) => { items={items.map((option) => ({ ...option, }))} - onChange={(e, data) => setTheme(data.value.value)} + onChange={handleDropdownChange} placeholder='Select a theme' /> diff --git a/packages/cascara/src/ui/Form/context/FormProvider.js b/packages/cascara/src/ui/Form/context/FormProvider.js index b79a5687f..53d9bd23a 100644 --- a/packages/cascara/src/ui/Form/context/FormProvider.js +++ b/packages/cascara/src/ui/Form/context/FormProvider.js @@ -15,8 +15,7 @@ const FormProvider = ({ children, value, ...props }) => { const { handleSubmit } = formMethods; const onSubmit = (data) => { - // eslint-disable-next-line no-console - console.table(data); + return data; }; const mergedValues = { diff --git a/packages/cascara/src/ui/Pagination/Pagination.js b/packages/cascara/src/ui/Pagination/Pagination.js index d77ebb221..19de8d4a4 100644 --- a/packages/cascara/src/ui/Pagination/Pagination.js +++ b/packages/cascara/src/ui/Pagination/Pagination.js @@ -53,7 +53,7 @@ const Pagination = ({ // @param {Object} component Component object passed by SUIR // @param {String} component.name The name of the component // @param {Any} component.value The new value in the component - const handlePaginationChange = (_, component) => { + function handlePaginationChange(_, component) { let newPage = currentPage; let newitemsPerPageLimit = itemsPerPageLimit; @@ -74,7 +74,7 @@ const Pagination = ({ limit: newitemsPerPageLimit, page: newPage, }); - }; + } // // Handles button's click event @@ -85,7 +85,7 @@ const Pagination = ({ // @param {Event} _ Usually the click event // @param {Object} component Component object passed by SUIR // @param {String} component.name The name of the component - const handleButtonClick = (_, button) => { + function handleButtonClick(_, button) { let newPage = currentPage; if (button.name === 'forward') { @@ -98,7 +98,7 @@ const Pagination = ({ name: 'page', value: newPage, }); - }; + } const availablePages = Math.ceil(recordCount / itemsPerPageLimit) || 1; const canGoForward = currentPage < availablePages; @@ -137,7 +137,6 @@ const Pagination = ({ })); const itemsPerPageLimitSelect = () => ( - // eslint-disable-next-line jsx-a11y/label-has-for