Skip to content

Commit d2f088d

Browse files
committed
refactor: rename '_' to unit
1 parent 385165a commit d2f088d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+220
-215
lines changed

.pkgs/eslint-plugin-local/dist/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as AST from '@eslint-react/ast';
22
import { ESLintUtils, AST_NODE_TYPES } from '@typescript-eslint/utils';
3-
import { _ } from '@eslint-react/eff';
3+
import { unit } from '@eslint-react/eff';
44
import { findVariable } from '@eslint-react/var';
55
import { AST_NODE_TYPES as AST_NODE_TYPES$1 } from '@typescript-eslint/types';
66
import { nullThrows, NullThrowsReasons } from '@typescript-eslint/utils/eslint-utils';
@@ -44,7 +44,7 @@ function getRequireExpressionArguments(node) {
4444
return getRequireExpressionArguments(node.object);
4545
}
4646
}
47-
return _;
47+
return unit;
4848
}
4949

5050
// src/rules/avoid-multiline-template-expression.ts

.pkgs/eslint-plugin-local/src/utils/is-initialized-from-source.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Scope } from "@typescript-eslint/scope-manager";
22
import type { TSESTree } from "@typescript-eslint/types";
33
import * as AST from "@eslint-react/ast";
4-
import { _ } from "@eslint-react/eff";
4+
import { unit } from "@eslint-react/eff";
55
import { findVariable } from "@eslint-react/var";
66
import { AST_NODE_TYPES as T } from "@typescript-eslint/types";
77

@@ -46,7 +46,7 @@ export function isInitializedFromSource(
4646
return parent?.type === T.ImportDeclaration && parent.source.value === source;
4747
}
4848

49-
function getRequireExpressionArguments(node: TSESTree.Node): TSESTree.CallExpressionArgument[] | _ {
49+
function getRequireExpressionArguments(node: TSESTree.Node): TSESTree.CallExpressionArgument[] | unit {
5050
switch (true) {
5151
// require('source')
5252
case node.type === T.CallExpression
@@ -59,5 +59,5 @@ function getRequireExpressionArguments(node: TSESTree.Node): TSESTree.CallExpres
5959
return getRequireExpressionArguments(node.object);
6060
}
6161
}
62-
return _;
62+
return unit;
6363
}

packages/core/docs/@eslint-react/namespaces/useComponentCollector/type-aliases/ReturnType.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@
3838

3939
#### getCurrentEntry()
4040

41-
> **getCurrentEntry**: () => `FunctionEntry` \| `_`
41+
> **getCurrentEntry**: () => `FunctionEntry` \| `unit`
4242
4343
##### Returns
4444

45-
`FunctionEntry` \| `_`
45+
`FunctionEntry` \| `unit`
4646

4747
***
4848

packages/core/src/component/component-collector-legacy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ESLintUtils, TSESTree } from "@typescript-eslint/utils";
22
import type { ClassComponent } from "./component-semantic-node";
33
import * as AST from "@eslint-react/ast";
4-
import { _ } from "@eslint-react/eff";
4+
import { unit } from "@eslint-react/eff";
55

66
import { getId } from "@eslint-react/shared";
77
import { ComponentFlag } from "./component-flag";
@@ -48,7 +48,7 @@ export function useComponentCollectorLegacy(): useComponentCollectorLegacy.Retur
4848
name: id?.name,
4949
node,
5050
// TODO: Get displayName of class component
51-
displayName: _,
51+
displayName: unit,
5252
flag,
5353
hint: 0n,
5454
// TODO: Get methods of class component

packages/core/src/component/component-collector.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { ESLintUtils } from "@typescript-eslint/utils";
33
import type { ComponentDetectionHint } from "./component-detection-hint";
44
import type { FunctionComponent } from "./component-semantic-node";
55
import * as AST from "@eslint-react/ast";
6-
import { _ } from "@eslint-react/eff";
6+
import { unit } from "@eslint-react/eff";
77
import { type RuleContext, Selector as SEL } from "@eslint-react/kit";
88
import { getId } from "@eslint-react/shared";
99
import { AST_NODE_TYPES as T } from "@typescript-eslint/types";
@@ -33,7 +33,7 @@ export declare namespace useComponentCollector {
3333
ctx: {
3434
getAllComponents: (node: TSESTree.Program) => Map<string, FunctionComponent>;
3535
getCurrentEntries: () => FunctionEntry[];
36-
getCurrentEntry: () => FunctionEntry | _;
36+
getCurrentEntry: () => FunctionEntry | unit;
3737
};
3838
listeners: ESLintUtils.RuleListener;
3939
};
@@ -114,7 +114,7 @@ export function useComponentCollector(
114114
kind: "function",
115115
name,
116116
node: entry.node,
117-
displayName: _,
117+
displayName: unit,
118118
flag: getComponentFlagFromInitPath(initPath),
119119
hint,
120120
hookCalls: entry.hookCalls,
@@ -128,7 +128,7 @@ export function useComponentCollector(
128128
if (left.type !== T.MemberExpression) return;
129129
const componentName = left.object.type === T.Identifier
130130
? left.object.name
131-
: _;
131+
: unit;
132132
const component = [...components.values()]
133133
.findLast(({ name }) => name != null && name === componentName);
134134
if (component == null) return;
@@ -163,7 +163,7 @@ export function useComponentCollector(
163163
kind: "function",
164164
name,
165165
node: entry.node,
166-
displayName: _,
166+
displayName: unit,
167167
flag: getComponentFlagFromInitPath(initPath),
168168
hint,
169169
hookCalls: entry.hookCalls,

packages/core/src/component/component-id.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import type { RuleContext } from "@eslint-react/kit";
22
import type { TSESTree } from "@typescript-eslint/types";
33
import * as AST from "@eslint-react/ast";
4-
import { _ } from "@eslint-react/eff";
4+
import { unit } from "@eslint-react/eff";
55
import { AST_NODE_TYPES as T } from "@typescript-eslint/types";
66
import { isComponentWrapperCallLoose } from "./component-wrapper";
77

88
export function getFunctionComponentId(
99
context: RuleContext,
1010
node: AST.TSESTreeFunction,
11-
): TSESTree.Identifier | TSESTree.Identifier[] | _ {
11+
): TSESTree.Identifier | TSESTree.Identifier[] | unit {
1212
const functionId = AST.getFunctionId(node);
1313
if (functionId != null) {
1414
return functionId;
@@ -34,5 +34,5 @@ export function getFunctionComponentId(
3434
) {
3535
return parent.parent.parent.id;
3636
}
37-
return _;
37+
return unit;
3838
}

packages/core/src/component/component-name.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type * as AST from "@eslint-react/ast";
22
import type { RuleContext } from "@eslint-react/kit";
33
import type { TSESTree } from "@typescript-eslint/types";
4-
import { _ } from "@eslint-react/eff";
4+
import { unit } from "@eslint-react/eff";
55
import { RegExp as RE } from "@eslint-react/kit";
66

77
import { getFunctionComponentId } from "./component-id";
@@ -14,8 +14,8 @@ export function isComponentNameLoose(name: string) {
1414
return RE.COMPONENT_NAME_LOOSE.test(name);
1515
}
1616

17-
export function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] | _) {
18-
if (id == null) return _;
17+
export function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] | unit) {
18+
if (id == null) return unit;
1919
return Array.isArray(id)
2020
? id.map((n) => n.name).join(".")
2121
: id.name;

packages/core/src/component/component-semantic-node.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type * as AST from "@eslint-react/ast";
2-
import type { _ } from "@eslint-react/eff";
2+
import type { unit } from "@eslint-react/eff";
33
import type { TSESTree } from "@typescript-eslint/types";
44

55
import type { SemanticNode } from "../semantic";
@@ -9,33 +9,33 @@ import type { ComponentFlag } from "./component-flag";
99
/* eslint-disable perfectionist/sort-interfaces */
1010
export interface FunctionComponent extends SemanticNode {
1111
id:
12-
| _
12+
| unit
1313
| TSESTree.Identifier
1414
| TSESTree.Identifier[];
1515
kind: "function";
1616
node: AST.TSESTreeFunction;
1717
flag: ComponentFlag;
1818
hint: ComponentDetectionHint;
1919
initPath:
20-
| _
20+
| unit
2121
| AST.FunctionInitPath;
2222
hookCalls: TSESTree.CallExpression[];
2323
displayName:
24-
| _
24+
| unit
2525
| TSESTree.Expression;
2626
}
2727

2828
export interface ClassComponent extends SemanticNode {
2929
id:
30-
| _
30+
| unit
3131
| TSESTree.Identifier;
3232
kind: "class";
3333
node: AST.TSESTreeClass;
3434
flag: ComponentFlag;
3535
hint: ComponentDetectionHint;
3636
methods: AST.TSESTreeMethodOrProperty[];
3737
displayName:
38-
| _
38+
| unit
3939
| TSESTree.Expression;
4040
}
4141
/* eslint-enable perfectionist/sort-interfaces */

packages/core/src/hook/hook-hierarchy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import type { _ } from "@eslint-react/eff";
1+
import type { unit } from "@eslint-react/eff";
22
import type { TSESTree } from "@typescript-eslint/types";
33
import * as AST from "@eslint-react/ast";
44
import { AST_NODE_TYPES as T } from "@typescript-eslint/types";
55
import { isUseEffectCallLoose } from "./hook-is";
66

7-
export function isFunctionOfUseEffectSetup(node: TSESTree.Node | _) {
7+
export function isFunctionOfUseEffectSetup(node: TSESTree.Node | unit) {
88
if (node == null) return false;
99
return node.parent?.type === T.CallExpression
1010
&& node.parent.callee !== node
@@ -13,7 +13,7 @@ export function isFunctionOfUseEffectSetup(node: TSESTree.Node | _) {
1313
&& isUseEffectCallLoose(node.parent);
1414
}
1515

16-
export function isFunctionOfUseEffectCleanup(node: TSESTree.Node | _) {
16+
export function isFunctionOfUseEffectCleanup(node: TSESTree.Node | unit) {
1717
if (node == null) return false;
1818
const pReturn = AST.findParentNode(node, AST.is(T.ReturnStatement));
1919
const pFunction = AST.findParentNode(node, AST.isFunction); // Correctly named variable

packages/core/src/hook/hook-is.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { _ } from "@eslint-react/eff";
1+
import type { unit } from "@eslint-react/eff";
22
import type { RuleContext } from "@eslint-react/kit";
33
import type { TSESTree } from "@typescript-eslint/types";
44
import * as AST from "@eslint-react/ast";
@@ -9,7 +9,7 @@ import { AST_NODE_TYPES as T } from "@typescript-eslint/types";
99
import { isInitializedFromReact } from "../utils";
1010
import { isReactHookName } from "./hook-name";
1111

12-
export function isReactHook(node: AST.TSESTreeFunction | _) {
12+
export function isReactHook(node: AST.TSESTreeFunction | unit) {
1313
if (node == null) return false;
1414
const id = AST.getFunctionId(node);
1515
return id?.name != null && isReactHookName(id.name);
@@ -20,7 +20,7 @@ export function isReactHook(node: AST.TSESTreeFunction | _) {
2020
* @param node The node to check.
2121
* @returns `true` if the node is a React Hook call, `false` otherwise.
2222
*/
23-
export function isReactHookCall(node: TSESTree.Node | _) {
23+
export function isReactHookCall(node: TSESTree.Node | unit) {
2424
if (node == null) return false;
2525
if (node.type !== T.CallExpression) {
2626
return false;
@@ -35,7 +35,7 @@ export function isReactHookCall(node: TSESTree.Node | _) {
3535
}
3636

3737
/* eslint-disable function/function-return-boolean */
38-
export function isReactHookCallWithName(context: RuleContext, node: TSESTree.Node | _) {
38+
export function isReactHookCallWithName(context: RuleContext, node: TSESTree.Node | unit) {
3939
if (node == null || node.type !== T.CallExpression) return constFalse;
4040
const {
4141
importSource = DEFAULT_ESLINT_REACT_SETTINGS.importSource,
@@ -58,7 +58,7 @@ export function isReactHookCallWithName(context: RuleContext, node: TSESTree.Nod
5858
};
5959
}
6060

61-
export function isReactHookCallWithNameLoose(node: TSESTree.Node | _) {
61+
export function isReactHookCallWithNameLoose(node: TSESTree.Node | unit) {
6262
if (node == null || node.type !== T.CallExpression) return constFalse;
6363
return (name: string) => {
6464
switch (node.callee.type) {
@@ -72,7 +72,7 @@ export function isReactHookCallWithNameLoose(node: TSESTree.Node | _) {
7272
};
7373
}
7474

75-
export function isReactHookCallWithNameAlias(context: RuleContext, name: string, alias: _ | string[] = []) {
75+
export function isReactHookCallWithNameAlias(context: RuleContext, name: string, alias: unit | string[] = []) {
7676
const {
7777
importSource = DEFAULT_ESLINT_REACT_SETTINGS.importSource,
7878
skipImportCheck = true,
@@ -95,7 +95,7 @@ export function isReactHookCallWithNameAlias(context: RuleContext, name: string,
9595
}
9696
/* eslint-enable function/function-return-boolean */
9797

98-
export function isUseEffectCallLoose(node: TSESTree.Node | _) {
98+
export function isUseEffectCallLoose(node: TSESTree.Node | unit) {
9999
if (node == null) return false;
100100
if (node.type !== T.CallExpression) {
101101
return false;

0 commit comments

Comments
 (0)