oxlint-plugin-react-doctor 0.5.6-dev.17389ba → 0.5.6-dev.3f7d0e7

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.
Files changed (2) hide show
  1. package/dist/index.js +41 -13
  2. 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) return {
10738
- kind: "iterator",
10739
- callExpression: parent
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;
@@ -17430,6 +17452,7 @@ const noDanger = defineRule({
17430
17452
  title: "Raw HTML injection can run unsafe markup",
17431
17453
  severity: "warn",
17432
17454
  category: "Security",
17455
+ defaultEnabled: false,
17433
17456
  recommendation: "Render trusted content as React children so attacker-controlled HTML cannot run in users' browsers.",
17434
17457
  create: (context) => ({
17435
17458
  JSXOpeningElement(node) {
@@ -20190,15 +20213,20 @@ const noInlineExhaustiveStyle = defineRule({
20190
20213
  severity: "warn",
20191
20214
  tags: ["test-noise", "react-jsx-only"],
20192
20215
  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) => ({ JSXAttribute(node) {
20194
- const expression = getInlineStyleExpression(node);
20195
- if (!expression) return;
20196
- const propertyCount = expression.properties?.filter((property) => isNodeOfType(property, "Property")).length ?? 0;
20197
- if (propertyCount >= 8) context.report({
20198
- node: expression,
20199
- 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.`
20200
- });
20201
- } })
20216
+ create: (context) => {
20217
+ if (isGeneratedImageRenderContext(context)) return {};
20218
+ return { JSXAttribute(node) {
20219
+ const expression = getInlineStyleExpression(node);
20220
+ if (!expression) return;
20221
+ const propertyCount = expression.properties?.filter((property) => isNodeOfType(property, "Property")).length ?? 0;
20222
+ if (propertyCount < 8) return;
20223
+ if (isGeneratedImageRenderContext(context, node.parent ?? void 0)) return;
20224
+ context.report({
20225
+ node: expression,
20226
+ 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.`
20227
+ });
20228
+ } };
20229
+ }
20202
20230
  });
20203
20231
  //#endregion
20204
20232
  //#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.17389ba",
3
+ "version": "0.5.6-dev.3f7d0e7",
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",