eslint-plugin-react-jsx 5.8.11 → 5.8.12
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 +9 -43
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ 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
4
|
import { merge } from "@eslint-react/eslint";
|
|
5
|
-
import { findAttribute, getChildren, getElementFullType, hasAnyAttribute, hasChildren, isFragmentElement, isHostElement, isWhitespaceText } from "@eslint-react/jsx";
|
|
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.12";
|
|
30
30
|
|
|
31
31
|
//#endregion
|
|
32
32
|
//#region src/utils/create-rule.ts
|
|
@@ -468,44 +468,6 @@ function create$1(context) {
|
|
|
468
468
|
} });
|
|
469
469
|
}
|
|
470
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]);
|
|
507
|
-
}
|
|
508
|
-
|
|
509
471
|
//#endregion
|
|
510
472
|
//#region src/rules/no-useless-fragment/no-useless-fragment.ts
|
|
511
473
|
const RULE_NAME = "no-useless-fragment";
|
|
@@ -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
|
/**
|
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.12",
|
|
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/
|
|
43
|
-
"@eslint-react/
|
|
44
|
-
"@eslint-react/
|
|
45
|
-
"@eslint-react/
|
|
46
|
-
"@eslint-react/
|
|
42
|
+
"@eslint-react/core": "5.8.12",
|
|
43
|
+
"@eslint-react/eslint": "5.8.12",
|
|
44
|
+
"@eslint-react/ast": "5.8.12",
|
|
45
|
+
"@eslint-react/jsx": "5.8.12",
|
|
46
|
+
"@eslint-react/shared": "5.8.12"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/react": "^19.2.16",
|