oxlint-plugin-react-doctor 0.5.6-dev.b317164 → 0.5.6-dev.b8170f8
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 +40 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10684,6 +10684,24 @@ const hasJsxKeyAttribute = (openingElement) => {
|
|
|
10684
10684
|
return false;
|
|
10685
10685
|
};
|
|
10686
10686
|
//#endregion
|
|
10687
|
+
//#region src/plugin/utils/is-non-children-jsx-attribute-value.ts
|
|
10688
|
+
const ascendThroughJsxValueWrappers = (node) => {
|
|
10689
|
+
let current = node;
|
|
10690
|
+
while (current.parent) {
|
|
10691
|
+
const parent = current.parent;
|
|
10692
|
+
if (!(isNodeOfType(parent, "ChainExpression") || isNodeOfType(parent, "TSAsExpression") || isNodeOfType(parent, "TSSatisfiesExpression") || isNodeOfType(parent, "TSNonNullExpression") || isNodeOfType(parent, "LogicalExpression") || isNodeOfType(parent, "ConditionalExpression") && parent.test !== current)) break;
|
|
10693
|
+
current = parent;
|
|
10694
|
+
}
|
|
10695
|
+
return current;
|
|
10696
|
+
};
|
|
10697
|
+
const isNonChildrenJsxAttributeValue = (node) => {
|
|
10698
|
+
const container = ascendThroughJsxValueWrappers(node).parent;
|
|
10699
|
+
if (!container || !isNodeOfType(container, "JSXExpressionContainer")) return false;
|
|
10700
|
+
const attribute = container.parent;
|
|
10701
|
+
if (!attribute || !isNodeOfType(attribute, "JSXAttribute")) return false;
|
|
10702
|
+
return getJsxAttributeName(attribute.name) !== "children";
|
|
10703
|
+
};
|
|
10704
|
+
//#endregion
|
|
10687
10705
|
//#region src/plugin/rules/react-builtins/jsx-key.ts
|
|
10688
10706
|
const ITERATOR_METHOD_NAMES = new Set([
|
|
10689
10707
|
"map",
|
|
@@ -10722,6 +10740,7 @@ const findEnclosingIteratorContext = (jsxNode) => {
|
|
|
10722
10740
|
const arrayParent = parent.parent;
|
|
10723
10741
|
if (arrayParent && isNodeOfType(arrayParent, "Property")) return null;
|
|
10724
10742
|
if (arrayParent && isNodeOfType(arrayParent, "ArrayExpression")) return null;
|
|
10743
|
+
if (isNonChildrenJsxAttributeValue(parent)) return null;
|
|
10725
10744
|
return { kind: "array" };
|
|
10726
10745
|
} else if (isNodeOfType(parent, "CallExpression")) {
|
|
10727
10746
|
const callee = parent.callee;
|
|
@@ -10734,10 +10753,13 @@ const findEnclosingIteratorContext = (jsxNode) => {
|
|
|
10734
10753
|
if (!targetArg) return null;
|
|
10735
10754
|
let walker = current;
|
|
10736
10755
|
while (walker && walker !== parent) {
|
|
10737
|
-
if (walker === targetArg)
|
|
10738
|
-
|
|
10739
|
-
|
|
10740
|
-
|
|
10756
|
+
if (walker === targetArg) {
|
|
10757
|
+
if (isNonChildrenJsxAttributeValue(parent)) return null;
|
|
10758
|
+
return {
|
|
10759
|
+
kind: "iterator",
|
|
10760
|
+
callExpression: parent
|
|
10761
|
+
};
|
|
10762
|
+
}
|
|
10741
10763
|
walker = walker.parent ?? null;
|
|
10742
10764
|
}
|
|
10743
10765
|
return null;
|
|
@@ -20190,15 +20212,20 @@ const noInlineExhaustiveStyle = defineRule({
|
|
|
20190
20212
|
severity: "warn",
|
|
20191
20213
|
tags: ["test-noise", "react-jsx-only"],
|
|
20192
20214
|
recommendation: "Move the styles to a CSS class, CSS module, Tailwind utilities, or a styled component. Big inline objects are hard to read and rebuild on every update.",
|
|
20193
|
-
create: (context) =>
|
|
20194
|
-
|
|
20195
|
-
|
|
20196
|
-
|
|
20197
|
-
|
|
20198
|
-
|
|
20199
|
-
|
|
20200
|
-
|
|
20201
|
-
|
|
20215
|
+
create: (context) => {
|
|
20216
|
+
if (isGeneratedImageRenderContext(context)) return {};
|
|
20217
|
+
return { JSXAttribute(node) {
|
|
20218
|
+
const expression = getInlineStyleExpression(node);
|
|
20219
|
+
if (!expression) return;
|
|
20220
|
+
const propertyCount = expression.properties?.filter((property) => isNodeOfType(property, "Property")).length ?? 0;
|
|
20221
|
+
if (propertyCount < 8) return;
|
|
20222
|
+
if (isGeneratedImageRenderContext(context, node.parent ?? void 0)) return;
|
|
20223
|
+
context.report({
|
|
20224
|
+
node: expression,
|
|
20225
|
+
message: `This inline style has ${propertyCount} properties, which is hard to read & rebuilds every render. Move it to a CSS class, CSS module, or styled component.`
|
|
20226
|
+
});
|
|
20227
|
+
} };
|
|
20228
|
+
}
|
|
20202
20229
|
});
|
|
20203
20230
|
//#endregion
|
|
20204
20231
|
//#region src/plugin/rules/performance/no-inline-prop-on-memo-component.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oxlint-plugin-react-doctor",
|
|
3
|
-
"version": "0.5.6-dev.
|
|
3
|
+
"version": "0.5.6-dev.b8170f8",
|
|
4
4
|
"description": "oxlint plugin for React Doctor: diagnose React codebases for security, performance, correctness, accessibility, bundle-size, and architecture issues",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility",
|