oxlint-plugin-react-doctor 0.2.18-dev.eab6dc2 → 0.2.18-dev.eba20ae
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.d.ts +657 -0
- package/dist/index.js +112 -97
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3954,6 +3954,7 @@ const noEmDashInJsxText = defineRule({
|
|
|
3954
3954
|
title: "Em dash in JSX text",
|
|
3955
3955
|
tags: ["design", "test-noise"],
|
|
3956
3956
|
severity: "warn",
|
|
3957
|
+
defaultEnabled: false,
|
|
3957
3958
|
category: "Architecture",
|
|
3958
3959
|
recommendation: "Replace em dashes in UI text with commas, colons, semicolons, or parentheses so the copy reads less like AI output.",
|
|
3959
3960
|
create: (context) => ({ JSXText(jsxTextNode) {
|
|
@@ -4000,6 +4001,7 @@ const noRedundantPaddingAxes = defineRule({
|
|
|
4000
4001
|
title: "Redundant padding axes",
|
|
4001
4002
|
tags: ["design", "test-noise"],
|
|
4002
4003
|
severity: "warn",
|
|
4004
|
+
defaultEnabled: false,
|
|
4003
4005
|
category: "Architecture",
|
|
4004
4006
|
recommendation: "Collapse `px-N py-N` to `p-N` when both sides match. Keep them split only when one side changes at a breakpoint (`py-2 md:py-3`).",
|
|
4005
4007
|
create: (context) => ({ JSXAttribute(jsxAttribute) {
|
|
@@ -4023,6 +4025,7 @@ const noRedundantSizeAxes = defineRule({
|
|
|
4023
4025
|
requires: ["tailwind:3.4"],
|
|
4024
4026
|
tags: ["design", "test-noise"],
|
|
4025
4027
|
severity: "warn",
|
|
4028
|
+
defaultEnabled: false,
|
|
4026
4029
|
category: "Architecture",
|
|
4027
4030
|
recommendation: "Collapse `w-N h-N` to `size-N` (Tailwind v3.4+) when both sides match.",
|
|
4028
4031
|
create: (context) => ({ JSXAttribute(jsxAttribute) {
|
|
@@ -4046,6 +4049,7 @@ const noSpaceOnFlexChildren = defineRule({
|
|
|
4046
4049
|
title: "space-* utility on flex children",
|
|
4047
4050
|
tags: ["design", "test-noise"],
|
|
4048
4051
|
severity: "warn",
|
|
4052
|
+
defaultEnabled: false,
|
|
4049
4053
|
category: "Architecture",
|
|
4050
4054
|
recommendation: "Use `gap-*` on the flex or grid parent. `space-x-*` and `space-y-*` leave gaps when a child is hidden, miss spacing on wrapped lines, and don't flip in right-to-left layouts.",
|
|
4051
4055
|
create: (context) => ({ JSXAttribute(jsxAttribute) {
|
|
@@ -4079,6 +4083,7 @@ const noThreePeriodEllipsis = defineRule({
|
|
|
4079
4083
|
title: "Three dots instead of ellipsis",
|
|
4080
4084
|
tags: ["design", "test-noise"],
|
|
4081
4085
|
severity: "warn",
|
|
4086
|
+
defaultEnabled: false,
|
|
4082
4087
|
category: "Architecture",
|
|
4083
4088
|
recommendation: "Use the real ellipsis \"…\" (or `…`) instead of three dots. Good for labels like \"Rename…\" and \"Loading…\".",
|
|
4084
4089
|
create: (context) => ({ JSXText(jsxTextNode) {
|
|
@@ -4138,6 +4143,7 @@ const noVagueButtonLabel = defineRule({
|
|
|
4138
4143
|
title: "Vague button label",
|
|
4139
4144
|
tags: ["design", "test-noise"],
|
|
4140
4145
|
severity: "warn",
|
|
4146
|
+
defaultEnabled: false,
|
|
4141
4147
|
recommendation: "Name the action: \"Save changes\" instead of \"Continue\", \"Send invite\" instead of \"Submit\". The label is the button's accessible name.",
|
|
4142
4148
|
create: (context) => ({ JSXElement(jsxElementNode) {
|
|
4143
4149
|
const tagName = getOpeningElementTagName(jsxElementNode.openingElement);
|
|
@@ -4609,11 +4615,17 @@ const isCleanupFunctionLike = (node, knownCleanupFunctionNames, knownBoundSubscr
|
|
|
4609
4615
|
if (!isFunctionLike$2(node)) return false;
|
|
4610
4616
|
return containsReleaseLikeCall(node.body, knownCleanupFunctionNames, knownBoundSubscriptionNames);
|
|
4611
4617
|
};
|
|
4612
|
-
const isCleanupReturn = (returnedValue, knownCleanupFunctionNames, knownBoundSubscriptionNames) => {
|
|
4618
|
+
const isCleanupReturn = (returnedValue, knownCleanupFunctionNames, knownBoundSubscriptionNames, options = {}) => {
|
|
4613
4619
|
if (!returnedValue) return false;
|
|
4614
4620
|
const unwrappedValue = unwrapChainExpression$2(returnedValue);
|
|
4615
|
-
if (isNodeOfType(unwrappedValue, "
|
|
4621
|
+
if (isNodeOfType(unwrappedValue, "Literal") && unwrappedValue.value === null) return false;
|
|
4622
|
+
if (isNodeOfType(unwrappedValue, "Identifier")) {
|
|
4623
|
+
if (unwrappedValue.name === "undefined") return false;
|
|
4624
|
+
if (knownCleanupFunctionNames.has(unwrappedValue.name)) return true;
|
|
4625
|
+
return options.allowOpaqueReturn === true && !knownBoundSubscriptionNames.has(unwrappedValue.name);
|
|
4626
|
+
}
|
|
4616
4627
|
if (isCleanupReturningSubscribeLikeCallExpression(unwrappedValue)) return true;
|
|
4628
|
+
if (options.allowOpaqueReturn === true && !isSubscribeLikeCallExpression(unwrappedValue)) return true;
|
|
4617
4629
|
if (isCleanupFunctionLike(unwrappedValue, knownCleanupFunctionNames, knownBoundSubscriptionNames)) return true;
|
|
4618
4630
|
return false;
|
|
4619
4631
|
};
|
|
@@ -4634,12 +4646,14 @@ const findSubscribeLikeUsages = (callback) => {
|
|
|
4634
4646
|
if (isNodeOfType(child.callee, "Identifier") && TIMER_CALLEE_NAMES_REQUIRING_CLEANUP.has(child.callee.name)) {
|
|
4635
4647
|
usages.push({
|
|
4636
4648
|
kind: "timer",
|
|
4649
|
+
node: child,
|
|
4637
4650
|
resourceName: child.callee.name
|
|
4638
4651
|
});
|
|
4639
4652
|
return;
|
|
4640
4653
|
}
|
|
4641
4654
|
if (isNodeOfType(child.callee, "MemberExpression") && isNodeOfType(child.callee.property, "Identifier") && SUBSCRIPTION_METHOD_NAMES.has(child.callee.property.name)) usages.push({
|
|
4642
4655
|
kind: "subscribe",
|
|
4656
|
+
node: child,
|
|
4643
4657
|
resourceName: child.callee.property.name
|
|
4644
4658
|
});
|
|
4645
4659
|
});
|
|
@@ -4686,7 +4700,20 @@ const collectCleanupBindings = (effectCallback) => {
|
|
|
4686
4700
|
});
|
|
4687
4701
|
return bindings;
|
|
4688
4702
|
};
|
|
4689
|
-
const
|
|
4703
|
+
const getRangeStart = (node) => {
|
|
4704
|
+
const rangeStart = node.range?.[0];
|
|
4705
|
+
return typeof rangeStart === "number" ? rangeStart : null;
|
|
4706
|
+
};
|
|
4707
|
+
const cleanupReturnRunsAfterUsage = (returnStatement, usages) => {
|
|
4708
|
+
if (returnStatement.argument && isCleanupReturningSubscribeLikeCallExpression(returnStatement.argument)) return true;
|
|
4709
|
+
const returnStart = getRangeStart(returnStatement);
|
|
4710
|
+
if (returnStart === null) return true;
|
|
4711
|
+
return usages.some((usage) => {
|
|
4712
|
+
const usageStart = getRangeStart(usage.node);
|
|
4713
|
+
return usageStart === null || usageStart < returnStart;
|
|
4714
|
+
});
|
|
4715
|
+
};
|
|
4716
|
+
const effectHasCleanupReturn = (callback, usages) => {
|
|
4690
4717
|
if (!isNodeOfType(callback, "ArrowFunctionExpression") && !isNodeOfType(callback, "FunctionExpression")) return false;
|
|
4691
4718
|
if (!isNodeOfType(callback.body, "BlockStatement")) return isCleanupReturningSubscribeLikeCallExpression(callback.body);
|
|
4692
4719
|
const cleanupBindings = collectCleanupBindings(callback);
|
|
@@ -4694,7 +4721,8 @@ const effectHasCleanupRelease = (callback) => {
|
|
|
4694
4721
|
walkInsideStatementBlocks(callback.body, (child) => {
|
|
4695
4722
|
if (didFindCleanupReturn) return;
|
|
4696
4723
|
if (!isNodeOfType(child, "ReturnStatement")) return;
|
|
4697
|
-
if (
|
|
4724
|
+
if (!cleanupReturnRunsAfterUsage(child, usages)) return;
|
|
4725
|
+
if (isCleanupReturn(child.argument, cleanupBindings.cleanupFunctionNames, cleanupBindings.subscriptionNames, { allowOpaqueReturn: true })) didFindCleanupReturn = true;
|
|
4698
4726
|
});
|
|
4699
4727
|
return didFindCleanupReturn;
|
|
4700
4728
|
};
|
|
@@ -4710,7 +4738,7 @@ const effectNeedsCleanup = defineRule({
|
|
|
4710
4738
|
if (!callback) return;
|
|
4711
4739
|
const usages = findSubscribeLikeUsages(callback);
|
|
4712
4740
|
if (usages.length === 0) return;
|
|
4713
|
-
if (
|
|
4741
|
+
if (effectHasCleanupReturn(callback, usages)) return;
|
|
4714
4742
|
const firstUsage = usages[0];
|
|
4715
4743
|
const verb = firstUsage.kind === "timer" ? "schedules" : "subscribes via";
|
|
4716
4744
|
context.report({
|
|
@@ -9703,6 +9731,7 @@ const jsxNoConstructedContextValues = defineRule({
|
|
|
9703
9731
|
title: "Unstable context provider value",
|
|
9704
9732
|
tags: ["react-jsx-only"],
|
|
9705
9733
|
severity: "warn",
|
|
9734
|
+
disabledBy: ["react-compiler"],
|
|
9706
9735
|
recommendation: "Wrap the context value in `useMemo`, or move it outside the component.",
|
|
9707
9736
|
category: "Performance",
|
|
9708
9737
|
create: (context) => {
|
|
@@ -11785,6 +11814,7 @@ const jsxPascalCase = defineRule({
|
|
|
11785
11814
|
id: "jsx-pascal-case",
|
|
11786
11815
|
title: "Component name not PascalCase",
|
|
11787
11816
|
severity: "warn",
|
|
11817
|
+
defaultEnabled: false,
|
|
11788
11818
|
tags: ["test-noise"],
|
|
11789
11819
|
recommendation: "Rename custom JSX components to PascalCase.",
|
|
11790
11820
|
category: "Architecture",
|
|
@@ -14243,6 +14273,7 @@ const noArrayIndexKey = defineRule({
|
|
|
14243
14273
|
id: "no-array-index-key",
|
|
14244
14274
|
title: "Array index used as a key",
|
|
14245
14275
|
severity: "warn",
|
|
14276
|
+
defaultEnabled: false,
|
|
14246
14277
|
recommendation: "Use a stable `key` from your data instead of the array index.",
|
|
14247
14278
|
category: "Performance",
|
|
14248
14279
|
create: (context) => ({
|
|
@@ -15382,6 +15413,7 @@ const noDarkModeGlow = defineRule({
|
|
|
15382
15413
|
title: "Colored glow on dark background",
|
|
15383
15414
|
tags: ["design", "test-noise"],
|
|
15384
15415
|
severity: "warn",
|
|
15416
|
+
defaultEnabled: false,
|
|
15385
15417
|
recommendation: "Use a subtle `box-shadow` in neutral colors for depth, or a faint `border`. Colored glows on dark backgrounds look overdone.",
|
|
15386
15418
|
create: (context) => ({ JSXAttribute(node) {
|
|
15387
15419
|
const expression = getInlineStyleExpression(node);
|
|
@@ -15416,6 +15448,7 @@ const noDefaultProps = defineRule({
|
|
|
15416
15448
|
requires: ["react:19"],
|
|
15417
15449
|
tags: ["test-noise"],
|
|
15418
15450
|
severity: "warn",
|
|
15451
|
+
defaultEnabled: false,
|
|
15419
15452
|
recommendation: "React 19 drops `Component.defaultProps` for function components. Set the defaults in the destructured props instead: `function Foo({ size = \"md\", variant = \"primary\" })` instead of `Foo.defaultProps = { size: \"md\", variant: \"primary\" }`.",
|
|
15420
15453
|
create: (context) => ({ AssignmentExpression(node) {
|
|
15421
15454
|
if (node.operator !== "=") return;
|
|
@@ -17588,6 +17621,7 @@ const noGenericHandlerNames = defineRule({
|
|
|
17588
17621
|
id: "no-generic-handler-names",
|
|
17589
17622
|
title: "Vague event handler name",
|
|
17590
17623
|
severity: "warn",
|
|
17624
|
+
defaultEnabled: false,
|
|
17591
17625
|
tags: ["test-noise"],
|
|
17592
17626
|
recommendation: "Rename it to say what it does. For example `handleSubmit` could be `saveUserProfile`, and `handleClick` could be `toggleSidebar`.",
|
|
17593
17627
|
create: (context) => ({ JSXAttribute(node) {
|
|
@@ -17789,6 +17823,7 @@ const noGradientText = defineRule({
|
|
|
17789
17823
|
title: "Gradient text is hard to read",
|
|
17790
17824
|
tags: ["design", "test-noise"],
|
|
17791
17825
|
severity: "warn",
|
|
17826
|
+
defaultEnabled: false,
|
|
17792
17827
|
recommendation: "Use a solid text color so it stays readable. For emphasis, change the weight, size, or color instead of using a gradient.",
|
|
17793
17828
|
create: (context) => ({
|
|
17794
17829
|
JSXAttribute(node) {
|
|
@@ -18075,6 +18110,7 @@ const noJustifiedText = defineRule({
|
|
|
18075
18110
|
title: "Justified text without hyphens",
|
|
18076
18111
|
tags: ["test-noise"],
|
|
18077
18112
|
severity: "warn",
|
|
18113
|
+
defaultEnabled: false,
|
|
18078
18114
|
category: "Accessibility",
|
|
18079
18115
|
recommendation: "Use `text-align: left` for body text. If you must justify, add `hyphens: auto` and `overflow-wrap: break-word`.",
|
|
18080
18116
|
create: (context) => ({ JSXAttribute(node) {
|
|
@@ -20179,6 +20215,12 @@ const getReactDoctorStringSetting = (settings, settingName) => {
|
|
|
20179
20215
|
const settingValue = readOwnPropertyValue(bag, settingName);
|
|
20180
20216
|
return typeof settingValue === "string" ? settingValue : void 0;
|
|
20181
20217
|
};
|
|
20218
|
+
const getReactDoctorNumberSetting = (settings, settingName) => {
|
|
20219
|
+
const bag = readReactDoctorSettingsBag(settings);
|
|
20220
|
+
if (!bag) return void 0;
|
|
20221
|
+
const settingValue = readOwnPropertyValue(bag, settingName);
|
|
20222
|
+
return typeof settingValue === "number" && Number.isFinite(settingValue) ? settingValue : void 0;
|
|
20223
|
+
};
|
|
20182
20224
|
const getReactDoctorStringArraySetting = (settings, settingName) => {
|
|
20183
20225
|
const bag = readReactDoctorSettingsBag(settings);
|
|
20184
20226
|
if (!bag) return [];
|
|
@@ -20316,6 +20358,7 @@ const noPropTypes = defineRule({
|
|
|
20316
20358
|
requires: ["react:19"],
|
|
20317
20359
|
tags: ["test-noise"],
|
|
20318
20360
|
severity: "warn",
|
|
20361
|
+
defaultEnabled: false,
|
|
20319
20362
|
recommendation: "React 19 ignores `Component.propTypes`, so invalid props pass silently. Describe props with TypeScript types and add real runtime checks (or schema parsing) only where data can actually be wrong. Only runs on React 19+ projects.",
|
|
20320
20363
|
create: (context) => ({
|
|
20321
20364
|
AssignmentExpression(node) {
|
|
@@ -20344,6 +20387,7 @@ const noPureBlackBackground = defineRule({
|
|
|
20344
20387
|
title: "Pure black background",
|
|
20345
20388
|
tags: ["design", "test-noise"],
|
|
20346
20389
|
severity: "warn",
|
|
20390
|
+
defaultEnabled: false,
|
|
20347
20391
|
recommendation: "Nudge the background slightly toward your brand color, like `#0a0a0f` or Tailwind's `bg-gray-950`. Pure black looks harsh on modern screens.",
|
|
20348
20392
|
create: (context) => ({
|
|
20349
20393
|
JSXAttribute(node) {
|
|
@@ -21773,6 +21817,7 @@ const noSideTabBorder = defineRule({
|
|
|
21773
21817
|
title: "Thick one-sided border",
|
|
21774
21818
|
tags: ["design", "test-noise"],
|
|
21775
21819
|
severity: "warn",
|
|
21820
|
+
defaultEnabled: false,
|
|
21776
21821
|
recommendation: "Use a softer accent like an inset box-shadow, a background, or a thin border-bottom instead of a thick one-sided border.",
|
|
21777
21822
|
create: (context) => ({
|
|
21778
21823
|
JSXAttribute(node) {
|
|
@@ -23651,15 +23696,46 @@ const noUsememoSimpleExpression = defineRule({
|
|
|
23651
23696
|
});
|
|
23652
23697
|
//#endregion
|
|
23653
23698
|
//#region src/plugin/rules/design/no-wide-letter-spacing.ts
|
|
23699
|
+
const getJsxAttributeStringValue = (attributeValue) => {
|
|
23700
|
+
if (!attributeValue) return null;
|
|
23701
|
+
if (isNodeOfType(attributeValue, "Literal") && typeof attributeValue.value === "string") return attributeValue.value;
|
|
23702
|
+
if (isNodeOfType(attributeValue, "JSXExpressionContainer")) {
|
|
23703
|
+
const expression = attributeValue.expression;
|
|
23704
|
+
if (isNodeOfType(expression, "Literal") && typeof expression.value === "string") return expression.value;
|
|
23705
|
+
}
|
|
23706
|
+
return null;
|
|
23707
|
+
};
|
|
23708
|
+
const isTruthyBooleanJsxAttribute = (attributeValue) => {
|
|
23709
|
+
if (attributeValue === null) return true;
|
|
23710
|
+
if (isNodeOfType(attributeValue, "JSXExpressionContainer")) {
|
|
23711
|
+
const expression = attributeValue.expression;
|
|
23712
|
+
return isNodeOfType(expression, "Literal") && expression.value === true;
|
|
23713
|
+
}
|
|
23714
|
+
return false;
|
|
23715
|
+
};
|
|
23716
|
+
const hasUppercaseSiblingProp = (styleAttribute) => {
|
|
23717
|
+
const openingElement = styleAttribute.parent;
|
|
23718
|
+
if (!openingElement || !isNodeOfType(openingElement, "JSXOpeningElement")) return false;
|
|
23719
|
+
for (const attribute of openingElement.attributes ?? []) {
|
|
23720
|
+
if (!isNodeOfType(attribute, "JSXAttribute")) continue;
|
|
23721
|
+
if (!isNodeOfType(attribute.name, "JSXIdentifier")) continue;
|
|
23722
|
+
const attributeName = attribute.name.name;
|
|
23723
|
+
if (attributeName === "uppercase" && isTruthyBooleanJsxAttribute(attribute.value)) return true;
|
|
23724
|
+
if (attributeName === "textTransform" && getJsxAttributeStringValue(attribute.value) === "uppercase") return true;
|
|
23725
|
+
}
|
|
23726
|
+
return false;
|
|
23727
|
+
};
|
|
23654
23728
|
const noWideLetterSpacing = defineRule({
|
|
23655
23729
|
id: "no-wide-letter-spacing",
|
|
23656
23730
|
title: "Wide letter spacing on body text",
|
|
23657
23731
|
severity: "warn",
|
|
23732
|
+
defaultEnabled: false,
|
|
23658
23733
|
tags: ["test-noise"],
|
|
23659
23734
|
recommendation: "Save wide letter-spacing (over 0.05em) for short uppercase labels, nav items, and buttons, not body text.",
|
|
23660
23735
|
create: (context) => ({ JSXAttribute(node) {
|
|
23661
23736
|
const expression = getInlineStyleExpression(node);
|
|
23662
23737
|
if (!expression) return;
|
|
23738
|
+
if (hasUppercaseSiblingProp(node)) return;
|
|
23663
23739
|
let isUppercase = false;
|
|
23664
23740
|
let letterSpacingProperty = null;
|
|
23665
23741
|
let letterSpacingEm = null;
|
|
@@ -23737,6 +23813,7 @@ const noZIndex9999 = defineRule({
|
|
|
23737
23813
|
title: "Excessively high z-index",
|
|
23738
23814
|
tags: ["test-noise"],
|
|
23739
23815
|
severity: "warn",
|
|
23816
|
+
defaultEnabled: false,
|
|
23740
23817
|
recommendation: "Pick a small z-index scale, like dropdown 10, modal 20, toast 30. To layer something on top, use `isolation: isolate` instead of bigger numbers.",
|
|
23741
23818
|
create: (context) => ({
|
|
23742
23819
|
JSXAttribute(node) {
|
|
@@ -24512,6 +24589,7 @@ const preferEs6Class = defineRule({
|
|
|
24512
24589
|
id: "prefer-es6-class",
|
|
24513
24590
|
title: "createClass instead of ES6 class",
|
|
24514
24591
|
severity: "warn",
|
|
24592
|
+
defaultEnabled: false,
|
|
24515
24593
|
recommendation: "Pick one component style for the whole codebase: `class extends React.Component` (default) or `createReactClass` (legacy).",
|
|
24516
24594
|
category: "Architecture",
|
|
24517
24595
|
create: (context) => {
|
|
@@ -24822,6 +24900,7 @@ const preferModuleScopeStaticValue = defineRule({
|
|
|
24822
24900
|
tags: ["test-noise"],
|
|
24823
24901
|
severity: "warn",
|
|
24824
24902
|
category: "Architecture",
|
|
24903
|
+
disabledBy: ["react-compiler"],
|
|
24825
24904
|
recommendation: "Move the value above the component, at the top of the file. It doesn't use local state, so rebuilding it each update is wasted and makes it look new every time.",
|
|
24826
24905
|
create: (context) => ({ VariableDeclarator(node) {
|
|
24827
24906
|
if (!isNodeOfType(node.id, "Identifier")) return;
|
|
@@ -26778,76 +26857,22 @@ const rerenderTransitionsScroll = defineRule({
|
|
|
26778
26857
|
} })
|
|
26779
26858
|
});
|
|
26780
26859
|
//#endregion
|
|
26860
|
+
//#region src/plugin/utils/define-retired-rule.ts
|
|
26861
|
+
const defineRetiredRule = (rule) => defineRule({
|
|
26862
|
+
...rule,
|
|
26863
|
+
defaultEnabled: false,
|
|
26864
|
+
lifecycle: "retired",
|
|
26865
|
+
create: () => ({})
|
|
26866
|
+
});
|
|
26867
|
+
//#endregion
|
|
26781
26868
|
//#region src/plugin/rules/react-native/rn-animate-layout-property.ts
|
|
26782
|
-
const
|
|
26783
|
-
"width",
|
|
26784
|
-
"height",
|
|
26785
|
-
"top",
|
|
26786
|
-
"left",
|
|
26787
|
-
"right",
|
|
26788
|
-
"bottom",
|
|
26789
|
-
"minWidth",
|
|
26790
|
-
"minHeight",
|
|
26791
|
-
"maxWidth",
|
|
26792
|
-
"maxHeight",
|
|
26793
|
-
"margin",
|
|
26794
|
-
"marginTop",
|
|
26795
|
-
"marginBottom",
|
|
26796
|
-
"marginLeft",
|
|
26797
|
-
"marginRight",
|
|
26798
|
-
"marginHorizontal",
|
|
26799
|
-
"marginVertical",
|
|
26800
|
-
"padding",
|
|
26801
|
-
"paddingTop",
|
|
26802
|
-
"paddingBottom",
|
|
26803
|
-
"paddingLeft",
|
|
26804
|
-
"paddingRight",
|
|
26805
|
-
"paddingHorizontal",
|
|
26806
|
-
"paddingVertical",
|
|
26807
|
-
"flex",
|
|
26808
|
-
"flexBasis",
|
|
26809
|
-
"flexGrow",
|
|
26810
|
-
"flexShrink",
|
|
26811
|
-
"borderWidth",
|
|
26812
|
-
"borderTopWidth",
|
|
26813
|
-
"borderBottomWidth",
|
|
26814
|
-
"borderLeftWidth",
|
|
26815
|
-
"borderRightWidth",
|
|
26816
|
-
"fontSize",
|
|
26817
|
-
"lineHeight",
|
|
26818
|
-
"letterSpacing"
|
|
26819
|
-
]);
|
|
26820
|
-
const findReturnedObject = (callback) => {
|
|
26821
|
-
if (!isNodeOfType(callback, "ArrowFunctionExpression") && !isNodeOfType(callback, "FunctionExpression")) return null;
|
|
26822
|
-
const body = callback.body;
|
|
26823
|
-
if (isNodeOfType(body, "ObjectExpression")) return body;
|
|
26824
|
-
if (!isNodeOfType(body, "BlockStatement")) return null;
|
|
26825
|
-
for (const stmt of body.body ?? []) if (isNodeOfType(stmt, "ReturnStatement") && isNodeOfType(stmt.argument, "ObjectExpression")) return stmt.argument;
|
|
26826
|
-
return null;
|
|
26827
|
-
};
|
|
26828
|
-
const rnAnimateLayoutProperty = defineRule({
|
|
26869
|
+
const rnAnimateLayoutProperty = defineRetiredRule({
|
|
26829
26870
|
id: "rn-animate-layout-property",
|
|
26830
26871
|
title: "Animating a layout property",
|
|
26831
26872
|
tags: ["test-noise"],
|
|
26832
26873
|
requires: ["react-native"],
|
|
26833
|
-
severity: "
|
|
26834
|
-
recommendation: "
|
|
26835
|
-
create: (context) => ({ CallExpression(node) {
|
|
26836
|
-
if (!isNodeOfType(node.callee, "Identifier") || node.callee.name !== "useAnimatedStyle") return;
|
|
26837
|
-
const callback = node.arguments?.[0];
|
|
26838
|
-
if (!callback) return;
|
|
26839
|
-
const returnedObject = findReturnedObject(callback);
|
|
26840
|
-
if (!returnedObject) return;
|
|
26841
|
-
for (const property of returnedObject.properties ?? []) {
|
|
26842
|
-
if (!isNodeOfType(property, "Property")) continue;
|
|
26843
|
-
if (!isNodeOfType(property.key, "Identifier")) continue;
|
|
26844
|
-
if (!REANIMATED_LAYOUT_KEYS.has(property.key.name)) continue;
|
|
26845
|
-
context.report({
|
|
26846
|
-
node: property,
|
|
26847
|
-
message: `Your users see stutter when useAnimatedStyle animates "${property.key.name}" on the layout thread.`
|
|
26848
|
-
});
|
|
26849
|
-
}
|
|
26850
|
-
} })
|
|
26874
|
+
severity: "warn",
|
|
26875
|
+
recommendation: "Reanimated useAnimatedStyle runs on the UI thread; layout-affecting properties driven by animation helpers, interpolate, or shared values are valid."
|
|
26851
26876
|
});
|
|
26852
26877
|
//#endregion
|
|
26853
26878
|
//#region src/plugin/rules/react-native/rn-animation-reaction-as-derived.ts
|
|
@@ -27052,7 +27077,6 @@ const LEGACY_EXPO_PACKAGE_REPLACEMENTS = new Map([
|
|
|
27052
27077
|
["expo-av", "expo-audio for audio and expo-video for video"],
|
|
27053
27078
|
["expo-permissions", "the permissions API in each module (e.g. Camera.requestPermissionsAsync())"],
|
|
27054
27079
|
["expo-app-loading", "expo-splash-screen"],
|
|
27055
|
-
["expo-linear-gradient", "the `backgroundImage` CSS gradient style prop (New Architecture) or expo-linear-gradient's successor"],
|
|
27056
27080
|
["react-native-fast-image", "expo-image (drop-in with caching, placeholders, and crossfades)"]
|
|
27057
27081
|
]);
|
|
27058
27082
|
const EXPO_UI_MODULE_SOURCES = new Set([
|
|
@@ -27207,6 +27231,10 @@ const RECYCLABLE_LIST_PACKAGES = {
|
|
|
27207
27231
|
LegendList: ["@legendapp/list"]
|
|
27208
27232
|
};
|
|
27209
27233
|
const SIZING_HINT_ATTRIBUTE_NAMES = new Set(["estimatedItemSize", "estimatedListSize"]);
|
|
27234
|
+
const isFlashListV2OrNewer = (context) => {
|
|
27235
|
+
const flashListMajorVersion = getReactDoctorNumberSetting(context.settings, "shopifyFlashListMajorVersion");
|
|
27236
|
+
return flashListMajorVersion !== void 0 && flashListMajorVersion >= 2;
|
|
27237
|
+
};
|
|
27210
27238
|
const isEmptyArrayLiteral = (node) => {
|
|
27211
27239
|
if (!isNodeOfType(node.value, "JSXExpressionContainer")) return false;
|
|
27212
27240
|
const expression = node.value.expression;
|
|
@@ -27228,6 +27256,7 @@ const rnListMissingEstimatedItemSize = defineRule({
|
|
|
27228
27256
|
break;
|
|
27229
27257
|
}
|
|
27230
27258
|
if (!canonicalRecyclerName) return;
|
|
27259
|
+
if (canonicalRecyclerName === "FlashList" && isFlashListV2OrNewer(context)) return;
|
|
27231
27260
|
let hasSizingHint = false;
|
|
27232
27261
|
let dataIsEmptyLiteral = false;
|
|
27233
27262
|
let hasDataProp = false;
|
|
@@ -28170,37 +28199,14 @@ const rnNoSingleElementStyleArray = defineRule({
|
|
|
28170
28199
|
} })
|
|
28171
28200
|
});
|
|
28172
28201
|
//#endregion
|
|
28173
|
-
//#region src/plugin/rules/react-native/utils/scrollview_names.ts
|
|
28174
|
-
const SCROLLVIEW_NAMES = new Set([
|
|
28175
|
-
"ScrollView",
|
|
28176
|
-
"FlatList",
|
|
28177
|
-
"SectionList",
|
|
28178
|
-
"VirtualizedList",
|
|
28179
|
-
"KeyboardAwareScrollView"
|
|
28180
|
-
]);
|
|
28181
|
-
//#endregion
|
|
28182
28202
|
//#region src/plugin/rules/react-native/rn-prefer-content-inset-adjustment.ts
|
|
28183
|
-
const rnPreferContentInsetAdjustment =
|
|
28203
|
+
const rnPreferContentInsetAdjustment = defineRetiredRule({
|
|
28184
28204
|
id: "rn-prefer-content-inset-adjustment",
|
|
28185
|
-
title: "
|
|
28205
|
+
title: "Manual safe-area inset adjustment",
|
|
28186
28206
|
tags: ["test-noise"],
|
|
28187
28207
|
requires: ["react-native"],
|
|
28188
28208
|
severity: "warn",
|
|
28189
|
-
recommendation: "
|
|
28190
|
-
create: (context) => ({ JSXElement(node) {
|
|
28191
|
-
if (resolveJsxElementName(node.openingElement) !== "SafeAreaView") return;
|
|
28192
|
-
for (const child of node.children ?? []) {
|
|
28193
|
-
if (!isNodeOfType(child, "JSXElement")) continue;
|
|
28194
|
-
const childName = resolveJsxElementName(child.openingElement);
|
|
28195
|
-
if (!childName || !SCROLLVIEW_NAMES.has(childName)) continue;
|
|
28196
|
-
if (childName === "KeyboardAwareScrollView") continue;
|
|
28197
|
-
context.report({
|
|
28198
|
-
node,
|
|
28199
|
-
message: `Your users render an extra wrapper view from <SafeAreaView> around <${childName}>.`
|
|
28200
|
-
});
|
|
28201
|
-
return;
|
|
28202
|
-
}
|
|
28203
|
-
} })
|
|
28209
|
+
recommendation: "Prefer native content inset adjustment only when it replaces manual inset plumbing; SafeAreaView wrappers are valid and intentionally ignored."
|
|
28204
28210
|
});
|
|
28205
28211
|
//#endregion
|
|
28206
28212
|
//#region src/react-native-dependency-names.ts
|
|
@@ -28586,6 +28592,15 @@ const rnPressableSharedValueMutation = defineRule({
|
|
|
28586
28592
|
}
|
|
28587
28593
|
});
|
|
28588
28594
|
//#endregion
|
|
28595
|
+
//#region src/plugin/rules/react-native/utils/scrollview_names.ts
|
|
28596
|
+
const SCROLLVIEW_NAMES = new Set([
|
|
28597
|
+
"ScrollView",
|
|
28598
|
+
"FlatList",
|
|
28599
|
+
"SectionList",
|
|
28600
|
+
"VirtualizedList",
|
|
28601
|
+
"KeyboardAwareScrollView"
|
|
28602
|
+
]);
|
|
28603
|
+
//#endregion
|
|
28589
28604
|
//#region src/plugin/rules/react-native/rn-scrollview-dynamic-padding.ts
|
|
28590
28605
|
const rnScrollviewDynamicPadding = defineRule({
|
|
28591
28606
|
id: "rn-scrollview-dynamic-padding",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oxlint-plugin-react-doctor",
|
|
3
|
-
"version": "0.2.18-dev.
|
|
3
|
+
"version": "0.2.18-dev.eba20ae",
|
|
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",
|