eslint-plugin-react-jsx 5.28.3 → 5.28.5
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 -10
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -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.5";
|
|
24
24
|
//#endregion
|
|
25
25
|
//#region src/utils/create-rule.ts
|
|
26
26
|
function getDocsUrl(ruleName) {
|
|
@@ -29,7 +29,7 @@ function getDocsUrl(ruleName) {
|
|
|
29
29
|
const createRule = ESLintUtils.RuleCreator(getDocsUrl);
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region src/utils/remove-jsx-attribute.ts
|
|
32
|
-
function
|
|
32
|
+
function removeJSXAttribute(context, fixer, attribute) {
|
|
33
33
|
let start = attribute.range[0];
|
|
34
34
|
while (start > 0 && /\s/.test(context.sourceCode.text[start - 1] ?? "")) start--;
|
|
35
35
|
return fixer.removeRange([start, attribute.range[1]]);
|
|
@@ -76,7 +76,7 @@ function create$7(context) {
|
|
|
76
76
|
node: prop,
|
|
77
77
|
suggest: [{
|
|
78
78
|
fix(fixer) {
|
|
79
|
-
return
|
|
79
|
+
return removeJSXAttribute(context, fixer, prop);
|
|
80
80
|
},
|
|
81
81
|
messageId: "remove-children-prop"
|
|
82
82
|
}, {
|
|
@@ -150,21 +150,21 @@ function create$6(context) {
|
|
|
150
150
|
}
|
|
151
151
|
function getChildrenText(context, attribute) {
|
|
152
152
|
const { value } = attribute;
|
|
153
|
-
if (value?.type === AST_NODE_TYPES.Literal) return
|
|
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
155
|
const exprText = context.sourceCode.getText(value.expression);
|
|
156
156
|
return Check.isJSXElementOrFragment(value.expression) ? exprText : `{${exprText}}`;
|
|
157
157
|
}
|
|
158
158
|
return null;
|
|
159
159
|
}
|
|
160
|
-
function
|
|
160
|
+
function escapeJSXText(text) {
|
|
161
161
|
return text.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("{", "{").replaceAll("}", "}");
|
|
162
162
|
}
|
|
163
163
|
function buildFix$1(context, node, prop, childrenText) {
|
|
164
164
|
return (fixer) => {
|
|
165
165
|
const sourceCode = context.sourceCode;
|
|
166
166
|
const { openingElement } = node;
|
|
167
|
-
const removePropFix =
|
|
167
|
+
const removePropFix = removeJSXAttribute(context, fixer, prop);
|
|
168
168
|
if (openingElement.selfClosing) {
|
|
169
169
|
const tagName = sourceCode.getText(openingElement.name);
|
|
170
170
|
const selfCloseOffset = sourceCode.getText(openingElement).lastIndexOf("/>");
|
|
@@ -303,7 +303,7 @@ var no_key_after_spread_default = createRule({
|
|
|
303
303
|
});
|
|
304
304
|
function create$4(context) {
|
|
305
305
|
if (!/key\s*=/.test(context.sourceCode.text)) return {};
|
|
306
|
-
const { jsx } = core.
|
|
306
|
+
const { jsx } = core.getJSXConfig(context);
|
|
307
307
|
if (jsx !== ts.JsxEmit.ReactJSX && jsx !== ts.JsxEmit.ReactJSXDev) return {};
|
|
308
308
|
return { JSXOpeningElement(node) {
|
|
309
309
|
for (const n of dropWhile(node.attributes, not(Check.isJSXSpreadAttribute)).filter(isAttribute("key"))) context.report({
|
|
@@ -453,7 +453,7 @@ function create(context, [option]) {
|
|
|
453
453
|
allowEmptyFragment: option.allowEmptyFragment ?? false,
|
|
454
454
|
allowExpressions: option.allowExpressions ?? true
|
|
455
455
|
};
|
|
456
|
-
const { jsxFragmentFactory } = core.
|
|
456
|
+
const { jsxFragmentFactory } = core.getJSXConfig(context);
|
|
457
457
|
return {
|
|
458
458
|
JSXElement(node) {
|
|
459
459
|
if (!isFragmentElement(node, jsxFragmentFactory)) return;
|
|
@@ -481,8 +481,8 @@ function visitFragment(context, node, options) {
|
|
|
481
481
|
function isContentUseless(node, options) {
|
|
482
482
|
const { allowEmptyFragment, allowExpressions } = options;
|
|
483
483
|
if (node.children.length === 0) return !allowEmptyFragment;
|
|
484
|
-
const
|
|
485
|
-
if (allowExpressions && !
|
|
484
|
+
const insideJSX = Check.isJSXElementOrFragment(node.parent);
|
|
485
|
+
if (allowExpressions && !insideJSX && node.children.length === 1 && node.children[0]?.type === AST_NODE_TYPES.JSXText) return false;
|
|
486
486
|
const meaningful = getChildren(node);
|
|
487
487
|
if (meaningful.length === 0) return true;
|
|
488
488
|
if (meaningful.length > 1) return false;
|
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.5",
|
|
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.5",
|
|
41
|
+
"@eslint-react/core": "5.28.5",
|
|
42
|
+
"@eslint-react/eslint": "5.28.5",
|
|
43
|
+
"@eslint-react/jsx": "5.28.5",
|
|
44
|
+
"@eslint-react/shared": "5.28.5",
|
|
45
45
|
"@typescript-eslint/types": "^8.72.0",
|
|
46
46
|
"@typescript-eslint/utils": "^8.72.0"
|
|
47
47
|
},
|