eslint-plugin-react-x 1.40.2 → 1.40.3-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 +14 -7
- package/dist/index.mjs +14 -7
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -141,7 +141,7 @@ var settings3 = {
|
|
|
141
141
|
|
|
142
142
|
// package.json
|
|
143
143
|
var name4 = "eslint-plugin-react-x";
|
|
144
|
-
var version = "1.40.
|
|
144
|
+
var version = "1.40.3-beta.0";
|
|
145
145
|
var createRule = utils.ESLintUtils.RuleCreator(shared.getDocsUrl("x"));
|
|
146
146
|
|
|
147
147
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -3123,13 +3123,20 @@ function create49(context, [option]) {
|
|
|
3123
3123
|
return {
|
|
3124
3124
|
JSXElement(node) {
|
|
3125
3125
|
if (!JSX8__namespace.isFragmentElement(node)) return;
|
|
3126
|
-
|
|
3126
|
+
checkNode(context, node, allowExpressions);
|
|
3127
3127
|
},
|
|
3128
3128
|
JSXFragment(node) {
|
|
3129
|
-
|
|
3129
|
+
checkNode(context, node, allowExpressions);
|
|
3130
3130
|
}
|
|
3131
3131
|
};
|
|
3132
3132
|
}
|
|
3133
|
+
var isLiteral = AST11__namespace.isOneOf([types.AST_NODE_TYPES.Literal, types.AST_NODE_TYPES.JSXText]);
|
|
3134
|
+
function isWhiteSpace(node) {
|
|
3135
|
+
return typeof node.value === "string" && node.raw.trim() === "";
|
|
3136
|
+
}
|
|
3137
|
+
function isPaddingSpaces(node) {
|
|
3138
|
+
return isLiteral(node) && isWhiteSpace(node) && node.raw.includes("\n");
|
|
3139
|
+
}
|
|
3133
3140
|
function trimLikeReact(text) {
|
|
3134
3141
|
const leadingSpaces = /^\s*/.exec(text)?.[0] ?? "";
|
|
3135
3142
|
const trailingSpaces = /\s*$/.exec(text)?.[0] ?? "";
|
|
@@ -3137,14 +3144,14 @@ function trimLikeReact(text) {
|
|
|
3137
3144
|
const end = trailingSpaces.includes("\n") ? text.length - trailingSpaces.length : text.length;
|
|
3138
3145
|
return text.slice(start, end);
|
|
3139
3146
|
}
|
|
3140
|
-
function
|
|
3147
|
+
function checkNode(context, node, allowExpressions) {
|
|
3141
3148
|
function fix(fixer) {
|
|
3142
3149
|
if (node.parent.type !== types.AST_NODE_TYPES.JSXElement && node.parent.type !== types.AST_NODE_TYPES.JSXFragment) {
|
|
3143
3150
|
if (node.children.length === 0) {
|
|
3144
3151
|
return null;
|
|
3145
3152
|
}
|
|
3146
3153
|
if (node.children.some(
|
|
3147
|
-
(child) =>
|
|
3154
|
+
(child) => isLiteral(child) && !isWhiteSpace(child) || AST11__namespace.is(types.AST_NODE_TYPES.JSXExpressionContainer)(child)
|
|
3148
3155
|
)) {
|
|
3149
3156
|
return null;
|
|
3150
3157
|
}
|
|
@@ -3185,7 +3192,7 @@ function doCheck(context, node, allowExpressions) {
|
|
|
3185
3192
|
const isChildElement = AST11__namespace.isOneOf([types.AST_NODE_TYPES.JSXElement, types.AST_NODE_TYPES.JSXFragment])(node.parent);
|
|
3186
3193
|
switch (true) {
|
|
3187
3194
|
// <Foo content={<>ee eeee eeee ...</>} />
|
|
3188
|
-
case (allowExpressions && !isChildElement && node.children.length === 1 &&
|
|
3195
|
+
case (allowExpressions && !isChildElement && node.children.length === 1 && isLiteral(node.children.at(0))): {
|
|
3189
3196
|
return;
|
|
3190
3197
|
}
|
|
3191
3198
|
// <Foo><>hello, world</></Foo>
|
|
@@ -3212,7 +3219,7 @@ function doCheck(context, node, allowExpressions) {
|
|
|
3212
3219
|
return;
|
|
3213
3220
|
}
|
|
3214
3221
|
}
|
|
3215
|
-
const nonPaddingChildren = node.children.filter((child) => !
|
|
3222
|
+
const nonPaddingChildren = node.children.filter((child) => !isPaddingSpaces(child));
|
|
3216
3223
|
const firstNonPaddingChild = nonPaddingChildren.at(0);
|
|
3217
3224
|
switch (true) {
|
|
3218
3225
|
case nonPaddingChildren.length === 0:
|
package/dist/index.mjs
CHANGED
|
@@ -113,7 +113,7 @@ var settings3 = {
|
|
|
113
113
|
|
|
114
114
|
// package.json
|
|
115
115
|
var name4 = "eslint-plugin-react-x";
|
|
116
|
-
var version = "1.40.
|
|
116
|
+
var version = "1.40.3-beta.0";
|
|
117
117
|
var createRule = ESLintUtils.RuleCreator(getDocsUrl("x"));
|
|
118
118
|
|
|
119
119
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -3095,13 +3095,20 @@ function create49(context, [option]) {
|
|
|
3095
3095
|
return {
|
|
3096
3096
|
JSXElement(node) {
|
|
3097
3097
|
if (!JSX8.isFragmentElement(node)) return;
|
|
3098
|
-
|
|
3098
|
+
checkNode(context, node, allowExpressions);
|
|
3099
3099
|
},
|
|
3100
3100
|
JSXFragment(node) {
|
|
3101
|
-
|
|
3101
|
+
checkNode(context, node, allowExpressions);
|
|
3102
3102
|
}
|
|
3103
3103
|
};
|
|
3104
3104
|
}
|
|
3105
|
+
var isLiteral = AST11.isOneOf([AST_NODE_TYPES.Literal, AST_NODE_TYPES.JSXText]);
|
|
3106
|
+
function isWhiteSpace(node) {
|
|
3107
|
+
return typeof node.value === "string" && node.raw.trim() === "";
|
|
3108
|
+
}
|
|
3109
|
+
function isPaddingSpaces(node) {
|
|
3110
|
+
return isLiteral(node) && isWhiteSpace(node) && node.raw.includes("\n");
|
|
3111
|
+
}
|
|
3105
3112
|
function trimLikeReact(text) {
|
|
3106
3113
|
const leadingSpaces = /^\s*/.exec(text)?.[0] ?? "";
|
|
3107
3114
|
const trailingSpaces = /\s*$/.exec(text)?.[0] ?? "";
|
|
@@ -3109,14 +3116,14 @@ function trimLikeReact(text) {
|
|
|
3109
3116
|
const end = trailingSpaces.includes("\n") ? text.length - trailingSpaces.length : text.length;
|
|
3110
3117
|
return text.slice(start, end);
|
|
3111
3118
|
}
|
|
3112
|
-
function
|
|
3119
|
+
function checkNode(context, node, allowExpressions) {
|
|
3113
3120
|
function fix(fixer) {
|
|
3114
3121
|
if (node.parent.type !== AST_NODE_TYPES.JSXElement && node.parent.type !== AST_NODE_TYPES.JSXFragment) {
|
|
3115
3122
|
if (node.children.length === 0) {
|
|
3116
3123
|
return null;
|
|
3117
3124
|
}
|
|
3118
3125
|
if (node.children.some(
|
|
3119
|
-
(child) =>
|
|
3126
|
+
(child) => isLiteral(child) && !isWhiteSpace(child) || AST11.is(AST_NODE_TYPES.JSXExpressionContainer)(child)
|
|
3120
3127
|
)) {
|
|
3121
3128
|
return null;
|
|
3122
3129
|
}
|
|
@@ -3157,7 +3164,7 @@ function doCheck(context, node, allowExpressions) {
|
|
|
3157
3164
|
const isChildElement = AST11.isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment])(node.parent);
|
|
3158
3165
|
switch (true) {
|
|
3159
3166
|
// <Foo content={<>ee eeee eeee ...</>} />
|
|
3160
|
-
case (allowExpressions && !isChildElement && node.children.length === 1 &&
|
|
3167
|
+
case (allowExpressions && !isChildElement && node.children.length === 1 && isLiteral(node.children.at(0))): {
|
|
3161
3168
|
return;
|
|
3162
3169
|
}
|
|
3163
3170
|
// <Foo><>hello, world</></Foo>
|
|
@@ -3184,7 +3191,7 @@ function doCheck(context, node, allowExpressions) {
|
|
|
3184
3191
|
return;
|
|
3185
3192
|
}
|
|
3186
3193
|
}
|
|
3187
|
-
const nonPaddingChildren = node.children.filter((child) => !
|
|
3194
|
+
const nonPaddingChildren = node.children.filter((child) => !isPaddingSpaces(child));
|
|
3188
3195
|
const firstNonPaddingChild = nonPaddingChildren.at(0);
|
|
3189
3196
|
switch (true) {
|
|
3190
3197
|
case nonPaddingChildren.length === 0:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "1.40.
|
|
3
|
+
"version": "1.40.3-beta.0",
|
|
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",
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
"is-immutable-type": "^5.0.1",
|
|
51
51
|
"string-ts": "^2.2.1",
|
|
52
52
|
"ts-pattern": "^5.7.0",
|
|
53
|
-
"@eslint-react/
|
|
54
|
-
"@eslint-react/
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/
|
|
57
|
-
"@eslint-react/
|
|
58
|
-
"@eslint-react/var": "1.40.
|
|
59
|
-
"@eslint-react/
|
|
53
|
+
"@eslint-react/ast": "1.40.3-beta.0",
|
|
54
|
+
"@eslint-react/core": "1.40.3-beta.0",
|
|
55
|
+
"@eslint-react/jsx": "1.40.3-beta.0",
|
|
56
|
+
"@eslint-react/kit": "1.40.3-beta.0",
|
|
57
|
+
"@eslint-react/shared": "1.40.3-beta.0",
|
|
58
|
+
"@eslint-react/var": "1.40.3-beta.0",
|
|
59
|
+
"@eslint-react/eff": "1.40.3-beta.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/react": "^19.1.0",
|