eslint-plugin-react-x 2.0.5-beta.1 → 2.0.5-beta.3
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 +8 -12
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { P, isMatching, match } from "ts-pattern";
|
|
|
6
6
|
import ts from "typescript";
|
|
7
7
|
import * as AST from "@eslint-react/ast";
|
|
8
8
|
import { ConstructionDetectionHint, findVariable, getChildScopes, getConstruction, getVariableDefinitionNode } from "@eslint-react/var";
|
|
9
|
-
import { ComponentDetectionHint, ComponentFlag, DEFAULT_COMPONENT_DETECTION_HINT, JsxEmit, findParentJsxAttribute, getInstanceId, getJsxAttribute, getJsxAttributeName, getJsxConfigFromAnnotation, getJsxConfigFromContext, getJsxElementType,
|
|
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 { report, toRegExp } from "@eslint-react/kit";
|
|
11
11
|
import { constFalse, constTrue, flow, getOrElseUpdate, identity, unit } from "@eslint-react/eff";
|
|
12
12
|
import { compare } from "compare-versions";
|
|
@@ -115,7 +115,7 @@ const settings = { ...settings$1 };
|
|
|
115
115
|
//#endregion
|
|
116
116
|
//#region package.json
|
|
117
117
|
var name = "eslint-plugin-react-x";
|
|
118
|
-
var version = "2.0.5-beta.
|
|
118
|
+
var version = "2.0.5-beta.3";
|
|
119
119
|
|
|
120
120
|
//#endregion
|
|
121
121
|
//#region src/utils/create-rule.ts
|
|
@@ -905,7 +905,7 @@ var no_children_prop_default = createRule({
|
|
|
905
905
|
});
|
|
906
906
|
function create$46(context) {
|
|
907
907
|
return { JSXElement(node) {
|
|
908
|
-
const childrenProp = getJsxAttribute(context, node
|
|
908
|
+
const childrenProp = getJsxAttribute(context, node)("children");
|
|
909
909
|
if (childrenProp != null) context.report({
|
|
910
910
|
messageId: "noChildrenProp",
|
|
911
911
|
node: childrenProp
|
|
@@ -1534,8 +1534,7 @@ var no_implicit_key_default = createRule({
|
|
|
1534
1534
|
});
|
|
1535
1535
|
function create$32(context) {
|
|
1536
1536
|
return { JSXOpeningElement(node) {
|
|
1537
|
-
const
|
|
1538
|
-
const keyProp = getJsxAttribute(context, node.attributes, initialScope)("key");
|
|
1537
|
+
const keyProp = getJsxAttribute(context, node.parent)("key");
|
|
1539
1538
|
const isKeyPropOnElement = node.attributes.some((n) => n.type === AST_NODE_TYPES.JSXAttribute && n.name.type === AST_NODE_TYPES.JSXIdentifier && n.name.name === "key");
|
|
1540
1539
|
if (keyProp != null && !isKeyPropOnElement) context.report({
|
|
1541
1540
|
messageId: "noImplicitKey",
|
|
@@ -1751,14 +1750,12 @@ function create$28(context) {
|
|
|
1751
1750
|
const state = { isWithinChildrenToArray: false };
|
|
1752
1751
|
function checkIteratorElement(node) {
|
|
1753
1752
|
switch (node.type) {
|
|
1754
|
-
case AST_NODE_TYPES.JSXElement:
|
|
1755
|
-
|
|
1756
|
-
if (!hasJsxAttribute(context, "key", node.openingElement.attributes, initialScope)) return {
|
|
1753
|
+
case AST_NODE_TYPES.JSXElement:
|
|
1754
|
+
if (getJsxAttribute(context, node)("key") == null) return {
|
|
1757
1755
|
messageId: "missingKey",
|
|
1758
1756
|
node
|
|
1759
1757
|
};
|
|
1760
1758
|
return null;
|
|
1761
|
-
}
|
|
1762
1759
|
case AST_NODE_TYPES.JSXFragment: return {
|
|
1763
1760
|
messageId: "unexpectedFragmentSyntax",
|
|
1764
1761
|
node
|
|
@@ -1794,7 +1791,7 @@ function create$28(context) {
|
|
|
1794
1791
|
const elements = node.elements.filter(AST.is(AST_NODE_TYPES.JSXElement));
|
|
1795
1792
|
if (elements.length === 0) return;
|
|
1796
1793
|
const initialScope = context.sourceCode.getScope(node);
|
|
1797
|
-
for (const element of elements) if (
|
|
1794
|
+
for (const element of elements) if (getJsxAttribute(context, element, initialScope)("key") == null) context.report({
|
|
1798
1795
|
messageId: "missingKey",
|
|
1799
1796
|
node: element
|
|
1800
1797
|
});
|
|
@@ -3266,8 +3263,7 @@ function trimLikeReact(text) {
|
|
|
3266
3263
|
* Check if a fragment node is useless and should be reported
|
|
3267
3264
|
*/
|
|
3268
3265
|
function checkNode(context, node, allowExpressions) {
|
|
3269
|
-
|
|
3270
|
-
if (node.type === AST_NODE_TYPES.JSXElement && hasJsxAttribute(context, "key", node.openingElement.attributes, initialScope)) return;
|
|
3266
|
+
if (node.type === AST_NODE_TYPES.JSXElement && getJsxAttribute(context, node)("key") != null) return;
|
|
3271
3267
|
if (isJsxHostElement(context, node.parent)) context.report({
|
|
3272
3268
|
messageId: "uselessFragment",
|
|
3273
3269
|
node,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "2.0.5-beta.
|
|
3
|
+
"version": "2.0.5-beta.3",
|
|
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,12 +43,12 @@
|
|
|
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/
|
|
47
|
-
"@eslint-react/
|
|
48
|
-
"@eslint-react/
|
|
49
|
-
"@eslint-react/
|
|
50
|
-
"@eslint-react/
|
|
51
|
-
"@eslint-react/var": "2.0.5-beta.
|
|
46
|
+
"@eslint-react/ast": "2.0.5-beta.3",
|
|
47
|
+
"@eslint-react/eff": "2.0.5-beta.3",
|
|
48
|
+
"@eslint-react/core": "2.0.5-beta.3",
|
|
49
|
+
"@eslint-react/kit": "2.0.5-beta.3",
|
|
50
|
+
"@eslint-react/shared": "2.0.5-beta.3",
|
|
51
|
+
"@eslint-react/var": "2.0.5-beta.3"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/react": "^19.1.16",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"eslint": "^9.36.0",
|
|
61
|
-
"typescript": "^5.9.
|
|
61
|
+
"typescript": "^5.9.3"
|
|
62
62
|
},
|
|
63
63
|
"engines": {
|
|
64
64
|
"node": ">=20.19.0"
|