Skip to content

Commit 52bee82

Browse files
committed
refactor: improve variable utils
1 parent 44a8ad2 commit 52bee82

31 files changed

+234
-160
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.5.28
1+
1.5.29-next.0

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eslint-react/monorepo",
3-
"version": "1.5.28",
3+
"version": "1.5.29-next.0",
44
"private": true,
55
"description": "A series of composable ESLint rules for libraries and frameworks that use React as a UI runtime.",
66
"keywords": [

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eslint-react/core",
3-
"version": "1.5.28",
3+
"version": "1.5.29-next.0",
44
"description": "ESLint React's ESLint utility module for static analysis of React core APIs and Patterns.",
55
"homepage": "https://github.com/rel1cx/eslint-react",
66
"bugs": {

packages/plugins/eslint-plugin-react-debug/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-react-debug",
3-
"version": "1.5.28",
3+
"version": "1.5.29-next.0",
44
"description": "ESLint React's ESLint plugin for debugging related rules.",
55
"homepage": "https://github.com/rel1cx/eslint-react",
66
"bugs": {

packages/plugins/eslint-plugin-react-dom/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-react-dom",
3-
"version": "1.5.28",
3+
"version": "1.5.29-next.0",
44
"description": "ESLint React's ESLint plugin for React DOM related rules.",
55
"homepage": "https://github.com/rel1cx/eslint-react",
66
"bugs": {

packages/plugins/eslint-plugin-react-dom/src/rules/no-dangerously-set-innerhtml-with-children.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { is, isOneOf, NodeType } from "@eslint-react/ast";
22
import { isCreateElementCall } from "@eslint-react/core";
33
import { findPropInProperties, hasProp, isLineBreak } from "@eslint-react/jsx";
44
import { F, O, Pred } from "@eslint-react/tools";
5-
import { findVariable, getVariableInit } from "@eslint-react/var";
5+
import { findVariable, getVariableNode } from "@eslint-react/var";
66
import type { TSESTree } from "@typescript-eslint/types";
77
import type { ESLintUtils } from "@typescript-eslint/utils";
88
import type { ConstantCase } from "string-ts";
@@ -49,7 +49,7 @@ export default createRule<[], MessageID>({
4949

5050
return F.pipe(
5151
findVariable(n.name, initialScope),
52-
O.flatMap(getVariableInit(0)),
52+
O.flatMap(getVariableNode(0)),
5353
O.flatMap((n) => "properties" in n ? O.fromNullable(n.properties) : O.none()),
5454
);
5555
})

packages/plugins/eslint-plugin-react-dom/src/rules/no-dangerously-set-innerhtml.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { is, isOneOf, NodeType } from "@eslint-react/ast";
22
import { isCreateElementCall } from "@eslint-react/core";
33
import { findPropInAttributes, findPropInProperties } from "@eslint-react/jsx";
44
import { F, O } from "@eslint-react/tools";
5-
import { findVariable, getVariableInit } from "@eslint-react/var";
5+
import { findVariable, getVariableNode } from "@eslint-react/var";
66
import type { ESLintUtils } from "@typescript-eslint/utils";
77
import type { ConstantCase } from "string-ts";
88
import { match } from "ts-pattern";
@@ -41,7 +41,7 @@ export default createRule<[], MessageID>({
4141

4242
return F.pipe(
4343
findVariable(n.name, initialScope),
44-
O.flatMap(getVariableInit(0)),
44+
O.flatMap(getVariableNode(0)),
4545
O.flatMap((n) => "properties" in n ? O.fromNullable(n.properties) : O.none()),
4646
);
4747
})

packages/plugins/eslint-plugin-react-hooks-extra/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-react-hooks-extra",
3-
"version": "1.5.28",
3+
"version": "1.5.29-next.0",
44
"description": "ESLint React's ESLint plugin for React Hooks related rules.",
55
"homepage": "https://github.com/rel1cx/eslint-react",
66
"bugs": {

packages/plugins/eslint-plugin-react-hooks-extra/src/rules/ensure-use-callback-has-non-empty-deps.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { is, isFunction, NodeType } from "@eslint-react/ast";
33
import { isReactHookCall, isReactHookCallWithNameLoose, isUseCallbackCall } from "@eslint-react/core";
44
import { getESLintReactSettings } from "@eslint-react/shared";
55
import { F, O } from "@eslint-react/tools";
6-
import { findVariable, getVariableInit } from "@eslint-react/var";
6+
import { findVariable, getVariableNode } from "@eslint-react/var";
77
import type { ESLintUtils } from "@typescript-eslint/utils";
88
import type { ConstantCase } from "string-ts";
99
import { match } from "ts-pattern";
@@ -53,7 +53,7 @@ export default createRule<[], MessageID>({
5353
.with({ type: NodeType.Identifier }, n => {
5454
return F.pipe(
5555
findVariable(n.name, initialScope),
56-
O.flatMap(getVariableInit(0)),
56+
O.flatMap(getVariableNode(0)),
5757
O.filter(is(NodeType.ArrayExpression)),
5858
);
5959
})
@@ -80,7 +80,7 @@ export default createRule<[], MessageID>({
8080
.with({ type: NodeType.Identifier }, n => {
8181
return F.pipe(
8282
findVariable(n.name, initialScope),
83-
O.flatMap(getVariableInit(0)),
83+
O.flatMap(getVariableNode(0)),
8484
O.filter(isFunction),
8585
) as O.Option<TSESTreeFunction>;
8686
})

packages/plugins/eslint-plugin-react-hooks-extra/src/rules/ensure-use-memo-has-non-empty-deps.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { is, isFunction, NodeType } from "@eslint-react/ast";
33
import { isReactHookCall, isReactHookCallWithNameLoose, isUseMemoCall } from "@eslint-react/core";
44
import { getESLintReactSettings } from "@eslint-react/shared";
55
import { F, O } from "@eslint-react/tools";
6-
import { findVariable, getVariableInit } from "@eslint-react/var";
6+
import { findVariable, getVariableNode } from "@eslint-react/var";
77
import type { ESLintUtils } from "@typescript-eslint/utils";
88
import type { ConstantCase } from "string-ts";
99
import { match } from "ts-pattern";
@@ -53,7 +53,7 @@ export default createRule<[], MessageID>({
5353
.with({ type: NodeType.Identifier }, n => {
5454
return F.pipe(
5555
findVariable(n.name, initialScope),
56-
O.flatMap(getVariableInit(0)),
56+
O.flatMap(getVariableNode(0)),
5757
O.filter(is(NodeType.ArrayExpression)),
5858
);
5959
})
@@ -80,7 +80,7 @@ export default createRule<[], MessageID>({
8080
.with({ type: NodeType.Identifier }, n => {
8181
return F.pipe(
8282
findVariable(n.name, initialScope),
83-
O.flatMap(getVariableInit(0)),
83+
O.flatMap(getVariableNode(0)),
8484
O.filter(isFunction),
8585
) as O.Option<TSESTreeFunction>;
8686
})

0 commit comments

Comments
 (0)