eslint-plugin-react-jsx 5.28.7 → 5.28.8
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 +10 -11
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DEFAULT_ESLINT_REACT_SETTINGS } from "@eslint-react/shared";
|
|
2
2
|
import * as ESLintUtils from "@typescript-eslint/utils/eslint-utils";
|
|
3
3
|
import * as core from "@eslint-react/core";
|
|
4
|
-
import "@eslint-react/eslint";
|
|
4
|
+
import { getText } from "@eslint-react/eslint";
|
|
5
5
|
import { collapseMultilineText, findAttribute, getChildren, getElementFullType, hasAnyAttribute, hasChildren, isAttribute, isEmptyStringExpression, isFragmentElement, isHostElement, isWhitespaceText } from "@eslint-react/jsx";
|
|
6
6
|
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
7
7
|
import { Check } from "@eslint-react/ast";
|
|
@@ -20,7 +20,7 @@ var __exportAll = (all, no_symbols) => {
|
|
|
20
20
|
//#endregion
|
|
21
21
|
//#region package.json
|
|
22
22
|
var name$2 = "eslint-plugin-react-jsx";
|
|
23
|
-
var version = "5.28.
|
|
23
|
+
var version = "5.28.8";
|
|
24
24
|
//#endregion
|
|
25
25
|
//#region src/utils/create-rule.ts
|
|
26
26
|
function getDocsUrl(ruleName) {
|
|
@@ -152,7 +152,7 @@ function getChildrenText(context, attribute) {
|
|
|
152
152
|
const { value } = attribute;
|
|
153
153
|
if (value?.type === AST_NODE_TYPES.Literal) return escapeJSXText(String(value.value));
|
|
154
154
|
if (value?.type === AST_NODE_TYPES.JSXExpressionContainer && value.expression.type !== AST_NODE_TYPES.JSXEmptyExpression) {
|
|
155
|
-
const exprText =
|
|
155
|
+
const exprText = getText(context, value.expression);
|
|
156
156
|
return Check.isJSXElementOrFragment(value.expression) ? exprText : `{${exprText}}`;
|
|
157
157
|
}
|
|
158
158
|
return null;
|
|
@@ -162,14 +162,13 @@ function escapeJSXText(text) {
|
|
|
162
162
|
}
|
|
163
163
|
function buildFix$1(context, node, prop, childrenText) {
|
|
164
164
|
return (fixer) => {
|
|
165
|
-
const sourceCode = context.sourceCode;
|
|
166
165
|
const { openingElement } = node;
|
|
167
166
|
const removePropFix = removeJSXAttribute(context, fixer, prop);
|
|
168
167
|
if (openingElement.selfClosing) {
|
|
169
|
-
const tagName =
|
|
170
|
-
const selfCloseOffset =
|
|
168
|
+
const tagName = getText(context, openingElement.name);
|
|
169
|
+
const selfCloseOffset = getText(context, openingElement).lastIndexOf("/>");
|
|
171
170
|
let wsStart = openingElement.range[0] + selfCloseOffset;
|
|
172
|
-
while (wsStart > prop.range[1] && /\s/.test(sourceCode.text[wsStart - 1])) wsStart--;
|
|
171
|
+
while (wsStart > prop.range[1] && /\s/.test(context.sourceCode.text[wsStart - 1])) wsStart--;
|
|
173
172
|
return [removePropFix, fixer.replaceTextRange([wsStart, openingElement.range[1]], `>${childrenText}</${tagName}>`)];
|
|
174
173
|
}
|
|
175
174
|
if (node.closingElement == null) return [removePropFix];
|
|
@@ -189,7 +188,7 @@ var no_comment_textnodes_default = createRule({
|
|
|
189
188
|
function create$5(context) {
|
|
190
189
|
return { JSXText(node) {
|
|
191
190
|
if (!Check.isJSXElementOrFragment(node.parent)) return;
|
|
192
|
-
if (!/^\s*\/(?:\/|\*)/mu.test(
|
|
191
|
+
if (!/^\s*\/(?:\/|\*)/mu.test(getText(context, node))) return;
|
|
193
192
|
context.report({
|
|
194
193
|
messageId: "default",
|
|
195
194
|
node
|
|
@@ -334,7 +333,7 @@ function create$3(context) {
|
|
|
334
333
|
if (child.type !== AST_NODE_TYPES.JSXText || !child.value.endsWith("$")) continue;
|
|
335
334
|
if (node.children[index + 1]?.type !== AST_NODE_TYPES.JSXExpressionContainer) continue;
|
|
336
335
|
if (child.value.trim() === "$" && node.children.every((sibling, siblingIndex) => siblingIndex === index || siblingIndex === index + 1 || isNonSubstantiveChild(sibling))) continue;
|
|
337
|
-
if (!
|
|
336
|
+
if (!getText(context, child).endsWith("$")) continue;
|
|
338
337
|
const dollarStart = child.range[1] - 1;
|
|
339
338
|
const dollarEnd = child.range[1];
|
|
340
339
|
context.report({
|
|
@@ -381,7 +380,7 @@ var no_leaked_semicolon_default = createRule({
|
|
|
381
380
|
function create$2(context) {
|
|
382
381
|
return { JSXText(node) {
|
|
383
382
|
if (!Check.isJSXElementOrFragment(node.parent)) return;
|
|
384
|
-
if (!/^;+[ \t]*(?:\r\n|\r|\n)/u.test(
|
|
383
|
+
if (!/^;+[ \t]*(?:\r\n|\r|\n)/u.test(getText(context, node))) return;
|
|
385
384
|
context.report({
|
|
386
385
|
messageId: "default",
|
|
387
386
|
node,
|
|
@@ -506,7 +505,7 @@ function buildFix(context, node) {
|
|
|
506
505
|
for (const child of node.children) if (child.type === AST_NODE_TYPES.JSXText) {
|
|
507
506
|
const cleaned = collapseMultilineText(child.value);
|
|
508
507
|
if (cleaned != null) text += cleaned;
|
|
509
|
-
} else text +=
|
|
508
|
+
} else text += getText(context, child);
|
|
510
509
|
let start = node.range[0];
|
|
511
510
|
if (text === "" && node.children.length > 0) {
|
|
512
511
|
const lineStart = Math.max(sourceCode.text.lastIndexOf("\n", start - 1), sourceCode.text.lastIndexOf("\r", start - 1)) + 1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-jsx",
|
|
3
|
-
"version": "5.28.
|
|
3
|
+
"version": "5.28.8",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for React Flavored JSX rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"dist"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@eslint-react/ast": "5.28.
|
|
41
|
-
"@eslint-react/core": "5.28.
|
|
42
|
-
"@eslint-react/eslint": "5.28.
|
|
43
|
-
"@eslint-react/jsx": "5.28.
|
|
44
|
-
"@eslint-react/shared": "5.28.
|
|
40
|
+
"@eslint-react/ast": "5.28.8",
|
|
41
|
+
"@eslint-react/core": "5.28.8",
|
|
42
|
+
"@eslint-react/eslint": "5.28.8",
|
|
43
|
+
"@eslint-react/jsx": "5.28.8",
|
|
44
|
+
"@eslint-react/shared": "5.28.8",
|
|
45
45
|
"@typescript-eslint/types": "^8.72.0",
|
|
46
46
|
"@typescript-eslint/utils": "^8.72.0"
|
|
47
47
|
},
|