eslint-plugin-react-x 2.2.3-next.7 → 2.2.4-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +6 -5
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { isFalseLiteralType, isTrueLiteralType, isTypeFlagSet, unionConstituents
|
|
|
5
5
|
import { P, isMatching, match } from "ts-pattern";
|
|
6
6
|
import ts from "typescript";
|
|
7
7
|
import * as AST from "@eslint-react/ast";
|
|
8
|
-
import {
|
|
8
|
+
import { findVariable, getChildScopes, getObjectType, getVariableDefinitionNode } from "@eslint-react/var";
|
|
9
9
|
import { ComponentDetectionHint, ComponentFlag, DEFAULT_COMPONENT_DETECTION_HINT, JsxEmit, findParentJsxAttribute, getInstanceId, getJsxAttribute, getJsxAttributeName, getJsxConfigFromAnnotation, getJsxConfigFromContext, getJsxElementType, isAssignmentToThisState, isCaptureOwnerStackCall, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUpdate, isCreateContextCall, isCreateElementCall, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRefCall, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInstanceIdEqual, isJsxFragmentElement, isJsxHostElement, isJsxText, isLazyCall, isReactHookCall, isReactHookName, isRenderMethodLike, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseCall, isUseCallbackCall, isUseContextCall, isUseMemoCall, isUseStateCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector } from "@eslint-react/core";
|
|
10
10
|
import { constFalse, constTrue, flow, getOrElseUpdate, identity, unit } from "@eslint-react/eff";
|
|
11
11
|
import { compare } from "compare-versions";
|
|
@@ -28,7 +28,7 @@ var __export = (all) => {
|
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region package.json
|
|
30
30
|
var name$6 = "eslint-plugin-react-x";
|
|
31
|
-
var version = "2.2.
|
|
31
|
+
var version = "2.2.4-beta.0";
|
|
32
32
|
|
|
33
33
|
//#endregion
|
|
34
34
|
//#region src/utils/create-rule.ts
|
|
@@ -2558,7 +2558,7 @@ function create$11(context) {
|
|
|
2558
2558
|
const value = attribute.value;
|
|
2559
2559
|
if (value?.type !== AST_NODE_TYPES.JSXExpressionContainer) return;
|
|
2560
2560
|
const valueExpression = value.expression;
|
|
2561
|
-
const construction =
|
|
2561
|
+
const construction = getObjectType(valueExpression, context.sourceCode.getScope(valueExpression));
|
|
2562
2562
|
if (construction == null) return;
|
|
2563
2563
|
if (isReactHookCall(construction.node)) return;
|
|
2564
2564
|
getOrElseUpdate(constructions, functionEntry.node, () => []).push(construction);
|
|
@@ -2567,7 +2567,7 @@ function create$11(context) {
|
|
|
2567
2567
|
const components = ctx.getAllComponents(program).values();
|
|
2568
2568
|
for (const { node: component } of components) for (const construction of constructions.get(component) ?? []) {
|
|
2569
2569
|
const { kind, node: constructionNode } = construction;
|
|
2570
|
-
const suggestion = kind
|
|
2570
|
+
const suggestion = kind === "function" ? "Consider wrapping it in a useCallback hook." : "Consider wrapping it in a useMemo hook.";
|
|
2571
2571
|
context.report({
|
|
2572
2572
|
messageId: "unstableContextValue",
|
|
2573
2573
|
node: constructionNode,
|
|
@@ -2627,7 +2627,7 @@ function create$10(context) {
|
|
|
2627
2627
|
if (prop.type !== AST_NODE_TYPES.Property || prop.value.type !== AST_NODE_TYPES.AssignmentPattern) continue;
|
|
2628
2628
|
const { value } = prop;
|
|
2629
2629
|
const { right } = value;
|
|
2630
|
-
const construction =
|
|
2630
|
+
const construction = getObjectType(value, context.sourceCode.getScope(value));
|
|
2631
2631
|
if (construction == null) continue;
|
|
2632
2632
|
if (isReactHookCall(construction.node)) continue;
|
|
2633
2633
|
const forbiddenType = AST.toDelimiterFormat(right);
|
|
@@ -3538,6 +3538,7 @@ var recommended_exports = /* @__PURE__ */ __export({
|
|
|
3538
3538
|
});
|
|
3539
3539
|
const name$5 = "react-x/recommended";
|
|
3540
3540
|
const rules$6 = {
|
|
3541
|
+
"react-x/jsx-key-before-spread": "warn",
|
|
3541
3542
|
"react-x/jsx-no-comment-textnodes": "warn",
|
|
3542
3543
|
"react-x/jsx-no-duplicate-props": "warn",
|
|
3543
3544
|
"react-x/jsx-uses-react": "warn",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4-beta.0",
|
|
4
4
|
"description": "A set of composable ESLint rules for for libraries and frameworks that use React as a UI runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"string-ts": "^2.2.1",
|
|
44
44
|
"ts-api-utils": "^2.1.0",
|
|
45
45
|
"ts-pattern": "^5.8.0",
|
|
46
|
-
"@eslint-react/ast": "2.2.
|
|
47
|
-
"@eslint-react/core": "2.2.
|
|
48
|
-
"@eslint-react/eff": "2.2.
|
|
49
|
-
"@eslint-react/shared": "2.2.
|
|
50
|
-
"@eslint-react/var": "2.2.
|
|
46
|
+
"@eslint-react/ast": "2.2.4-beta.0",
|
|
47
|
+
"@eslint-react/core": "2.2.4-beta.0",
|
|
48
|
+
"@eslint-react/eff": "2.2.4-beta.0",
|
|
49
|
+
"@eslint-react/shared": "2.2.4-beta.0",
|
|
50
|
+
"@eslint-react/var": "2.2.4-beta.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/react": "^19.2.2",
|