eslint-plugin-react-jsx 5.8.11 → 5.8.13
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 +26 -60
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DEFAULT_ESLINT_REACT_SETTINGS } from "@eslint-react/shared";
|
|
2
2
|
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
3
3
|
import * as core from "@eslint-react/core";
|
|
4
|
-
import
|
|
5
|
-
import { findAttribute, getChildren, getElementFullType, hasAnyAttribute, hasChildren, isFragmentElement, isHostElement, isWhitespaceText } from "@eslint-react/jsx";
|
|
4
|
+
import "@eslint-react/eslint";
|
|
5
|
+
import { collapseMultilineText, findAttribute, getChildren, getElementFullType, hasAnyAttribute, hasChildren, isFragmentElement, isHostElement, isWhitespaceText } from "@eslint-react/jsx";
|
|
6
6
|
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
7
7
|
import { Check, Extract, isOneOf } from "@eslint-react/ast";
|
|
8
8
|
import ts from "typescript";
|
|
@@ -26,7 +26,7 @@ var __exportAll = (all, no_symbols) => {
|
|
|
26
26
|
//#endregion
|
|
27
27
|
//#region package.json
|
|
28
28
|
var name$2 = "eslint-plugin-react-jsx";
|
|
29
|
-
var version = "5.8.
|
|
29
|
+
var version = "5.8.13";
|
|
30
30
|
|
|
31
31
|
//#endregion
|
|
32
32
|
//#region src/utils/create-rule.ts
|
|
@@ -99,7 +99,7 @@ var no_children_prop_with_children_default = createRule({
|
|
|
99
99
|
defaultOptions: []
|
|
100
100
|
});
|
|
101
101
|
function create$7(context) {
|
|
102
|
-
return
|
|
102
|
+
return {
|
|
103
103
|
CallExpression(node) {
|
|
104
104
|
if (!core.isCreateElementCall(context, node)) return;
|
|
105
105
|
const [, propsArg, firstExtra] = node.arguments;
|
|
@@ -142,7 +142,7 @@ function create$7(context) {
|
|
|
142
142
|
}]
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
|
-
}
|
|
145
|
+
};
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
//#endregion
|
|
@@ -220,7 +220,7 @@ var no_children_prop_default = createRule({
|
|
|
220
220
|
defaultOptions: []
|
|
221
221
|
});
|
|
222
222
|
function create$6(context) {
|
|
223
|
-
return
|
|
223
|
+
return {
|
|
224
224
|
CallExpression(node) {
|
|
225
225
|
if (!core.isCreateElementCall(context, node)) return;
|
|
226
226
|
const [, propsArg] = node.arguments;
|
|
@@ -273,7 +273,7 @@ function create$6(context) {
|
|
|
273
273
|
}]
|
|
274
274
|
});
|
|
275
275
|
}
|
|
276
|
-
}
|
|
276
|
+
};
|
|
277
277
|
}
|
|
278
278
|
|
|
279
279
|
//#endregion
|
|
@@ -303,10 +303,10 @@ function create$5(context) {
|
|
|
303
303
|
node
|
|
304
304
|
});
|
|
305
305
|
};
|
|
306
|
-
return
|
|
306
|
+
return {
|
|
307
307
|
JSXText: visitorFunction,
|
|
308
308
|
Literal: visitorFunction
|
|
309
|
-
}
|
|
309
|
+
};
|
|
310
310
|
}
|
|
311
311
|
|
|
312
312
|
//#endregion
|
|
@@ -326,7 +326,7 @@ var no_key_after_spread_default = createRule({
|
|
|
326
326
|
function create$4(context) {
|
|
327
327
|
const { jsx } = core.getJsxConfig(context);
|
|
328
328
|
if (!(jsx === ts.JsxEmit.ReactJSX || jsx === ts.JsxEmit.ReactJSXDev)) return {};
|
|
329
|
-
return
|
|
329
|
+
return { JSXOpeningElement(node) {
|
|
330
330
|
let firstSpreadPropIndex = null;
|
|
331
331
|
for (const [index, prop] of node.attributes.entries()) {
|
|
332
332
|
if (prop.type === AST_NODE_TYPES.JSXSpreadAttribute) {
|
|
@@ -339,7 +339,7 @@ function create$4(context) {
|
|
|
339
339
|
node: prop
|
|
340
340
|
});
|
|
341
341
|
}
|
|
342
|
-
} }
|
|
342
|
+
} };
|
|
343
343
|
}
|
|
344
344
|
|
|
345
345
|
//#endregion
|
|
@@ -394,10 +394,10 @@ function create$3(context) {
|
|
|
394
394
|
});
|
|
395
395
|
}
|
|
396
396
|
};
|
|
397
|
-
return
|
|
397
|
+
return {
|
|
398
398
|
JSXElement: visitorFunction,
|
|
399
399
|
JSXFragment: visitorFunction
|
|
400
|
-
}
|
|
400
|
+
};
|
|
401
401
|
}
|
|
402
402
|
|
|
403
403
|
//#endregion
|
|
@@ -436,10 +436,10 @@ function create$2(context) {
|
|
|
436
436
|
}]
|
|
437
437
|
});
|
|
438
438
|
};
|
|
439
|
-
return
|
|
439
|
+
return {
|
|
440
440
|
JSXText: visitorFunction,
|
|
441
441
|
Literal: visitorFunction
|
|
442
|
-
}
|
|
442
|
+
};
|
|
443
443
|
}
|
|
444
444
|
|
|
445
445
|
//#endregion
|
|
@@ -457,7 +457,7 @@ var no_namespace_default = createRule({
|
|
|
457
457
|
defaultOptions: []
|
|
458
458
|
});
|
|
459
459
|
function create$1(context) {
|
|
460
|
-
return
|
|
460
|
+
return { JSXElement(node) {
|
|
461
461
|
const name = getElementFullType(node);
|
|
462
462
|
if (typeof name !== "string" || !name.includes(":")) return;
|
|
463
463
|
context.report({
|
|
@@ -465,45 +465,7 @@ function create$1(context) {
|
|
|
465
465
|
messageId: "noNamespace",
|
|
466
466
|
node: node.openingElement.name
|
|
467
467
|
});
|
|
468
|
-
} }
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
//#endregion
|
|
472
|
-
//#region src/rules/no-useless-fragment/lib.ts
|
|
473
|
-
/**
|
|
474
|
-
* Trim leading / trailing whitespace that spans across a newline.
|
|
475
|
-
*
|
|
476
|
-
* This is used by the auto-fixer to remove indentation / formatting artefacts
|
|
477
|
-
* from the raw source text between a fragment's opening and closing tags,
|
|
478
|
-
* producing cleaner unwrapped output. It does **not** model React's rendering
|
|
479
|
-
* behaviour — React DOM preserves text nodes exactly as written.
|
|
480
|
-
*
|
|
481
|
-
* Whitespace that contains a newline is stripped entirely;
|
|
482
|
-
* whitespace that stays on the same line is preserved.
|
|
483
|
-
* @param text The raw source text between JSX tags.
|
|
484
|
-
*/
|
|
485
|
-
function trimLikeReact(text) {
|
|
486
|
-
const leadingSpaces = /^\s*/.exec(text)?.[0] ?? "";
|
|
487
|
-
const trailingSpaces = /\s*$/.exec(text)?.[0] ?? "";
|
|
488
|
-
const start = leadingSpaces.includes("\n") ? leadingSpaces.length : 0;
|
|
489
|
-
const end = trailingSpaces.includes("\n") ? text.length - trailingSpaces.length : text.length;
|
|
490
|
-
return text.slice(start, end);
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* Extract the raw source text of an element's / fragment's children
|
|
494
|
-
* (everything between the opening and closing tags).
|
|
495
|
-
*
|
|
496
|
-
* Returns `""` for self-closing elements like `<Fragment />`.
|
|
497
|
-
* @param context The rule context.
|
|
498
|
-
* @param node The JSX element or fragment.
|
|
499
|
-
*/
|
|
500
|
-
function getChildrenSourceText(context, node) {
|
|
501
|
-
const { sourceCode } = context;
|
|
502
|
-
const opener = node.type === AST_NODE_TYPES.JSXFragment ? node.openingFragment : node.openingElement;
|
|
503
|
-
const closer = node.type === AST_NODE_TYPES.JSXFragment ? node.closingFragment : node.closingElement;
|
|
504
|
-
if (opener.type === AST_NODE_TYPES.JSXOpeningElement && opener.selfClosing) return "";
|
|
505
|
-
if (closer == null) return "";
|
|
506
|
-
return sourceCode.text.slice(opener.range[1], closer.range[0]);
|
|
468
|
+
} };
|
|
507
469
|
}
|
|
508
470
|
|
|
509
471
|
//#endregion
|
|
@@ -579,14 +541,18 @@ function create(context, [option]) {
|
|
|
579
541
|
}
|
|
580
542
|
/**
|
|
581
543
|
* Build an autofix that unwraps the fragment, replacing it with its
|
|
582
|
-
*
|
|
544
|
+
* meaningful children content. Returns `null` when the fix is unsafe.
|
|
583
545
|
* @param node The fragment node to fix.
|
|
584
546
|
*/
|
|
585
547
|
function buildFix(node) {
|
|
586
548
|
if (!isSafeToFix(node)) return null;
|
|
587
549
|
return (fixer) => {
|
|
588
|
-
|
|
589
|
-
|
|
550
|
+
let text = "";
|
|
551
|
+
for (const child of node.children) if (child.type === AST_NODE_TYPES.JSXText) {
|
|
552
|
+
const cleaned = collapseMultilineText(child.value);
|
|
553
|
+
if (cleaned != null) text += cleaned;
|
|
554
|
+
} else text += context.sourceCode.getText(child);
|
|
555
|
+
return fixer.replaceText(node, text);
|
|
590
556
|
};
|
|
591
557
|
}
|
|
592
558
|
/**
|
|
@@ -611,7 +577,7 @@ function create(context, [option]) {
|
|
|
611
577
|
node
|
|
612
578
|
});
|
|
613
579
|
}
|
|
614
|
-
return
|
|
580
|
+
return {
|
|
615
581
|
JSXElement(node) {
|
|
616
582
|
if (!isFragmentElement(node, jsxConfig.jsxFragmentFactory)) return;
|
|
617
583
|
if (hasAnyAttribute(context, node, ["key", "ref"])) return;
|
|
@@ -620,7 +586,7 @@ function create(context, [option]) {
|
|
|
620
586
|
JSXFragment(node) {
|
|
621
587
|
checkNode(node);
|
|
622
588
|
}
|
|
623
|
-
}
|
|
589
|
+
};
|
|
624
590
|
}
|
|
625
591
|
|
|
626
592
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-jsx",
|
|
3
|
-
"version": "5.8.
|
|
3
|
+
"version": "5.8.13",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for React Flavored JSX rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@typescript-eslint/types": "^8.60.1",
|
|
41
41
|
"@typescript-eslint/utils": "^8.60.1",
|
|
42
|
-
"@eslint-react/ast": "5.8.
|
|
43
|
-
"@eslint-react/core": "5.8.
|
|
44
|
-
"@eslint-react/
|
|
45
|
-
"@eslint-react/
|
|
46
|
-
"@eslint-react/
|
|
42
|
+
"@eslint-react/ast": "5.8.13",
|
|
43
|
+
"@eslint-react/core": "5.8.13",
|
|
44
|
+
"@eslint-react/eslint": "5.8.13",
|
|
45
|
+
"@eslint-react/jsx": "5.8.13",
|
|
46
|
+
"@eslint-react/shared": "5.8.13"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/react": "^19.2.16",
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"@typescript-eslint/rule-tester": "^8.60.1",
|
|
52
52
|
"dedent": "^1.7.2",
|
|
53
53
|
"eslint": "^10.4.1",
|
|
54
|
-
"tsdown": "^0.22.
|
|
54
|
+
"tsdown": "^0.22.2",
|
|
55
55
|
"typescript": "6.0.3",
|
|
56
|
-
"@local/
|
|
57
|
-
"@local/
|
|
56
|
+
"@local/eff": "0.0.0",
|
|
57
|
+
"@local/configs": "0.0.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"eslint": "^10.3.0",
|