Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ export function useNoDirectSetStateInUseEffect<Ctx extends RuleContext>(
match(getCallKind(node))
.with("setState", () => {
switch (true) {
case pEntry.node === setupFunction
|| pEntry.kind === "immediate": {
case pEntry.node === setupFunction:
case pEntry.kind === "immediate"
&& AST.findParentNode(pEntry.node, AST.isFunction) === setupFunction: {
onViolation(context, node, {
name: context.sourceCode.getText(node.callee),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -785,5 +785,21 @@ ruleTester.run(RULE_NAME, rule, {
// ...use tooltipHeight in the rendering logic below...
}
`,
// https://github.com/Rel1cx/eslint-react/issues/967
/* tsx */ `
import { useEffect, useState, useCallback } from "react";

function useCustomHook() {
const [something, setSomething] = useState('');

const test = useCallback(() => {
setSomething('') // doesn't trigger the rules

;(() => {
setSomething('') // trigger the rules
})()
}, [])
}
`,
],
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ react-x/no-children-prop

## What it does

Disallows passing 'children' as a prop.
Disallows passing `children` as a prop.

Most of the time, `children` should be actual `children`, not passed in as a `prop`.

Expand Down