An open source design system that's fully customizable and agent ready
TypeScript
chore(lint): flag truthiness guards on ReactNode slot values (#9470)
Cindy Zhang790f078d671c
diff --git a/eslint.config.js b/eslint.config.jsindex b315b4d018..8828404355 100644--- a/eslint.config.js+++ b/eslint.config.js@@ -11,6 +11,7 @@ import reactCompiler from 'eslint-plugin-react-compiler';import astryxPlugin from './internal/eslint-plugin-astryx/index.js';import {scope as internalBarrelScope} from './internal/eslint-plugin-astryx/no-internal-barrel-import.js';import {scope as nullishGuardScope} from './internal/eslint-plugin-astryx/no-nullish-jsx-guard.js';+import {scope as truthyGuardScope} from './internal/eslint-plugin-astryx/no-truthy-jsx-guard.js';import {scope as privateAttributeScope} from './internal/eslint-plugin-astryx/no-raw-private-attribute.js';/* global process */@@ -47,6 +48,19 @@ const internalBarrelBaseline = JSON.parse(),);+// Truthiness guards on ReactNode values that existed when+// `@astryx/no-truthy-jsx-guard` arrived, by repo-relative file, once per+// guard. The list only shrinks.+const truthyGuardBaseline = JSON.parse(+ readFileSync(+ path.join(+ import.meta.dirname,+ 'internal/eslint-plugin-astryx/no-truthy-jsx-guard.baseline.json',+ ),+ 'utf8',+ ),+);+// Private `data-astryx-*` attributes written by hand before// `@astryx/no-raw-private-attribute` arrived, by repo-relative file, once per// site. The list only shrinks.@@ -930,6 +944,25 @@ export default defineConfig('@astryx/no-nullish-jsx-guard': reactSeverity,},},+ // A slot value can be `0`. A truthiness guard in front of its JSX then+ // renders a stray "0" (`&&`) or drops the slot (`? :`), so a slot's+ // presence is decided by `isRenderable` here too. The rule reads types, so+ // its scope is core, which the type-aware block above parses with the+ // project service. The guards that predate the rule are listed in the+ // baseline, once per guard; one more is reported (an error in strict mode).+ {+ files: truthyGuardScope.files,+ ignores: truthyGuardScope.ignores,+ plugins: {+ '@astryx': astryxEslintPlugin,+ },+ rules: {+ '@astryx/no-truthy-jsx-guard': [+ reactSeverity,+ {baseline: truthyGuardBaseline, root: import.meta.dirname},+ ],+ },+ },// A private `data-astryx-*` attribute is written once, in its owner module// under packages/<package>/src/privateAttributes, which exports ready-made// styles, setter props and readers (`architecture:public-component-api`diff --git a/internal/eslint-plugin-astryx/README.md b/internal/eslint-plugin-astryx/README.mdindex 875f2e96eb..7d9d76f27a 100644--- a/internal/eslint-plugin-astryx/README.md+++ b/internal/eslint-plugin-astryx/README.md@@ -603,6 +603,38 @@ The presets ship it as a warning. The repository config enforces it in core andSee: https://github.com/meta/astryx/issues/2538+### `@astryx/no-truthy-jsx-guard`++Flags a bare truthiness guard on a `ReactNode` value in front of rendered JSX. A `ReactNode` can be `0`: `0 && <Slot />` evaluates to `0`, so React renders a stray "0" where the slot should be, and a ternary drops the slot although `0` is content that renders. Use `isRenderable(value)` from `@astryxdesign/core/utils`; it is false only for `null`, `undefined`, `true`, `false` and `''`.++**Scope:** the guard is a bare value reference (`icon`, `item.icon`) in an `&&` chain whose right side is JSX, or the test of a ternary that renders JSX or `null`. The rule reads types and flags only a value whose type can be both a number and an object, as `ReactNode` and `ReactNode | IconType` can. A boolean, a string, a plain number or a data object is not flagged, and neither is a converted guard (`!!icon`, `Boolean(icon)`, a `hasIcon` local) or a value typed `any`.++**Bad:**++```tsx+{+ startIcon && <Slot>{startIcon}</Slot>;+}+{+ label ? <span>{label}</span> : null;+}+```++**Good:**++```tsx+import {isRenderable} from '@astryxdesign/core/utils';++{+ isRenderable(startIcon) && <Slot>{startIcon}</Slot>;+}+{+ isOpen && <Panel />; // a boolean guard+}+```++The rule needs type information (`parserOptions.projectService`) and stops with an error without it, so it is not in the presets. The repository config enforces it in core, where it is an error in strict mode. Other packages read core's types from core's build output, so a core type there is `any` before a build and real after it; the rule would give a different result per build state, so they are out of scope. The guards that predate it are listed in `no-truthy-jsx-guard.baseline.json`, once per guard, and that many stay allowed until they move to `isRenderable`; one more is reported. Regenerate the list with `node internal/eslint-plugin-astryx/no-truthy-jsx-guard.baseline.mjs` (`--check` verifies it). A guard that is right as written says so with `// eslint-disable-next-line @astryx/no-truthy-jsx-guard -- <reason>`. The rule also provides an ESLint suggestion that wraps the guard in `isRenderable(value)` (add the import manually).+### `@astryx/focus-outline-keyboard-only`Flags a focus outline written against `:focus` or `:focus-within` inside `stylex.create()`. A focus outline is a **keyboard** affordance; both of those selectors also match a plain mouse click, so the ring gets shown to pointer users too — most easily missed on the paths where focus is restored programmatically (an overlay that returns focus to its trigger after a click-to-dismiss puts the ring back up with no keyboard involved).diff --git a/internal/eslint-plugin-astryx/index.js b/internal/eslint-plugin-astryx/index.jsindex 5bfa843f18..df86c5e6ea 100644--- a/internal/eslint-plugin-astryx/index.js+++ b/internal/eslint-plugin-astryx/index.js@@ -11,6 +11,7 @@* - no-raw-paragraph: Disallows components from rendering a <p> by default (render <div> so any content composes)* - no-style-only-wrapper: Disallows div/span wrappers that only style a single Astryx component (use xstyle)* - no-nullish-jsx-guard: Flags `!= null` JSX render guards for rendered values (use isRenderable so false/''/true slots don't leak an empty element)+ * - no-truthy-jsx-guard: Flags a truthiness guard on a ReactNode value in front of JSX (a 0 slot renders a stray "0" or is dropped; use isRenderable). Reads types, so it is not in the presets* - no-raw-intl-locale: Forbids raw Intl formatting/comparison outside the approved i18n infrastructure boundary, navigator.language(s) as a locale source, and date-helper calls without provider locale* - no-unguarded-ime-keydown: Flags an onKeyDown on an editable surface that branches on command keys without an IME composition guard (isImeKeyEvent/isComposing)* - no-physical-properties: Flags physical left/right CSS properties and unsafe logical-centering transform pairs@@ -42,6 +43,7 @@ import noClassnameClobberRule from './no-classname-clobber.js';import noHardcodedAnchorRule from './no-hardcoded-anchor.js';import noRawParagraphRule from './no-raw-paragraph.js';import noNullishJsxGuardRule from './no-nullish-jsx-guard.js';+import noTruthyJsxGuardRule from './no-truthy-jsx-guard.js';import noRawIntlLocaleRule from './no-raw-intl-locale.js';import noUnguardedImeKeydownRule from './no-unguarded-ime-keydown.js';import noBorderShorthandRule from './no-border-shorthand.js';@@ -347,6 +349,7 @@ const plugin = {'no-hardcoded-anchor': noHardcodedAnchorRule,'no-raw-paragraph': noRawParagraphRule,'no-nullish-jsx-guard': noNullishJsxGuardRule,+ 'no-truthy-jsx-guard': noTruthyJsxGuardRule,'no-raw-intl-locale': noRawIntlLocaleRule,'no-unguarded-ime-keydown': noUnguardedImeKeydownRule,'no-border-shorthand': noBorderShorthandRule,diff --git a/internal/eslint-plugin-astryx/no-truthy-jsx-guard.baseline.json b/internal/eslint-plugin-astryx/no-truthy-jsx-guard.baseline.jsonnew file mode 100644index 0000000000..5e3bfb04f7--- /dev/null+++ b/internal/eslint-plugin-astryx/no-truthy-jsx-guard.baseline.json@@ -0,0 +1,44 @@+{+ "packages/core/src/Avatar/Avatar.tsx": ["status"],+ "packages/core/src/Breadcrumbs/BreadcrumbItem.tsx": ["startIcon"],+ "packages/core/src/Button/Button.tsx": ["endContent", "icon"],+ "packages/core/src/Lightbox/Lightbox.tsx": ["currentItem.caption"],+ "packages/core/src/NavMenu/NavHeadingMenuItem.tsx": ["description"],+ "packages/core/src/SegmentedControl/SegmentedControlItem.tsx": ["icon"],+ "packages/core/src/SideNav/SideNav.tsx": [+ "footerIcons",+ "footerIcons",+ "topContent"+ ],+ "packages/core/src/SideNav/SideNavHeading.tsx": [+ "headerEndContent",+ "icon",+ "icon",+ "icon",+ "icon",+ "icon",+ "icon"+ ],+ "packages/core/src/SideNav/SideNavItem.tsx": ["endContent"],+ "packages/core/src/SideNav/SideNavSection.tsx": ["endContent"],+ "packages/core/src/TabList/Tab.tsx": ["displayIcon", "endContent"],+ "packages/core/src/Tokenizer/Tokenizer.tsx": ["startIcon", "startIcon"],+ "packages/core/src/TopNav/TopNav.tsx": [+ "endContent",+ "heading",+ "heading",+ "mobileContent",+ "mobileContent",+ "resolvedStartContent"+ ],+ "packages/core/src/TopNav/TopNavHeading.tsx": [+ "headerEndContent",+ "logo",+ "logo",+ "logo",+ "logo",+ "logo"+ ],+ "packages/core/src/TopNav/TopNavMegaMenuItem.tsx": ["icon", "icon"],+ "packages/core/src/TopNav/TopNavMenu.tsx": ["item.icon"]+}diff --git a/internal/eslint-plugin-astryx/no-truthy-jsx-guard.baseline.mjs b/internal/eslint-plugin-astryx/no-truthy-jsx-guard.baseline.mjsnew file mode 100644index 0000000000..2affdaddac--- /dev/null+++ b/internal/eslint-plugin-astryx/no-truthy-jsx-guard.baseline.mjs@@ -0,0 +1,29 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file no-truthy-jsx-guard.baseline.mjs+ * @description Writes (or, with --check, verifies) the baseline that+ * `@astryx/no-truthy-jsx-guard` allows: each guarded ReactNode value, per+ * file, once per truthiness guard that predates the rule. Run it after+ * moving guards to `isRenderable`, or after merging main into a branch that+ * changes the rule, so the list only names guards that still exist.+ *+ * node internal/eslint-plugin-astryx/no-truthy-jsx-guard.baseline.mjs [--check]+ */++import path from 'node:path';+import {scope} from './no-truthy-jsx-guard.js';+import {runRuleBaseline} from './rule-baseline.mjs';++await runRuleBaseline({+ ruleId: '@astryx/no-truthy-jsx-guard',+ scope,+ targets: ['packages/core/src'],+ baselineFile: path.join(+ import.meta.dirname,+ 'no-truthy-jsx-guard.baseline.json',+ ),+ entryFromMessage: message => /^`([^`]*)`/.exec(message)?.[1] ?? null,+ unique: false,+ noun: 'truthiness guards',+});diff --git a/internal/eslint-plugin-astryx/no-truthy-jsx-guard.js b/internal/eslint-plugin-astryx/no-truthy-jsx-guard.jsnew file mode 100644index 0000000000..fc6cf561c6--- /dev/null+++ b/internal/eslint-plugin-astryx/no-truthy-jsx-guard.js@@ -0,0 +1,215 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file no-truthy-jsx-guard.js+ * @description Disallow a bare truthiness guard on a ReactNode value in+ * front of rendered JSX.+ *+ * {startIcon && <Slot>{startIcon}</Slot>}+ * {label ? <span>{label}</span> : null}+ *+ * A ReactNode can be `0`. `0 && <Slot />` evaluates to `0`, so React renders+ * a stray "0" where the slot should be. The ternary form renders no stray+ * text, but it drops the slot for `0`, which is content that renders.+ * `isRenderable(value)` from `@astryxdesign/core/utils` is the one presence+ * check for a slot: it is false only for null, undefined, true, false and ''.+ *+ * Scope:+ * - The guard is a bare value reference (`icon`, `item.icon`, `props.icon`)+ * in an `&&` chain whose right side is JSX, or the test of a ternary that+ * renders JSX or `null`/`undefined`.+ * - The value's type can be a number and can be an object, as `ReactNode`+ * and `ReactNode | IconType` can. A boolean, a string, a plain number or a+ * data object is not a slot value and is not flagged.+ *+ * The rule reads types, so the file must be parsed with type information+ * (`parserOptions.projectService`). Without it the rule stops with an error,+ * so a config that loses type information cannot pass silently.+ *+ * Options: `{baseline: {[repoRelativeFile]: string[]}, root: string}`. The+ * baseline lists, per file, each guarded value once per guard that predates+ * enforcement. That many guards of the value stay allowed until migrated;+ * one more is reported.+ *+ * Known limitations:+ * - A guard that converts the value first (`!!icon`, `Boolean(icon)`, a+ * `hasIcon` local) is not flagged. It renders no stray "0", and the type of+ * the derived boolean does not show where it came from.+ * - A value typed `any` is not flagged.+ */++import ts from 'typescript';+import {baselineAllowance} from './rule-baseline.mjs';++/**+ * Where the repository config enforces the rule. Core only: another package+ * reads Core's types from Core's build output. Before a build they are `any`,+ * after it they are real, so the result there would change with build state.+ */+export const scope = {+ files: ['packages/core/src/**/*.{ts,tsx}'],+ ignores: [+ 'packages/core/src/theme/**',+ '**/*.test.{ts,tsx}',+ '**/*.stories.{ts,tsx}',+ ],+};++const NUMBER_FLAGS = ts.TypeFlags.NumberLike | ts.TypeFlags.BigIntLike;+const OBJECT_FLAGS =+ ts.TypeFlags.Object | ts.TypeFlags.NonPrimitive | ts.TypeFlags.Intersection;+const UNKNOWN_FLAGS = ts.TypeFlags.Any | ts.TypeFlags.Unknown;++function isJSX(node) {+ return node?.type === 'JSXElement' || node?.type === 'JSXFragment';+}++function isNullish(node) {+ return (+ (node?.type === 'Literal' && node.value === null) ||+ (node?.type === 'Identifier' && node.name === 'undefined')+ );+}++/** `icon`, `item.icon`, `item?.icon`, `item.icon!`; not a call or a test. */+function isValueReference(node) {+ switch (node?.type) {+ case 'Identifier':+ return node.name !== 'undefined';+ case 'MemberExpression':+ return true;+ case 'ChainExpression':+ return node.expression.type === 'MemberExpression';+ case 'TSNonNullExpression':+ return isValueReference(node.expression);+ default:+ return false;+ }+}++/** Flatten a left-nested `&&` chain into its operands. */+function flattenAnd(node) {+ if (node?.type === 'LogicalExpression' && node.operator === '&&') {+ return [...flattenAnd(node.left), ...flattenAnd(node.right)];+ }+ return [node];+}++/**+ * Can a value of this type be both a number and an object? `ReactNode` can+ * (`0`, an element), so can a union that adds a component type to it. A type+ * parameter is read through its constraint.+ */+function isNodeType(type, checker) {+ const resolved = checker.getBaseConstraintOfType(type) ?? type;+ const parts = resolved.isUnion() ? resolved.types : [resolved];+ let canBeNumber = false;+ let canBeObject = false;+ for (const part of parts) {+ if (part.flags & UNKNOWN_FLAGS) {+ return false;+ }+ if (part.flags & NUMBER_FLAGS) {+ canBeNumber = true;+ } else if (part.flags & OBJECT_FLAGS) {+ canBeObject = true;+ }+ }+ return canBeNumber && canBeObject;+}++const rule = {+ meta: {+ type: 'problem',+ docs: {+ description:+ 'Disallow a truthiness guard on a ReactNode value in front of rendered JSX — use isRenderable() so a 0 slot renders as content, never as stray text',+ category: 'Best Practices',+ recommended: false,+ requiresTypeChecking: true,+ },+ hasSuggestions: true,+ messages: {+ andGuard:+ '`{{value}}` is a ReactNode and can be `0`. Then `{{value}} && <…>` ' ++ 'renders a stray "0" in place of the slot. Use ' ++ '`isRenderable({{value}})` from `@astryxdesign/core/utils`; it is ' ++ 'false only for null, undefined, true, false and "".',+ ternaryGuard:+ '`{{value}}` is a ReactNode and can be `0`, which renders as ' ++ 'content, but this truthiness test drops the slot for it. Use ' ++ '`isRenderable({{value}})` from `@astryxdesign/core/utils`; it is ' ++ 'false only for null, undefined, true, false and "".',+ },+ schema: [+ {+ type: 'object',+ properties: {+ baseline: {+ type: 'object',+ additionalProperties: {type: 'array', items: {type: 'string'}},+ },+ root: {type: 'string'},+ },+ additionalProperties: false,+ },+ ],+ },+ create(context) {+ const sourceCode = context.sourceCode ?? context.getSourceCode();+ const services = sourceCode.parserServices;+ if (services?.program == null || services.esTreeNodeToTSNodeMap == null) {+ throw new Error(+ '@astryx/no-truthy-jsx-guard reads types. Parse the file with ' ++ 'typescript-eslint and parserOptions.projectService.',+ );+ }+ const checker = services.program.getTypeChecker();+ const isAllowed = baselineAllowance(context);++ function isNodeValue(node) {+ const tsNode = services.esTreeNodeToTSNodeMap.get(node);+ return isNodeType(checker.getTypeAtLocation(tsNode), checker);+ }++ function checkGuards(test, messageId) {+ for (const guard of flattenAnd(test)) {+ if (!isValueReference(guard) || !isNodeValue(guard)) {+ continue;+ }+ const value = sourceCode.getText(guard);+ if (isAllowed(value)) {+ continue;+ }+ context.report({+ node: guard,+ messageId,+ data: {value},+ suggest: [+ {+ desc: `Replace with isRenderable(${value})`,+ fix: fixer => fixer.replaceText(guard, `isRenderable(${value})`),+ },+ ],+ });+ }+ }++ return {+ // `{icon && <Slot>{icon}</Slot>}`+ LogicalExpression(node) {+ if (node.operator === '&&' && isJSX(node.right)) {+ checkGuards(node.left, 'andGuard');+ }+ },+ // `{icon ? <Slot>{icon}</Slot> : null}`+ ConditionalExpression(node) {+ if (isJSX(node.consequent) && isNullish(node.alternate)) {+ checkGuards(node.test, 'ternaryGuard');+ }+ },+ };+ },+};++export default rule;diff --git a/internal/eslint-plugin-astryx/no-truthy-jsx-guard.test.mjs b/internal/eslint-plugin-astryx/no-truthy-jsx-guard.test.mjsnew file mode 100644index 0000000000..e305815ce6--- /dev/null+++ b/internal/eslint-plugin-astryx/no-truthy-jsx-guard.test.mjs@@ -0,0 +1,166 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file no-truthy-jsx-guard.test.mjs+ * @description Tests for the Astryx no-truthy-jsx-guard ESLint rule.+ */++import {RuleTester} from 'eslint';+import tseslint from 'typescript-eslint';+import rule from './no-truthy-jsx-guard.js';++// The rule reads types. Each case is a file that no tsconfig includes, so the+// project service gives it the default project.+const tester = new RuleTester({+ languageOptions: {+ parser: tseslint.parser,+ parserOptions: {+ ecmaFeatures: {jsx: true},+ projectService: {allowDefaultProject: ['*.tsx']},+ tsconfigRootDir: import.meta.dirname,+ },+ },+});++const filename = `${import.meta.dirname}/fixture.tsx`;++const header = `+import type {ReactNode} from 'react';+type IconType = (props: {size: number}) => ReactNode;+declare function isRenderable(node: ReactNode): boolean;+declare const Slot: (props: {children?: ReactNode}) => ReactNode;+`;++function file(body) {+ return {code: `${header}\n${body}`, filename};+}++/**+ * One report on `value`, whose suggestion wraps its `occurrence`-th guard+ * (1-based) in `isRenderable`.+ */+function flagged(body, messageId, value, occurrence = 1) {+ const guard = messageId === 'andGuard' ? `${value} &&` : `${value} ?`;+ const parts = body.split(guard);+ const fixed =+ parts.slice(0, occurrence).join(guard) ++ `isRenderable(${value}) ${guard.slice(value.length + 1)}` ++ parts.slice(occurrence).join(guard);+ return {+ ...file(body),+ errors: [+ {+ messageId,+ data: {value},+ suggestions: [+ {+ desc: `Replace with isRenderable(${value})`,+ output: `${header}\n${fixed}`,+ },+ ],+ },+ ],+ };+}++// RuleTester registers its own describe/it blocks internally, so it must run+// at the top level (Vitest 4 forbids calling suite functions inside an it()).+tester.run('no-truthy-jsx-guard', rule, {+ valid: [+ // ✅ The shared presence check.+ file(+ `export const C = ({startIcon}: {startIcon?: ReactNode}) => <div>{isRenderable(startIcon) && <Slot>{startIcon}</Slot>}</div>;`,+ ),+ file(+ `export const C = ({startIcon}: {startIcon?: ReactNode}) => <div>{isRenderable(startIcon) ? <Slot>{startIcon}</Slot> : null}</div>;`,+ ),+ // ✅ A boolean is not a slot value.+ file(+ `export const C = ({isOpen}: {isOpen?: boolean}) => <div>{isOpen && <Slot>open</Slot>}</div>;`,+ ),+ // ✅ Neither is a string, a plain number or a data object.+ file(+ `export const C = ({title}: {title?: string}) => <div>{title && <h2>{title}</h2>}</div>;`,+ ),+ file(+ `export const C = ({count}: {count: number}) => <div>{count ? <b>{count}</b> : null}</div>;`,+ ),+ file(+ `export const C = ({user}: {user?: {name: string}}) => <div>{user && <b>{user.name}</b>}</div>;`,+ ),+ // ✅ A converted guard renders no stray text.+ file(+ `export const C = ({startIcon}: {startIcon?: ReactNode}) => <div>{!!startIcon && <Slot>{startIcon}</Slot>}</div>;`,+ ),+ // ✅ A truthiness test that does not guard JSX.+ file(`export const f = (label: ReactNode) => (label ? 'yes' : 'no');`),+ // ✅ The allow form names its reason.+ file(+ `export const C = ({startIcon}: {startIcon?: ReactNode}) => (+ <div>+ {/* eslint-disable-next-line rule-to-test/no-truthy-jsx-guard -- 0 is not a valid icon here */}+ {startIcon && <Slot>{startIcon}</Slot>}+ </div>+);`,+ ),+ // ✅ Baselined values in their own file.+ {+ ...file(+ `export const C = ({startIcon}: {startIcon?: ReactNode}) => <div>{startIcon && <Slot>{startIcon}</Slot>}</div>;`,+ ),+ options: [+ {+ baseline: {'fixture.tsx': ['startIcon']},+ root: import.meta.dirname,+ },+ ],+ },+ ],+ invalid: [+ // ❌ The stray "0": `0 && <Slot />` renders 0.+ flagged(+ `export const C = ({startIcon}: {startIcon?: ReactNode}) => <div>{startIcon && <Slot>{startIcon}</Slot>}</div>;`,+ 'andGuard',+ 'startIcon',+ ),+ // ❌ A union that adds a component type to ReactNode.+ flagged(+ `export const C = ({startIcon}: {startIcon?: ReactNode | IconType}) => <div>{startIcon && <Slot>icon</Slot>}</div>;`,+ 'andGuard',+ 'startIcon',+ ),+ // ❌ A member expression later in a chain.+ flagged(+ `export const C = ({item, isOpen}: {item: {icon?: ReactNode}; isOpen: boolean}) => <div>{isOpen && item.icon && <Slot>{item.icon}</Slot>}</div>;`,+ 'andGuard',+ 'item.icon',+ ),+ // ❌ The ternary drops the slot for 0.+ flagged(+ `export const C = ({label}: {label?: ReactNode}) => <div>{label ? <Slot>{label}</Slot> : null}</div>;`,+ 'ternaryGuard',+ 'label',+ ),+ // ❌ A type parameter bound by ReactNode.+ flagged(+ `export function C<T extends ReactNode>({icon}: {icon: T}) { return <div>{icon && <Slot>{icon}</Slot>}</div>; }`,+ 'andGuard',+ 'icon',+ ),+ // ❌ The baseline allows as many guards as it lists; one more is reported.+ {+ ...flagged(+ `export const C = ({startIcon}: {startIcon?: ReactNode}) => <div>{startIcon && <Slot>{startIcon}</Slot>}<Slot>{startIcon && <b>{startIcon}</b>}</Slot></div>;`,+ 'andGuard',+ 'startIcon',+ 2,+ ),+ options: [+ {+ baseline: {'fixture.tsx': ['startIcon']},+ root: import.meta.dirname,+ },+ ],+ },+ ],+});