Skip to content

Commit

Permalink
chore: add eslint rule for React hooks (#666)
Browse files Browse the repository at this point in the history
  • Loading branch information
TCL735 authored Sep 1, 2021
1 parent 90450b8 commit 36cf48b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 28 deletions.
51 changes: 26 additions & 25 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,49 @@
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"prettier/react",
"prettier/@typescript-eslint"
"plugin:react-hooks/recommended",
"plugin:react/recommended",
"prettier/@typescript-eslint",
"prettier/react"
],
"settings": {
"react": {
"version": "16.5"
}
},
"rules": {
"curly": ["error", "all"],
"no-console": ["error", {"allow": ["warn", "error"]}],
"no-empty": "off",
"getter-return": "off",
"no-extra-boolean-cast": "off",
"no-case-declarations": "off",
"no-useless-escape": "off",
"no-undef": "off",
"no-fallthrough": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/array-type": "off",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-object-literal-type-assertion": "off",
"@typescript-eslint/array-type": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/prefer-interface": "off",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-object-literal-type-assertion": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{"varsIgnorePattern": "^_", "argsIgnorePattern": "^_"}
],
"react/jsx-no-target-blank": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/prefer-interface": "off",
"curly": ["error", "all"],
"getter-return": "off",
"no-case-declarations": "off",
"no-console": ["error", {"allow": ["warn", "error"]}],
"no-empty": "off",
"no-extra-boolean-cast": "off",
"no-fallthrough": "off",
"no-undef": "off",
"no-useless-escape": "off",
"react/display-name": "off",
"react/no-unescaped-entities": "off",
"react/prop-types": "off",
"react/jsx-no-target-blank": "off",
"react/jsx-uses-react": "error",
"react/no-find-dom-node": "off",
"react/jsx-uses-react": "error"
"react/no-unescaped-entities": "off",
"react/prop-types": "off"
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"eslint-config-prettier": "^6.5.0",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-react": "^7.19.0",
"eslint-plugin-react-hooks": "^4.2.0",
"file-loader": "^3.0.1",
"html-loader": "^0.5.5",
"husky": "^4.2.5",
Expand Down
10 changes: 7 additions & 3 deletions src/Components/Popover/Documentation/Popover.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -516,16 +516,20 @@ testPopoverStories.add('Popover + Autofocus Child', () => {

testPopoverStories.add('200 Popovers + Filtering', () => {
const [searchTerm, updateSearchTerm] = useState<string>('')
const popovers = []
const words = []
const dictionary = getDictionary()

for (let i = 0; i < 200; i++) {
popovers.push({
triggerRef: useRef<ButtonRef>(null),
words.push({
name: dictionary[i],
})
}

const popovers = words.map(word => ({
name: word.name,
triggerRef: useRef<ButtonRef>(null),
}))

const handleInputChange = (e: ChangeEvent<InputRef>): void => {
updateSearchTerm(e.target.value)
}
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7203,6 +7203,11 @@ eslint-plugin-prettier@^3.1.1:
dependencies:
prettier-linter-helpers "^1.0.0"

eslint-plugin-react-hooks@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.2.0.tgz#8c229c268d468956334c943bb45fc860280f5556"
integrity sha512-623WEiZJqxR7VdxFCKLI6d6LLpwJkGPYKODnkH3D7WpOG5KM8yWueBd8TLsNAetEJNF5iJmolaAKO3F8yzyVBQ==

eslint-plugin-react@^7.19.0:
version "7.19.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.19.0.tgz#6d08f9673628aa69c5559d33489e855d83551666"
Expand Down

0 comments on commit 36cf48b

Please sign in to comment.