Skip to content

feat(lint): require explicit conditional object fields - #167

Draft
jcosta33 wants to merge 1 commit into
codex/no-inline-param-typefrom
codex/no-conditional-object-spread
Draft

jcosta33 wants to merge 1 commit into
codex/no-inline-param-typefrom
codex/no-conditional-object-spread

Conversation

@jcosta33

@jcosta33 jcosta33 commented Dec 1, 2026 •

Copy link
Copy Markdown

Make conditional field assignment explicit in object literals and JSX props. Both base configs report ternary and logical spreads in those two contexts as errors.

Build a named object and assign optional fields in an if block. This makes it clear when a key is present.

Examples

In this example, BadgeProps.title is optional.

Before

const options = { ...defaults, ...(showTitle && { title }) };
const badge = <Badge {...(showTitle ? { title } : {})} />;

Corrected

import type { JSX } from 'react';

const options: BadgeProps = { ...defaults };
let badge: JSX.Element;

if (showTitle) {
    options.title = title;
    badge = <Badge title={title} />;
} else {
    badge = <Badge />;
}

Parent #164

Child #168

@changeset-bot

changeset-bot Bot commented Dec 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 91eca16

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@frontify/eslint-config-basic Minor
@frontify/eslint-config-react Minor
@frontify/eslint-plugin Patch
@frontify/oxlint-config-basic Minor
@frontify/oxlint-config-react Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant