Skip to content

Commit 033d0aa

Browse files
committed
refactor: rename 'unsafe' to 'loose' in internal API names
1 parent acb689d commit 033d0aa

File tree

7 files changed

+23
-23
lines changed

7 files changed

+23
-23
lines changed

packages/core/docs/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
- [isCreateElementCall](functions/isCreateElementCall.md)
6363
- [isCreateRef](functions/isCreateRef.md)
6464
- [isCreateRefCall](functions/isCreateRefCall.md)
65+
- [isDeclaredInRenderPropLoose](functions/isDeclaredInRenderPropLoose.md)
6566
- [isForwardRef](functions/isForwardRef.md)
6667
- [isForwardRefCall](functions/isForwardRefCall.md)
6768
- [isFragmentElement](functions/isFragmentElement.md)
@@ -82,6 +83,8 @@
8283
- [isReactHookCallWithName](functions/isReactHookCallWithName.md)
8384
- [isReactHookCallWithNameLoose](functions/isReactHookCallWithNameLoose.md)
8485
- [isReactHookName](functions/isReactHookName.md)
86+
- [isRenderFunctionLoose](functions/isRenderFunctionLoose.md)
87+
- [isRenderPropLoose](functions/isRenderPropLoose.md)
8588
- [isUseCallbackCall](functions/isUseCallbackCall.md)
8689
- [isUseContextCall](functions/isUseContextCall.md)
8790
- [isUseDebugValueCall](functions/isUseDebugValueCall.md)
@@ -97,9 +100,6 @@
97100
- [isUseStateCall](functions/isUseStateCall.md)
98101
- [isUseSyncExternalStoreCall](functions/isUseSyncExternalStoreCall.md)
99102
- [isUseTransitionCall](functions/isUseTransitionCall.md)
100-
- [unsafeIsDeclaredInRenderProp](functions/unsafeIsDeclaredInRenderProp.md)
101-
- [unsafeIsRenderFunction](functions/unsafeIsRenderFunction.md)
102-
- [unsafeIsRenderProp](functions/unsafeIsRenderProp.md)
103103
- [useComponentCollector](functions/useComponentCollector.md)
104104
- [useComponentCollectorLegacy](functions/useComponentCollectorLegacy.md)
105105
- [useHookCollector](functions/useHookCollector.md)

packages/core/docs/functions/unsafeIsDeclaredInRenderProp.md renamed to packages/core/docs/functions/isDeclaredInRenderPropLoose.md

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

33
***
44

5-
[@eslint-react/core](../README.md) / unsafeIsDeclaredInRenderProp
5+
[@eslint-react/core](../README.md) / isDeclaredInRenderPropLoose
66

7-
# Function: unsafeIsDeclaredInRenderProp()
7+
# Function: isDeclaredInRenderPropLoose()
88

9-
> **unsafeIsDeclaredInRenderProp**(`node`): `boolean`
9+
> **isDeclaredInRenderPropLoose**(`node`): `boolean`
1010
1111
Unsafe check whether given node is declared inside a render prop
1212
```jsx

packages/core/docs/functions/unsafeIsRenderFunction.md renamed to packages/core/docs/functions/isRenderFunctionLoose.md

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

33
***
44

5-
[@eslint-react/core](../README.md) / unsafeIsRenderFunction
5+
[@eslint-react/core](../README.md) / isRenderFunctionLoose
66

7-
# Function: unsafeIsRenderFunction()
7+
# Function: isRenderFunctionLoose()
88

9-
> **unsafeIsRenderFunction**(`node`, `context`): `boolean`
9+
> **isRenderFunctionLoose**(`node`, `context`): `boolean`
1010
1111
Unsafe check whether given node is a render function
1212
```jsx

packages/core/docs/functions/unsafeIsRenderProp.md renamed to packages/core/docs/functions/isRenderPropLoose.md

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

33
***
44

5-
[@eslint-react/core](../README.md) / unsafeIsRenderProp
5+
[@eslint-react/core](../README.md) / isRenderPropLoose
66

7-
# Function: unsafeIsRenderProp()
7+
# Function: isRenderPropLoose()
88

9-
> **unsafeIsRenderProp**(`node`, `context`): `boolean`
9+
> **isRenderPropLoose**(`node`, `context`): `boolean`
1010
1111
Unsafe check whether given JSXAttribute is a render prop
1212
```jsx

packages/core/src/render-prop/hierarchy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { isMatching, P } from "ts-pattern";
1515
* @param node The AST node to check
1616
* @returns `true` if component is declared inside a render property, `false` if not
1717
*/
18-
export function unsafeIsDirectValueOfRenderProperty(node: TSESTree.Node) {
18+
export function isDirectValueOfRenderPropertyLoose(node: TSESTree.Node) {
1919
const matching = isMatching({
2020
key: {
2121
type: NodeType.Identifier,
@@ -38,8 +38,8 @@ export function unsafeIsDirectValueOfRenderProperty(node: TSESTree.Node) {
3838
* @param node The AST node to check
3939
* @returns `true` if component is declared inside a render prop, `false` if not
4040
*/
41-
export function unsafeIsDeclaredInRenderProp(node: TSESTree.Node) {
42-
if (unsafeIsDirectValueOfRenderProperty(node)) {
41+
export function isDeclaredInRenderPropLoose(node: TSESTree.Node) {
42+
if (isDirectValueOfRenderPropertyLoose(node)) {
4343
return true;
4444
}
4545

packages/core/src/render-prop/is.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { isMatching, P } from "ts-pattern";
1818
* @param context The rule context
1919
* @returns `true` if node is a render function, `false` if not
2020
*/
21-
export function unsafeIsRenderFunction(node: TSESTreeFunction, context: RuleContext) {
21+
export function isRenderFunctionLoose(node: TSESTreeFunction, context: RuleContext) {
2222
const { body, parent } = node;
2323

2424
const maybeId = getFunctionIdentifier(node);
@@ -56,7 +56,7 @@ export function unsafeIsRenderFunction(node: TSESTreeFunction, context: RuleCont
5656
* @param context The rule context
5757
* @returns `true` if node is a render prop, `false` if not
5858
*/
59-
export function unsafeIsRenderProp(node: TSESTree.JSXAttribute, context: RuleContext) {
59+
export function isRenderPropLoose(node: TSESTree.JSXAttribute, context: RuleContext) {
6060
return isMatching({
6161
type: NodeType.JSXAttribute,
6262
name: {
@@ -67,5 +67,5 @@ export function unsafeIsRenderProp(node: TSESTree.JSXAttribute, context: RuleCon
6767
type: NodeType.JSXExpressionContainer,
6868
expression: P.when(isFunction),
6969
},
70-
}, node) && unsafeIsRenderFunction(node.value.expression, context);
70+
}, node) && isRenderFunctionLoose(node.value.expression, context);
7171
}

packages/plugins/eslint-plugin-react-core/src/rules/no-nested-components.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import type { TSESTreeClass, TSESTreeFunction } from "@eslint-react/ast";
22
import { isClass, isFunction, NodeType, traverseUp, traverseUpGuard } from "@eslint-react/ast";
33
import {
44
ERComponentHint,
5+
isDeclaredInRenderPropLoose,
6+
isDirectValueOfRenderPropertyLoose,
57
isInsideCreateElementProps,
68
isInsideRenderMethod,
7-
unsafeIsDeclaredInRenderProp,
8-
unsafeIsDirectValueOfRenderProperty,
99
useComponentCollector,
1010
useComponentCollectorLegacy,
1111
} from "@eslint-react/core";
@@ -64,14 +64,14 @@ export default createRule<[], MessageID>({
6464
};
6565
for (const { name: componentName, node: component } of functionComponents) {
6666
// Do not mark objects containing render methods
67-
if (unsafeIsDirectValueOfRenderProperty(component)) continue;
67+
if (isDirectValueOfRenderPropertyLoose(component)) continue;
6868
// Do not mark anonymous function components to reduce false positives
6969
if (O.isNone(componentName)) continue;
7070
const name = componentName.value;
7171
const isInsideProperty = component.parent.type === NodeType.Property;
7272
const isInsideJSXPropValue = isInsidePropValue(component);
7373
if (isInsideJSXPropValue) {
74-
if (!unsafeIsDeclaredInRenderProp(component)) {
74+
if (!isDeclaredInRenderPropLoose(component)) {
7575
context.report({
7676
data: {
7777
name,
@@ -95,7 +95,7 @@ export default createRule<[], MessageID>({
9595
continue;
9696
}
9797
const maybeParentComponent = traverseUpGuard(component, isFunctionComponent);
98-
if (O.isSome(maybeParentComponent) && !unsafeIsDirectValueOfRenderProperty(maybeParentComponent.value)) {
98+
if (O.isSome(maybeParentComponent) && !isDirectValueOfRenderPropertyLoose(maybeParentComponent.value)) {
9999
context.report({
100100
data: {
101101
name,

0 commit comments

Comments
 (0)