@blumintinc/eslint-plugin-blumint 1.20.60 → 1.20.61
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/lib/index.js +1 -1
- package/lib/rules/prefer-fragment-shorthand.js +17 -5
- package/package.json +1 -1
- package/release-manifest.json +14 -0
package/lib/index.js
CHANGED
|
@@ -8,6 +8,11 @@ exports.preferFragmentShorthand = (0, createRule_1.createRule)({
|
|
|
8
8
|
return {
|
|
9
9
|
JSXElement(node) {
|
|
10
10
|
const openingElement = node.openingElement;
|
|
11
|
+
// The <> shorthand cannot carry attributes, so an attributed fragment
|
|
12
|
+
// (key, spread, ...) has no valid rewrite and must not be reported.
|
|
13
|
+
if (openingElement.attributes.length > 0) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
11
16
|
if (openingElement.name.type === 'JSXMemberExpression' &&
|
|
12
17
|
openingElement.name.object.type === 'JSXIdentifier' &&
|
|
13
18
|
openingElement.name.object.name === 'React' &&
|
|
@@ -17,11 +22,18 @@ exports.preferFragmentShorthand = (0, createRule_1.createRule)({
|
|
|
17
22
|
node,
|
|
18
23
|
messageId: 'preferShorthand',
|
|
19
24
|
data: { fragmentName: 'React.Fragment' },
|
|
20
|
-
fix: (fixer) =>
|
|
21
|
-
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
fix: (fixer) => {
|
|
26
|
+
const { closingElement } = node;
|
|
27
|
+
// A self-closing <React.Fragment /> has no children and no
|
|
28
|
+
// closing element; <></> is its equivalent shorthand.
|
|
29
|
+
if (!closingElement) {
|
|
30
|
+
return fixer.replaceText(node, '<></>');
|
|
31
|
+
}
|
|
32
|
+
return [
|
|
33
|
+
fixer.replaceTextRange(openingElement.range, '<>'),
|
|
34
|
+
fixer.replaceTextRange(closingElement.range, '</>'),
|
|
35
|
+
];
|
|
36
|
+
},
|
|
25
37
|
});
|
|
26
38
|
}
|
|
27
39
|
},
|
package/package.json
CHANGED
package/release-manifest.json
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "1.20.61",
|
|
4
|
+
"date": "2026-08-01T06:30:50.860Z",
|
|
5
|
+
"rules": [
|
|
6
|
+
{
|
|
7
|
+
"name": "prefer-fragment-shorthand",
|
|
8
|
+
"changeType": "fix",
|
|
9
|
+
"issues": [
|
|
10
|
+
1552
|
|
11
|
+
],
|
|
12
|
+
"summary": "don't report attributed fragments (closes #1552)"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
},
|
|
2
16
|
{
|
|
3
17
|
"version": "1.20.60",
|
|
4
18
|
"date": "2026-08-01T05:06:58.616Z",
|