Skip to content

chore(eslint): disallow nested ternaries - #8340

Draft
tamas-sage wants to merge 1 commit into
masterfrom
FE-7853-no-nested-ternary
Draft

tamas-sage wants to merge 1 commit into
masterfrom
FE-7853-no-nested-ternary

Conversation

@tamas-sage

@tamas-sage tamas-sage commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

FE-7853

Proposed behaviour

Current behaviour

Checklist

  • Commits follow our style guide
  • Related issues linked in commit messages if required
  • Screenshots are included in the PR if useful
  • All themes are supported if required
  • Unit tests added or updated if required
  • Playwright automation tests added or updated if required
  • Storybook added or updated if required
  • Translations added or updated (including creating or amending translation keys table in storybook) if required
  • Typescript d.ts file added or updated if required
  • Related docs have been updated if required

QA

  • Tested in provided StackBlitz sandbox/Storybook
  • Add new Playwright test coverage if required
  • Carbon implementation matches Design System/designs
  • UI Tests GitHub check reviewed if required

Additional context

Testing instructions

@tamas-sage tamas-sage self-assigned this Dec 4, 2026
@tamas-sage
tamas-sage requested review from a team as code owners December 4, 2026 10:40
Copilot AI balanced review requested due to automatic review settings December 4, 2026 10:40
@tamas-sage
tamas-sage marked this pull request as draft December 4, 2026 10:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the nested-ternary rule and accompanying refactors.

No open issues 🎉

What changed in this PR

Disallows nested ternaries across Carbon and refactors existing expressions without intended behavior changes.

Changes:

  • Enables ESLint’s no-nested-ternary rule.
  • Replaces nested ternaries with helpers, conditionals, and simpler expressions.
  • Updates affected tests and skills-generation logic.
File Description
src/​locales/​pt-pt.ts Simplifies selection-count formatting.
src/​components/​tile/​tile.component.tsx Simplifies status-keyline fallback.
src/​components/​tile/​tile-footer/​tile-footer.component.tsx Uses conditional variant mapping.
src/​components/​textarea/​textarea.style.ts Extracts label-spacing helper.
src/​components/​table/​table-header/​table-header.component.tsx Calculates aria-sort separately.
src/​components/​table/​components-test.pw.tsx Simplifies fixture rendering conditions.
src/​components/​switch/​switch.style.tsx Shares thumb-transform helper.
src/​components/​select/​__internal__/​select-list/​__next__/​use-select-list-virtualization.ts Extracts navigation starting position.
src/​components/​select/​__internal__/​select-list/​__next__/​select-list.component.tsx Extracts divider-padding helper.
src/​components/​numeral-date/​numeral-date.test.tsx Supplies field keys in test cases.
src/​components/​loader/​__next__/​loader.style.ts Extracts label-font helpers.
src/​components/​loader/​__next__/​internal/​ring-loader.component.tsx Uses conditional ring sizing.
src/​components/​date/​__internal__/​hooks/​useDatePickerMonthYearSelection.ts Simplifies displayed-month bounds handling.
src/​components/​accordion/​accordion.component.tsx Extracts simple-header rendering.
src/​__internal__/​popover-menu/​hooks/​useHandleDropdownMenuKeyDown.ts Simplifies navigation-index fallback.
src/​__internal__/​character-count/​character-count.style.ts Extracts count-color helper.
scripts/​skills/​build_skills.mjs Simplifies sorting and deprecation formatting.
eslint.config.mjs Prohibits nested ternaries.

Review effort: Balanced

FE-7853

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tamas-sage
tamas-sage force-pushed the FE-7853-no-nested-ternary branch from de7590c to aeea43c Compare December 4, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants