Skip to content

Commit 80e673f

Browse files
committed
refactor(core): rename and consolidate component flag types
1 parent ba94d90 commit 80e673f

14 files changed

+70
-101
lines changed

packages/core/docs/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@
1515

1616
## Type Aliases
1717

18-
- [ERClassComponentFlag](type-aliases/ERClassComponentFlag.md)
1918
- [ERComponent](type-aliases/ERComponent.md)
19+
- [ERComponentFlag](type-aliases/ERComponentFlag.md)
2020
- [ERComponentHint](type-aliases/ERComponentHint.md)
2121
- [ERComponentKind](type-aliases/ERComponentKind.md)
2222
- [EREffectKind](type-aliases/EREffectKind.md)
2323
- [EREffectPhaseKind](type-aliases/EREffectPhaseKind.md)
24-
- [ERFunctionComponentFlag](type-aliases/ERFunctionComponentFlag.md)
2524
- [ERHookKind](type-aliases/ERHookKind.md)
2625
- [ERLifecyclePhaseKind](type-aliases/ERLifecyclePhaseKind.md)
2726
- [ERPhaseKind](type-aliases/ERPhaseKind.md)
@@ -31,9 +30,8 @@
3130

3231
- [COMPONENT\_DISPLAY\_NAME\_ASSIGNMENT\_SELECTOR](variables/COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR.md)
3332
- [DEFAULT\_COMPONENT\_HINT](variables/DEFAULT_COMPONENT_HINT.md)
34-
- [ERClassComponentFlag](variables/ERClassComponentFlag.md)
33+
- [ERComponentFlag](variables/ERComponentFlag.md)
3534
- [ERComponentHint](variables/ERComponentHint.md)
36-
- [ERFunctionComponentFlag](variables/ERFunctionComponentFlag.md)
3735
- [ERPhaseRelevance](variables/ERPhaseRelevance.md)
3836
- [RE\_COMPONENT\_NAME](variables/RE_COMPONENT_NAME.md)
3937
- [RE\_HOOK\_NAME](variables/RE_HOOK_NAME.md)

packages/core/docs/type-aliases/ERClassComponentFlag.md

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[**@eslint-react/core**](../README.md)
2+
3+
***
4+
5+
[@eslint-react/core](../README.md) / ERComponentFlag
6+
7+
# Type Alias: ERComponentFlag
8+
9+
> **ERComponentFlag**: `bigint`

packages/core/docs/type-aliases/ERFunctionComponentFlag.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

packages/core/docs/variables/ERClassComponentFlag.md

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[**@eslint-react/core**](../README.md)
2+
3+
***
4+
5+
[@eslint-react/core](../README.md) / ERComponentFlag
6+
7+
# Variable: ERComponentFlag
8+
9+
> **ERComponentFlag**: `object`
10+
11+
## Type declaration
12+
13+
### Async
14+
15+
> **Async**: `bigint`
16+
17+
### CreateElement
18+
19+
> **CreateElement**: `bigint`
20+
21+
### ForwardRef
22+
23+
> **ForwardRef**: `bigint`
24+
25+
### Memo
26+
27+
> **Memo**: `bigint`
28+
29+
### None
30+
31+
> **None**: `bigint` = `0n`
32+
33+
### PureComponent
34+
35+
> **PureComponent**: `bigint`

packages/core/docs/variables/ERFunctionComponentFlag.md

Lines changed: 0 additions & 23 deletions
This file was deleted.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { _ } from "@eslint-react/eff";
33
import { getId } from "@eslint-react/shared";
44
import type { ESLintUtils, TSESTree } from "@typescript-eslint/utils";
55

6-
import { ERClassComponentFlag } from "./component-flag";
6+
import { ERComponentFlag } from "./component-flag";
77
import type { ERClassComponent } from "./component-semantic-node";
88
import { isClassComponent, isPureComponent } from "./is";
99

@@ -28,8 +28,8 @@ export function useComponentCollectorLegacy() {
2828
const id = AST.getClassIdentifier(node);
2929
const key = getId();
3030
const flag = isPureComponent(node)
31-
? ERClassComponentFlag.PureComponent
32-
: ERClassComponentFlag.None;
31+
? ERComponentFlag.PureComponent
32+
: ERComponentFlag.None;
3333
components.set(
3434
key,
3535
{

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { isChildrenOfCreateElement } from "../element";
1111
import { isReactHookCall } from "../hook";
1212
import { DEFAULT_COMPONENT_HINT, ERComponentHint } from "./component-collector-hint";
1313
import { COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR } from "./component-display-name";
14-
import { ERFunctionComponentFlag } from "./component-flag";
14+
import { ERComponentFlag } from "./component-flag";
1515
import { getFunctionComponentIdentifier } from "./component-id";
1616
import { isFunctionOfRenderMethod } from "./component-lifecycle";
1717
import { getComponentNameFromIdentifier, hasNoneOrValidComponentName } from "./component-name";
@@ -47,12 +47,12 @@ function hasValidHierarchy(node: AST.TSESTreeFunction, context: RuleContext, hin
4747
}
4848

4949
function getComponentFlag(initPath: ERFunctionComponent["initPath"]) {
50-
let flag = ERFunctionComponentFlag.None;
50+
let flag = ERComponentFlag.None;
5151
if (initPath != null && AST.hasCallInFunctionInitPath("memo", initPath)) {
52-
flag |= ERFunctionComponentFlag.Memo;
52+
flag |= ERComponentFlag.Memo;
5353
}
5454
if (initPath != null && AST.hasCallInFunctionInitPath("forwardRef", initPath)) {
55-
flag |= ERFunctionComponentFlag.ForwardRef;
55+
flag |= ERComponentFlag.ForwardRef;
5656
}
5757
return flag;
5858
}
Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,11 @@
1-
export type ERClassComponentFlag = bigint;
1+
/* eslint-disable perfectionist/sort-objects */
2+
export type ERComponentFlag = bigint;
23

3-
export const ERClassComponentFlag = {
4+
export const ERComponentFlag = {
45
None: 0n,
56
PureComponent: 1n << 0n,
6-
// Reserved for future use
7-
// CreateElement: 1n << 1n,
8-
};
9-
10-
export type ERFunctionComponentFlag = bigint;
11-
12-
/* eslint-disable perfectionist/sort-objects */
13-
export const ERFunctionComponentFlag = {
14-
None: 0n,
15-
Memo: 1n << 0n,
16-
ForwardRef: 1n << 1n,
17-
// Reserved for future use
18-
// CreateElement: 1n << 2n,
19-
// Reserved for future use
20-
// hasHooks: 1n << 3n,
21-
// Reserved for future use
22-
// Async: 1n << 4n,
7+
CreateElement: 1n << 1n,
8+
Memo: 1n << 2n,
9+
Async: 1n << 3n,
10+
ForwardRef: 1n << 4n,
2311
};
24-
/* eslint-enable perfectionist/sort-objects */

0 commit comments

Comments
 (0)