Skip to content

Commit

Permalink
eslint rule "Do not memorize primitives" for useMemo
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanSilke committed Nov 21, 2023
1 parent 0bac0f8 commit 2269824
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/eslint-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ module.exports = {
},
],

'no-restricted-syntax': ["error",
{
"selector": "CallExpression[callee.name = useMemo] :matches(ArrowFunctionExpression, ArrowFunctionExpression ReturnStatement, FunctionExpression ReturnStatement) :matches(TemplateLiteral[expressions.length = 0], TemplateLiteral > Identifier, TemplateLiteral > Literal)",
"message": "Do not memorize primitives https://dev.to/katekate/another-react-dos-and-donts-4ba0#:~:text=1.2.%20Avoid%20useMemo%20for%20primitive%20memoization."
},
{
"selector": "CallExpression[callee.name = useMemo] :matches(ArrowFunctionExpression, ArrowFunctionExpression ReturnStatement, FunctionExpression ReturnStatement) > Literal",
"message": "Do not memorize primitives https://dev.to/katekate/another-react-dos-and-donts-4ba0#:~:text=1.2.%20Avoid%20useMemo%20for%20primitive%20memoization."
},
],

'default-param-last': 'warn',

'@typescript-eslint/member-ordering': [
Expand Down

0 comments on commit 2269824

Please sign in to comment.