eslint-plugin-react-jsx 4.2.3-beta.1 → 4.2.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 +121 -17
- 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.3
|
|
26
|
+
var version = "4.2.3";
|
|
27
27
|
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region src/utils/create-rule.ts
|
|
@@ -117,7 +117,7 @@ function getChildrenSourceText(context, node) {
|
|
|
117
117
|
|
|
118
118
|
//#endregion
|
|
119
119
|
//#region src/rules/no-children-prop-with-children/no-children-prop-with-children.ts
|
|
120
|
-
const RULE_NAME$
|
|
120
|
+
const RULE_NAME$7 = "no-children-prop-with-children";
|
|
121
121
|
var no_children_prop_with_children_default = createRule({
|
|
122
122
|
meta: {
|
|
123
123
|
type: "problem",
|
|
@@ -131,11 +131,11 @@ var no_children_prop_with_children_default = createRule({
|
|
|
131
131
|
},
|
|
132
132
|
schema: []
|
|
133
133
|
},
|
|
134
|
-
name: RULE_NAME$
|
|
135
|
-
create: create$
|
|
134
|
+
name: RULE_NAME$7,
|
|
135
|
+
create: create$7,
|
|
136
136
|
defaultOptions: []
|
|
137
137
|
});
|
|
138
|
-
function create$
|
|
138
|
+
function create$7(context) {
|
|
139
139
|
return defineRuleListener({ JSXElement(node) {
|
|
140
140
|
const childrenProp = findAttribute(context, node, "children");
|
|
141
141
|
if (childrenProp == null) return;
|
|
@@ -170,7 +170,7 @@ function create$5(context) {
|
|
|
170
170
|
|
|
171
171
|
//#endregion
|
|
172
172
|
//#region src/rules/no-children-prop/no-children-prop.ts
|
|
173
|
-
const RULE_NAME$
|
|
173
|
+
const RULE_NAME$6 = "no-children-prop";
|
|
174
174
|
var no_children_prop_default = createRule({
|
|
175
175
|
meta: {
|
|
176
176
|
type: "suggestion",
|
|
@@ -183,11 +183,11 @@ var no_children_prop_default = createRule({
|
|
|
183
183
|
},
|
|
184
184
|
schema: []
|
|
185
185
|
},
|
|
186
|
-
name: RULE_NAME$
|
|
187
|
-
create: create$
|
|
186
|
+
name: RULE_NAME$6,
|
|
187
|
+
create: create$6,
|
|
188
188
|
defaultOptions: []
|
|
189
189
|
});
|
|
190
|
-
function create$
|
|
190
|
+
function create$6(context) {
|
|
191
191
|
return defineRuleListener({ JSXElement(node) {
|
|
192
192
|
const childrenProp = findAttribute(context, node, "children");
|
|
193
193
|
if (childrenProp == null) return;
|
|
@@ -233,7 +233,7 @@ function create$4(context) {
|
|
|
233
233
|
|
|
234
234
|
//#endregion
|
|
235
235
|
//#region src/rules/no-comment-textnodes/no-comment-textnodes.ts
|
|
236
|
-
const RULE_NAME$
|
|
236
|
+
const RULE_NAME$5 = "no-comment-textnodes";
|
|
237
237
|
var no_comment_textnodes_default = createRule({
|
|
238
238
|
meta: {
|
|
239
239
|
type: "problem",
|
|
@@ -241,11 +241,11 @@ var no_comment_textnodes_default = createRule({
|
|
|
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
|
},
|
|
244
|
-
name: RULE_NAME$
|
|
245
|
-
create: create$
|
|
244
|
+
name: RULE_NAME$5,
|
|
245
|
+
create: create$5,
|
|
246
246
|
defaultOptions: []
|
|
247
247
|
});
|
|
248
|
-
function create$
|
|
248
|
+
function create$5(context) {
|
|
249
249
|
function hasCommentLike(node) {
|
|
250
250
|
if (ast.isOneOf([AST_NODE_TYPES.JSXAttribute, AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) return false;
|
|
251
251
|
return /^\s*\/(?:\/|\*)/mu.test(context.sourceCode.getText(node));
|
|
@@ -266,7 +266,7 @@ function create$3(context) {
|
|
|
266
266
|
|
|
267
267
|
//#endregion
|
|
268
268
|
//#region src/rules/no-key-after-spread/no-key-after-spread.ts
|
|
269
|
-
const RULE_NAME$
|
|
269
|
+
const RULE_NAME$4 = "no-key-after-spread";
|
|
270
270
|
var no_key_after_spread_default = createRule({
|
|
271
271
|
meta: {
|
|
272
272
|
type: "problem",
|
|
@@ -274,11 +274,11 @@ var no_key_after_spread_default = createRule({
|
|
|
274
274
|
messages: { noKeyAfterSpread: "Placing 'key' after spread props causes deoptimization when using the automatic JSX runtime. Put 'key' before any spread props." },
|
|
275
275
|
schema: []
|
|
276
276
|
},
|
|
277
|
-
name: RULE_NAME$
|
|
278
|
-
create: create$
|
|
277
|
+
name: RULE_NAME$4,
|
|
278
|
+
create: create$4,
|
|
279
279
|
defaultOptions: []
|
|
280
280
|
});
|
|
281
|
-
function create$
|
|
281
|
+
function create$4(context) {
|
|
282
282
|
const { jsx } = getJsxConfig(context);
|
|
283
283
|
if (!(jsx === JsxEmit.ReactJSX || jsx === JsxEmit.ReactJSXDev)) return {};
|
|
284
284
|
return defineRuleListener({ JSXOpeningElement(node) {
|
|
@@ -297,6 +297,106 @@ function create$2(context) {
|
|
|
297
297
|
} });
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
+
//#endregion
|
|
301
|
+
//#region src/rules/no-leaked-dollar/no-leaked-dollar.ts
|
|
302
|
+
const RULE_NAME$3 = "no-leaked-dollar";
|
|
303
|
+
var no_leaked_dollar_default = createRule({
|
|
304
|
+
meta: {
|
|
305
|
+
type: "suggestion",
|
|
306
|
+
docs: { description: "Catches `$` before `{expr}` in JSX — typically from template literal `${expr}` being copy-pasted into JSX without removing the `$`. The `$` \"leaks\" into the rendered output." },
|
|
307
|
+
fixable: "code",
|
|
308
|
+
hasSuggestions: true,
|
|
309
|
+
messages: {
|
|
310
|
+
default: "Leaked '$' in JSX. This '$' will be rendered as text nodes.",
|
|
311
|
+
removeDollarSign: "Remove the text node '$'."
|
|
312
|
+
},
|
|
313
|
+
schema: []
|
|
314
|
+
},
|
|
315
|
+
name: RULE_NAME$3,
|
|
316
|
+
create: create$3,
|
|
317
|
+
defaultOptions: []
|
|
318
|
+
});
|
|
319
|
+
function create$3(context) {
|
|
320
|
+
/**
|
|
321
|
+
* Visitor function for JSXElement and JSXFragment nodes
|
|
322
|
+
* @param node The JSXElement or JSXFragment node to be checked
|
|
323
|
+
*/
|
|
324
|
+
const visitorFunction = (node) => {
|
|
325
|
+
for (const [index, child] of node.children.entries()) {
|
|
326
|
+
if (child.type !== AST_NODE_TYPES.JSXText || !child.value.endsWith("$")) continue;
|
|
327
|
+
if (node.children[index + 1]?.type !== AST_NODE_TYPES.JSXExpressionContainer) continue;
|
|
328
|
+
if (child.value === "$" && node.children.length === 2) continue;
|
|
329
|
+
const pos = child.loc.end;
|
|
330
|
+
context.report({
|
|
331
|
+
loc: {
|
|
332
|
+
end: {
|
|
333
|
+
column: pos.column,
|
|
334
|
+
line: pos.line
|
|
335
|
+
},
|
|
336
|
+
start: {
|
|
337
|
+
column: pos.column - 1,
|
|
338
|
+
line: pos.line
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
messageId: "default",
|
|
342
|
+
node: child,
|
|
343
|
+
suggest: [{
|
|
344
|
+
fix(fixer) {
|
|
345
|
+
return fixer.removeRange([child.range[1] - 1, child.range[1]]);
|
|
346
|
+
},
|
|
347
|
+
messageId: "removeDollarSign"
|
|
348
|
+
}]
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
return defineRuleListener({
|
|
353
|
+
JSXElement: visitorFunction,
|
|
354
|
+
JSXFragment: visitorFunction
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
//#endregion
|
|
359
|
+
//#region src/rules/no-leaked-semicolon/no-leaked-semicolon.ts
|
|
360
|
+
const RULE_NAME$2 = "no-leaked-semicolon";
|
|
361
|
+
var no_leaked_semicolon_default = createRule({
|
|
362
|
+
meta: {
|
|
363
|
+
type: "problem",
|
|
364
|
+
docs: { description: "Catches `;` at the start of JSX text nodes — typically from accidentally placing a statement-ending `;` inside JSX. The `;` \"leaks\" into the rendered output." },
|
|
365
|
+
hasSuggestions: true,
|
|
366
|
+
messages: {
|
|
367
|
+
default: "Leaked ';' in JSX. This ';' will be rendered as text nodes.",
|
|
368
|
+
removeSemicolon: "Remove the text node ';'."
|
|
369
|
+
},
|
|
370
|
+
schema: []
|
|
371
|
+
},
|
|
372
|
+
name: RULE_NAME$2,
|
|
373
|
+
create: create$2,
|
|
374
|
+
defaultOptions: []
|
|
375
|
+
});
|
|
376
|
+
function hasLeakedSemicolon(text) {
|
|
377
|
+
return text.startsWith(";\n") || text.startsWith(";\r");
|
|
378
|
+
}
|
|
379
|
+
function create$2(context) {
|
|
380
|
+
const visitorFunction = (node) => {
|
|
381
|
+
if (!ast.isJSXElementLike(node.parent)) return;
|
|
382
|
+
if (!hasLeakedSemicolon(context.sourceCode.getText(node))) return;
|
|
383
|
+
context.report({
|
|
384
|
+
messageId: "default",
|
|
385
|
+
node,
|
|
386
|
+
suggest: [{
|
|
387
|
+
fix(fixer) {
|
|
388
|
+
return fixer.removeRange([node.range[0], node.range[0] + 1]);
|
|
389
|
+
},
|
|
390
|
+
messageId: "removeSemicolon"
|
|
391
|
+
}]
|
|
392
|
+
});
|
|
393
|
+
};
|
|
394
|
+
return defineRuleListener({
|
|
395
|
+
JSXText: visitorFunction,
|
|
396
|
+
Literal: visitorFunction
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
|
|
300
400
|
//#endregion
|
|
301
401
|
//#region src/rules/no-namespace/no-namespace.ts
|
|
302
402
|
const RULE_NAME$1 = "no-namespace";
|
|
@@ -452,6 +552,8 @@ const plugin = {
|
|
|
452
552
|
"no-children-prop-with-children": no_children_prop_with_children_default,
|
|
453
553
|
"no-comment-textnodes": no_comment_textnodes_default,
|
|
454
554
|
"no-key-after-spread": no_key_after_spread_default,
|
|
555
|
+
"no-leaked-dollar": no_leaked_dollar_default,
|
|
556
|
+
"no-leaked-semicolon": no_leaked_semicolon_default,
|
|
455
557
|
"no-namespace": no_namespace_default,
|
|
456
558
|
"no-useless-fragment": no_useless_fragment_default
|
|
457
559
|
}
|
|
@@ -470,6 +572,8 @@ const rules$1 = {
|
|
|
470
572
|
"react-jsx/no-children-prop": "warn",
|
|
471
573
|
"react-jsx/no-comment-textnodes": "warn",
|
|
472
574
|
"react-jsx/no-key-after-spread": "error",
|
|
575
|
+
"react-jsx/no-leaked-dollar": "warn",
|
|
576
|
+
"react-jsx/no-leaked-semicolon": "warn",
|
|
473
577
|
"react-jsx/no-namespace": "error"
|
|
474
578
|
};
|
|
475
579
|
const plugins$1 = { "react-jsx": plugin };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-jsx",
|
|
3
|
-
"version": "4.2.3
|
|
3
|
+
"version": "4.2.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.3
|
|
47
|
-
"@eslint-react/
|
|
48
|
-
"@eslint-react/
|
|
49
|
-
"@eslint-react/
|
|
50
|
-
"@eslint-react/var": "4.2.3
|
|
46
|
+
"@eslint-react/ast": "4.2.3",
|
|
47
|
+
"@eslint-react/core": "4.2.3",
|
|
48
|
+
"@eslint-react/jsx": "4.2.3",
|
|
49
|
+
"@eslint-react/shared": "4.2.3",
|
|
50
|
+
"@eslint-react/var": "4.2.3"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/react": "^19.2.14",
|