eslint-plugin-react-x 1.32.0 → 1.32.1-beta.1
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 +18 -18
- package/dist/index.mjs +19 -19
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -136,7 +136,7 @@ var settings3 = {
|
|
|
136
136
|
|
|
137
137
|
// package.json
|
|
138
138
|
var name4 = "eslint-plugin-react-x";
|
|
139
|
-
var version = "1.32.
|
|
139
|
+
var version = "1.32.1-beta.1";
|
|
140
140
|
var createRule = shared.createRuleForPlugin("x");
|
|
141
141
|
|
|
142
142
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -1090,37 +1090,37 @@ var no_context_provider_default = createRule({
|
|
|
1090
1090
|
},
|
|
1091
1091
|
fixable: "code",
|
|
1092
1092
|
messages: {
|
|
1093
|
-
noContextProvider: "In React 19, you can render '<
|
|
1093
|
+
noContextProvider: "In React 19, you can render '<Context>' as a provider instead of '<Context.Provider>'."
|
|
1094
1094
|
},
|
|
1095
1095
|
schema: []
|
|
1096
1096
|
},
|
|
1097
1097
|
name: RULE_NAME19,
|
|
1098
1098
|
create(context) {
|
|
1099
|
-
if (!context.sourceCode.text.includes("
|
|
1099
|
+
if (!context.sourceCode.text.includes("Provider")) return {};
|
|
1100
1100
|
const { version: version2 } = shared.getSettingsFromContext(context);
|
|
1101
|
-
if (compareVersions.compare(version2, "19.0.0", "<")) {
|
|
1102
|
-
return {};
|
|
1103
|
-
}
|
|
1101
|
+
if (compareVersions.compare(version2, "19.0.0", "<")) return {};
|
|
1104
1102
|
return {
|
|
1105
1103
|
JSXElement(node) {
|
|
1106
|
-
const
|
|
1107
|
-
|
|
1108
|
-
const
|
|
1104
|
+
const fullName = JSX8__namespace.getElementType(node);
|
|
1105
|
+
const parts = fullName.split(".");
|
|
1106
|
+
const selfName = parts.pop();
|
|
1107
|
+
const contextFullName = parts.join(".");
|
|
1108
|
+
const contextSelfName = parts.pop();
|
|
1109
|
+
if (selfName !== "Provider") return;
|
|
1109
1110
|
context.report({
|
|
1110
1111
|
messageId: "noContextProvider",
|
|
1111
1112
|
node,
|
|
1112
|
-
data: {
|
|
1113
|
-
contextName
|
|
1114
|
-
},
|
|
1115
1113
|
fix(fixer) {
|
|
1114
|
+
if (contextSelfName == null) return null;
|
|
1115
|
+
if (!core.isComponentNameLoose(contextSelfName)) return null;
|
|
1116
1116
|
const openingElement = node.openingElement;
|
|
1117
1117
|
const closingElement = node.closingElement;
|
|
1118
1118
|
if (closingElement == null) {
|
|
1119
|
-
return fixer.replaceText(openingElement.name,
|
|
1119
|
+
return fixer.replaceText(openingElement.name, contextFullName);
|
|
1120
1120
|
}
|
|
1121
1121
|
return [
|
|
1122
|
-
fixer.replaceText(openingElement.name,
|
|
1123
|
-
fixer.replaceText(closingElement.name,
|
|
1122
|
+
fixer.replaceText(openingElement.name, contextFullName),
|
|
1123
|
+
fixer.replaceText(closingElement.name, contextFullName)
|
|
1124
1124
|
];
|
|
1125
1125
|
}
|
|
1126
1126
|
});
|
|
@@ -1190,7 +1190,7 @@ var no_default_props_default = createRule({
|
|
|
1190
1190
|
if (property.type !== types.AST_NODE_TYPES.Identifier || property.name !== "defaultProps") {
|
|
1191
1191
|
return;
|
|
1192
1192
|
}
|
|
1193
|
-
if (!core.
|
|
1193
|
+
if (!core.isComponentNameLoose(object.name)) {
|
|
1194
1194
|
return;
|
|
1195
1195
|
}
|
|
1196
1196
|
const variable = VAR__namespace.findVariable(object.name, context.sourceCode.getScope(node));
|
|
@@ -2088,7 +2088,7 @@ var no_prop_types_default = createRule({
|
|
|
2088
2088
|
if (property.type !== types.AST_NODE_TYPES.Identifier || property.name !== "propTypes") {
|
|
2089
2089
|
return;
|
|
2090
2090
|
}
|
|
2091
|
-
if (!core.
|
|
2091
|
+
if (!core.isComponentNameLoose(object.name)) {
|
|
2092
2092
|
return;
|
|
2093
2093
|
}
|
|
2094
2094
|
const variable = VAR__namespace.findVariable(object.name, context.sourceCode.getScope(node));
|
|
@@ -3211,7 +3211,7 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3211
3211
|
return false;
|
|
3212
3212
|
}
|
|
3213
3213
|
const id = AST12__namespace.getFunctionIdentifier(block);
|
|
3214
|
-
return id != null && core.
|
|
3214
|
+
return id != null && core.isComponentNameLoose(id.name) && components.some((component) => component.node === block);
|
|
3215
3215
|
}
|
|
3216
3216
|
for (const [initialScope, memberExpression] of memberExpressionWithNames) {
|
|
3217
3217
|
let scope = initialScope;
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRuleForPlugin, getSettingsFromContext, unsafeDecodeSettings, DEFAULT_ESLINT_REACT_SETTINGS } from '@eslint-react/shared';
|
|
2
2
|
import * as JSX8 from '@eslint-react/jsx';
|
|
3
3
|
import * as AST12 from '@eslint-react/ast';
|
|
4
|
-
import { isForwardRefCall, isClassComponent, isThisSetState, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, useComponentCollectorLegacy, isComponentDidCatch, isGetDerivedStateFromError, isCloneElementCall,
|
|
4
|
+
import { isForwardRefCall, isClassComponent, isThisSetState, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, useComponentCollectorLegacy, isComponentDidCatch, isGetDerivedStateFromError, isCloneElementCall, isComponentNameLoose, isCreateRefCall, isAssignmentToThisState, useComponentCollector, DEFAULT_COMPONENT_HINT, ERComponentFlag, getInstanceId, isInstanceIdEqual, DISPLAY_NAME_ASSIGNMENT_SELECTOR, isCreateContextCall, isChildrenToArrayCall, ERComponentHint, isDirectValueOfRenderPropertyLoose, isDeclaredInRenderPropLoose, isInsideRenderMethod, isCreateElementCall, isReactHookCall, isReactHookCallWithNameAlias, isGetDerivedStateFromProps, isInitializedFromReact } from '@eslint-react/core';
|
|
5
5
|
import { _, getOrUpdate, constTrue, constFalse, identity } from '@eslint-react/eff';
|
|
6
6
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
7
7
|
import { isMatching, match, P } from 'ts-pattern';
|
|
@@ -109,7 +109,7 @@ var settings3 = {
|
|
|
109
109
|
|
|
110
110
|
// package.json
|
|
111
111
|
var name4 = "eslint-plugin-react-x";
|
|
112
|
-
var version = "1.32.
|
|
112
|
+
var version = "1.32.1-beta.1";
|
|
113
113
|
var createRule = createRuleForPlugin("x");
|
|
114
114
|
|
|
115
115
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -1063,37 +1063,37 @@ var no_context_provider_default = createRule({
|
|
|
1063
1063
|
},
|
|
1064
1064
|
fixable: "code",
|
|
1065
1065
|
messages: {
|
|
1066
|
-
noContextProvider: "In React 19, you can render '<
|
|
1066
|
+
noContextProvider: "In React 19, you can render '<Context>' as a provider instead of '<Context.Provider>'."
|
|
1067
1067
|
},
|
|
1068
1068
|
schema: []
|
|
1069
1069
|
},
|
|
1070
1070
|
name: RULE_NAME19,
|
|
1071
1071
|
create(context) {
|
|
1072
|
-
if (!context.sourceCode.text.includes("
|
|
1072
|
+
if (!context.sourceCode.text.includes("Provider")) return {};
|
|
1073
1073
|
const { version: version2 } = getSettingsFromContext(context);
|
|
1074
|
-
if (compare(version2, "19.0.0", "<")) {
|
|
1075
|
-
return {};
|
|
1076
|
-
}
|
|
1074
|
+
if (compare(version2, "19.0.0", "<")) return {};
|
|
1077
1075
|
return {
|
|
1078
1076
|
JSXElement(node) {
|
|
1079
|
-
const
|
|
1080
|
-
|
|
1081
|
-
const
|
|
1077
|
+
const fullName = JSX8.getElementType(node);
|
|
1078
|
+
const parts = fullName.split(".");
|
|
1079
|
+
const selfName = parts.pop();
|
|
1080
|
+
const contextFullName = parts.join(".");
|
|
1081
|
+
const contextSelfName = parts.pop();
|
|
1082
|
+
if (selfName !== "Provider") return;
|
|
1082
1083
|
context.report({
|
|
1083
1084
|
messageId: "noContextProvider",
|
|
1084
1085
|
node,
|
|
1085
|
-
data: {
|
|
1086
|
-
contextName
|
|
1087
|
-
},
|
|
1088
1086
|
fix(fixer) {
|
|
1087
|
+
if (contextSelfName == null) return null;
|
|
1088
|
+
if (!isComponentNameLoose(contextSelfName)) return null;
|
|
1089
1089
|
const openingElement = node.openingElement;
|
|
1090
1090
|
const closingElement = node.closingElement;
|
|
1091
1091
|
if (closingElement == null) {
|
|
1092
|
-
return fixer.replaceText(openingElement.name,
|
|
1092
|
+
return fixer.replaceText(openingElement.name, contextFullName);
|
|
1093
1093
|
}
|
|
1094
1094
|
return [
|
|
1095
|
-
fixer.replaceText(openingElement.name,
|
|
1096
|
-
fixer.replaceText(closingElement.name,
|
|
1095
|
+
fixer.replaceText(openingElement.name, contextFullName),
|
|
1096
|
+
fixer.replaceText(closingElement.name, contextFullName)
|
|
1097
1097
|
];
|
|
1098
1098
|
}
|
|
1099
1099
|
});
|
|
@@ -1163,7 +1163,7 @@ var no_default_props_default = createRule({
|
|
|
1163
1163
|
if (property.type !== AST_NODE_TYPES.Identifier || property.name !== "defaultProps") {
|
|
1164
1164
|
return;
|
|
1165
1165
|
}
|
|
1166
|
-
if (!
|
|
1166
|
+
if (!isComponentNameLoose(object.name)) {
|
|
1167
1167
|
return;
|
|
1168
1168
|
}
|
|
1169
1169
|
const variable = VAR.findVariable(object.name, context.sourceCode.getScope(node));
|
|
@@ -2061,7 +2061,7 @@ var no_prop_types_default = createRule({
|
|
|
2061
2061
|
if (property.type !== AST_NODE_TYPES.Identifier || property.name !== "propTypes") {
|
|
2062
2062
|
return;
|
|
2063
2063
|
}
|
|
2064
|
-
if (!
|
|
2064
|
+
if (!isComponentNameLoose(object.name)) {
|
|
2065
2065
|
return;
|
|
2066
2066
|
}
|
|
2067
2067
|
const variable = VAR.findVariable(object.name, context.sourceCode.getScope(node));
|
|
@@ -3184,7 +3184,7 @@ var prefer_destructuring_assignment_default = createRule({
|
|
|
3184
3184
|
return false;
|
|
3185
3185
|
}
|
|
3186
3186
|
const id = AST12.getFunctionIdentifier(block);
|
|
3187
|
-
return id != null &&
|
|
3187
|
+
return id != null && isComponentNameLoose(id.name) && components.some((component) => component.node === block);
|
|
3188
3188
|
}
|
|
3189
3189
|
for (const [initialScope, memberExpression] of memberExpressionWithNames) {
|
|
3190
3190
|
let scope = initialScope;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "1.32.
|
|
3
|
+
"version": "1.32.1-beta.1",
|
|
4
4
|
"description": "A set of composable linting rules for libraries and frameworks that use React as a UI runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
"compare-versions": "^6.1.1",
|
|
50
50
|
"string-ts": "^2.2.1",
|
|
51
51
|
"ts-pattern": "^5.6.2",
|
|
52
|
-
"@eslint-react/
|
|
53
|
-
"@eslint-react/eff": "1.32.
|
|
54
|
-
"@eslint-react/
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/shared": "1.32.
|
|
57
|
-
"@eslint-react/var": "1.32.
|
|
52
|
+
"@eslint-react/ast": "1.32.1-beta.1",
|
|
53
|
+
"@eslint-react/eff": "1.32.1-beta.1",
|
|
54
|
+
"@eslint-react/jsx": "1.32.1-beta.1",
|
|
55
|
+
"@eslint-react/core": "1.32.1-beta.1",
|
|
56
|
+
"@eslint-react/shared": "1.32.1-beta.1",
|
|
57
|
+
"@eslint-react/var": "1.32.1-beta.1"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/react": "^19.0.10",
|