feat(ui): add eslint rules

- `curly` requires conditionals to use curly braces
- `react/jsx-curly-brace-presence` requires string props to *not* have curly braces
- `react-memo/require-memo` requires function components to be wrapped in `memo`
- `react-memo/require-usememo` requires all complex props (objects, functions) to be wrapped in `useMemo` or `useCallback`
This commit is contained in:
psychedelicious 2023-08-16 12:31:33 +10:00
parent 611e241ca7
commit a7606901f3
3 changed files with 14 additions and 1 deletions

View File

@ -20,9 +20,16 @@ module.exports = {
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: ['react', '@typescript-eslint', 'eslint-plugin-react-hooks'],
plugins: ['react', '@typescript-eslint', 'react-hooks', 'react-memo'],
root: true,
rules: {
curly: 'error',
'react-memo/require-memo': 'error',
'react-memo/require-usememo': 'error',
'react/jsx-curly-brace-presence': [
'error',
{ props: 'never', children: 'never' },
],
'react-hooks/exhaustive-deps': 'error',
'no-var': 'error',
'brace-style': 'error',

View File

@ -76,6 +76,7 @@
"chakra-ui-contextmenu": "^1.0.5",
"dateformat": "^5.0.3",
"downshift": "^7.6.0",
"eslint-plugin-react-memo": "^0.0.3",
"formik": "^2.4.2",
"framer-motion": "^10.12.17",
"fuse.js": "^6.6.2",

View File

@ -3557,6 +3557,11 @@ eslint-plugin-react-hooks@^4.6.0:
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz#4c3e697ad95b77e93f8646aaa1630c1ba607edd3"
integrity sha512-oFc7Itz9Qxh2x4gNHStv3BqJq54ExXmfC+a1NjAta66IAN87Wu0R/QArgIS9qKzX3dXKPI9H5crl9QchNMY9+g==
eslint-plugin-react-memo@^0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/eslint-plugin-react-memo/-/eslint-plugin-react-memo-0.0.3.tgz#26542aa2eeabed37f354c64c6b4eabc07051cf78"
integrity sha512-IZzLDZJF4V84XL9+v74ypDSts/hAQtNeYFZGc3wvdX+YgIw4pkn4GiXPJ6MNUccNTPYJqr89Nnvqo3rcesEBOQ==
eslint-plugin-react@^7.32.2:
version "7.32.2"
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.32.2.tgz#e71f21c7c265ebce01bcbc9d0955170c55571f10"