eslint-plugin-react-jsx 4.2.0-beta.1 → 4.2.0-beta.3
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 -14
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __exportAll = (all, no_symbols) => {
|
|
|
23
23
|
//#endregion
|
|
24
24
|
//#region package.json
|
|
25
25
|
var name$2 = "eslint-plugin-react-jsx";
|
|
26
|
-
var version = "4.2.0-beta.
|
|
26
|
+
var version = "4.2.0-beta.3";
|
|
27
27
|
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region src/utils/create-rule.ts
|
|
@@ -38,7 +38,7 @@ const createRule = ESLintUtils.RuleCreator(getDocsUrl);
|
|
|
38
38
|
* Trim leading / trailing whitespace the same way React does when rendering
|
|
39
39
|
* JSX text. Whitespace that contains a newline is stripped entirely;
|
|
40
40
|
* whitespace that stays on the same line is preserved.
|
|
41
|
-
* @param text
|
|
41
|
+
* @param text The JSX text to trim.
|
|
42
42
|
*/
|
|
43
43
|
function trimLikeReact(text) {
|
|
44
44
|
const leadingSpaces = /^\s*/.exec(text)?.[0] ?? "";
|
|
@@ -50,8 +50,8 @@ function trimLikeReact(text) {
|
|
|
50
50
|
/**
|
|
51
51
|
* Compute the removal range for a JSX attribute, consuming any leading
|
|
52
52
|
* whitespace (spaces, tabs, newlines) so the resulting markup stays clean.
|
|
53
|
-
* @param context
|
|
54
|
-
* @param prop
|
|
53
|
+
* @param context The rule context.
|
|
54
|
+
* @param prop The JSX attribute.
|
|
55
55
|
*/
|
|
56
56
|
function getPropRemovalRange(context, prop) {
|
|
57
57
|
const { sourceCode } = context;
|
|
@@ -68,8 +68,8 @@ function getPropRemovalRange(context, prop) {
|
|
|
68
68
|
* - `children={<>…</>}` -> `<>…</>` (JSX fragment, no braces)
|
|
69
69
|
* - `children={expression}` -> `{expression}` (wrapped in braces)
|
|
70
70
|
* - `children` -> `null` (boolean shorthand, cannot extract)
|
|
71
|
-
* @param context
|
|
72
|
-
* @param prop
|
|
71
|
+
* @param context The rule context.
|
|
72
|
+
* @param prop The JSX attribute.
|
|
73
73
|
*/
|
|
74
74
|
function getChildrenPropText(context, prop) {
|
|
75
75
|
const { sourceCode } = context;
|
|
@@ -90,7 +90,7 @@ function getChildrenPropText(context, prop) {
|
|
|
90
90
|
* fragment (from the start of the first child to the end of the last child).
|
|
91
91
|
*
|
|
92
92
|
* Returns `null` when there are no children at all.
|
|
93
|
-
* @param node
|
|
93
|
+
* @param node The JSX element or fragment.
|
|
94
94
|
*/
|
|
95
95
|
function getChildrenContentRange(node) {
|
|
96
96
|
if (node.children.length === 0) return null;
|
|
@@ -103,8 +103,8 @@ function getChildrenContentRange(node) {
|
|
|
103
103
|
* (everything between the opening and closing tags).
|
|
104
104
|
*
|
|
105
105
|
* Returns `""` for self-closing elements like `<Fragment />`.
|
|
106
|
-
* @param context
|
|
107
|
-
* @param node
|
|
106
|
+
* @param context The rule context.
|
|
107
|
+
* @param node The JSX element or fragment.
|
|
108
108
|
*/
|
|
109
109
|
function getChildrenSourceText(context, node) {
|
|
110
110
|
const { sourceCode } = context;
|
|
@@ -237,7 +237,7 @@ const RULE_NAME$3 = "no-comment-textnodes";
|
|
|
237
237
|
var no_comment_textnodes_default = createRule({
|
|
238
238
|
meta: {
|
|
239
239
|
type: "problem",
|
|
240
|
-
docs: { description: "Prevents comment strings
|
|
240
|
+
docs: { description: "Prevents comment strings from being accidentally inserted into a JSX element's text nodes." },
|
|
241
241
|
messages: { default: "Possible misused comment in text node. Comments inside children section of tag should be placed inside braces." },
|
|
242
242
|
schema: []
|
|
243
243
|
},
|
|
@@ -363,7 +363,7 @@ function create(context, [option]) {
|
|
|
363
363
|
/**
|
|
364
364
|
* Whether the fragment has too few meaningful children to justify its
|
|
365
365
|
* existence (the "contains less than two children" reason).
|
|
366
|
-
* @param node
|
|
366
|
+
* @param node The fragment node to check.
|
|
367
367
|
*/
|
|
368
368
|
function isContentUseless(node) {
|
|
369
369
|
if (node.children.length === 0) return !allowEmptyFragment;
|
|
@@ -383,7 +383,7 @@ function create(context, [option]) {
|
|
|
383
383
|
}
|
|
384
384
|
/**
|
|
385
385
|
* Whether it is safe to auto-fix the fragment by unwrapping it.
|
|
386
|
-
* @param node
|
|
386
|
+
* @param node The fragment node to check.
|
|
387
387
|
*/
|
|
388
388
|
function isSafeToFix(node) {
|
|
389
389
|
if (ast.isJSXElementLike(node.parent)) return isHostElement(node.parent);
|
|
@@ -397,7 +397,7 @@ function create(context, [option]) {
|
|
|
397
397
|
/**
|
|
398
398
|
* Build an autofix that unwraps the fragment, replacing it with its
|
|
399
399
|
* trimmed children text. Returns `null` when the fix is unsafe.
|
|
400
|
-
* @param node
|
|
400
|
+
* @param node The fragment node to fix.
|
|
401
401
|
*/
|
|
402
402
|
function buildFix(node) {
|
|
403
403
|
if (!isSafeToFix(node)) return null;
|
|
@@ -412,7 +412,7 @@ function create(context, [option]) {
|
|
|
412
412
|
* A fragment may be reported for **two independent reasons** on the same
|
|
413
413
|
* node (e.g. `<p><>foo</></p>` is both "placed inside a host component"
|
|
414
414
|
* and* "contains less than two children").
|
|
415
|
-
* @param node
|
|
415
|
+
* @param node The fragment node to inspect.
|
|
416
416
|
*/
|
|
417
417
|
function checkNode(node) {
|
|
418
418
|
if (isHostElement(node.parent)) context.report({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-jsx",
|
|
3
|
-
"version": "4.2.0-beta.
|
|
3
|
+
"version": "4.2.0-beta.3",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for React Flavored JSX rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"@typescript-eslint/utils": "^8.58.0",
|
|
44
44
|
"compare-versions": "^6.1.1",
|
|
45
45
|
"ts-pattern": "^5.9.0",
|
|
46
|
-
"@eslint-react/ast": "4.2.0-beta.
|
|
47
|
-
"@eslint-react/core": "4.2.0-beta.
|
|
48
|
-
"@eslint-react/jsx": "4.2.0-beta.
|
|
49
|
-
"@eslint-react/shared": "4.2.0-beta.
|
|
50
|
-
"@eslint-react/var": "4.2.0-beta.
|
|
46
|
+
"@eslint-react/ast": "4.2.0-beta.3",
|
|
47
|
+
"@eslint-react/core": "4.2.0-beta.3",
|
|
48
|
+
"@eslint-react/jsx": "4.2.0-beta.3",
|
|
49
|
+
"@eslint-react/shared": "4.2.0-beta.3",
|
|
50
|
+
"@eslint-react/var": "4.2.0-beta.3"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/react": "^19.2.14",
|