Skip to content

Commit

Permalink
Re-enabled React hooks ESLint plugin (#172)
Browse files Browse the repository at this point in the history
* Re-enabled React hooks ESLint plugin

* Fixed lint error
  • Loading branch information
jwngr authored Sep 25, 2024
1 parent 1eae7b1 commit f4e9e28
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 27 deletions.
23 changes: 0 additions & 23 deletions website/.eslintrc

This file was deleted.

7 changes: 5 additions & 2 deletions website/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import eslint from '@eslint/js';
// TODO: Add back `eslint-plugin-react-hooks once it supports the ESLint flat file format.
// import reactHooks from 'eslint-plugin-react-hooks';
import reactHooks from 'eslint-plugin-react-hooks';
import globals from 'globals';
import tseslint from 'typescript-eslint';

Expand All @@ -21,9 +20,13 @@ export default tseslint.config(
sourceType: 'module',
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
},
rules: {
'no-console': 'error',
'@typescript-eslint/no-extraneous-class': 'off',
...reactHooks.configs.recommended.rules,
},
}
);
14 changes: 14 additions & 0 deletions website/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@types/react-router-dom": "^5.3.3",
"@vitejs/plugin-react": "^4.3.1",
"eslint": "^9.9.0",
"eslint-plugin-react-hooks": "^5.1.0-rc-f9ebd85a-20240925",
"globals": "^15.9.0",
"prettier": "^3.3.3",
"source-map-explorer": "^2.1.0",
Expand Down
4 changes: 2 additions & 2 deletions website/src/components/PageInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import debounce from 'lodash/debounce';
import filter from 'lodash/filter';
import forEach from 'lodash/forEach';
import get from 'lodash/get';
import React, {useCallback, useEffect, useState} from 'react';
import React, {useCallback, useEffect, useMemo, useState} from 'react';
import Autosuggest from 'react-autosuggest';
import styled from 'styled-components';

Expand Down Expand Up @@ -172,7 +172,7 @@ export const PageInput: React.FC<{
}
}, []);

const debouncedLoadSuggestions = useCallback(debounce(loadSuggestions, 300), [loadSuggestions]);
const debouncedLoadSuggestions = useMemo(() => debounce(loadSuggestions, 300), [loadSuggestions]);

return (
<AutosuggestWrapper>
Expand Down

0 comments on commit f4e9e28

Please sign in to comment.