Skip to content

Commit a537d4e

Browse files
committed
fix: minor fixes
1 parent cf52cdb commit a537d4e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

packages/plugins/eslint-plugin-react-hooks-extra/src/rules/no-direct-set-state-in-use-effect.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ export default createRule<[], MessageID>({
5353
});
5454

5555
export function create(context: RuleContext<MessageID, []>): RuleListener {
56-
57-
const getText = (n: TSESTree.Node) => context.sourceCode.getText(n);
56+
if (!/use\w*Effect/u.test(context.sourceCode.text)) return {};
5857

5958
const functionEntries: { kind: FunctionKind; node: AST.TSESTreeFunction }[] = [];
6059

@@ -67,6 +66,8 @@ export function create(context: RuleContext<MessageID, []>): RuleListener {
6766
const setStateInEffectSetup = new Map<TSESTree.CallExpression, TSESTree.Identifier[]>();
6867
const setStateInHookCallbacks = new WeakMap<TSESTree.Node, TSESTree.CallExpression[]>();
6968

69+
const getText = (n: TSESTree.Node) => context.sourceCode.getText(n);
70+
7071
const onSetupFunctionEnter = (node: AST.TSESTreeFunction) => {
7172
setupFnRef.current = node;
7273
};

packages/plugins/eslint-plugin/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ export default defineConfig([
167167

168168
Contributions are welcome!
169169

170-
Please follow our [contributing guidelines](https://github.com/Rel1cx/eslint-react/tree/feat/use-no-direct-set-state-in-use-layout-effect/.github/CONTRIBUTING.md).
170+
Please follow our [contributing guidelines](https://github.com/Rel1cx/eslint-react/tree/rework/hooks-rules/.github/CONTRIBUTING.md).
171171

172172
## License
173173

174-
This project is licensed under the MIT License - see the [LICENSE](https://github.com/Rel1cx/eslint-react/tree/feat/use-no-direct-set-state-in-use-layout-effect/LICENSE) file for details.
174+
This project is licensed under the MIT License - see the [LICENSE](https://github.com/Rel1cx/eslint-react/tree/rework/hooks-rules/LICENSE) file for details.

0 commit comments

Comments
 (0)