Skip to content

[Draft] BodyText linting part 2: no-invalid-bodytext-children#3015

Draft
marcysutton wants to merge 6 commits intomainfrom
WB-2248-bodytext-children
Draft

[Draft] BodyText linting part 2: no-invalid-bodytext-children#3015
marcysutton wants to merge 6 commits intomainfrom
WB-2248-bodytext-children

Conversation

@marcysutton
Copy link
Copy Markdown
Member

@marcysutton marcysutton commented Apr 16, 2026

Summary:

This new lint rule will flag invalid children within BodyText:

  • viewChild — always warns when View is a direct child of BodyText, regardless of tag prop
  • divChild — warns when <div> is a direct child and BodyText renders as <p> (no tag or tag="p")
  • paragraphChild — warns when <p> or a default <BodyText> (renders as <p>) is a direct child
  • blockChild — warns on other block-level HTML elements (section, ul, h1h6, etc.) and WB heading components when BodyText renders as <p>
  • tooManyChildren — warns when direct JSX element children exceed a configurable threshold (default: 5)
  • Block-child checks are skipped when BodyText has an inline or block-container tag prop set

Issue: WB-2248

Test plan:

  1. Ensure tests pass
  2. Test in frontend (WIP)

@marcysutton marcysutton self-assigned this Apr 16, 2026
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 16, 2026

🦋 Changeset detected

Latest commit: 4199e63

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

This PR includes changesets to release 1 package
Name Type
@khanacademy/eslint-plugin-wonder-blocks 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

@khan-actions-bot khan-actions-bot requested a review from a team April 16, 2026 23:12
@khan-actions-bot
Copy link
Copy Markdown
Contributor

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to .eslintrc.js, .changeset/brown-tips-draw.md, packages/eslint-plugin-wonder-blocks/src/configs/strict.ts, packages/eslint-plugin-wonder-blocks/src/rules/index.ts, packages/eslint-plugin-wonder-blocks/src/rules/no-invalid-bodytext-children.ts, packages/eslint-plugin-wonder-blocks/src/rules/__tests__/no-invalid-bodytext-children.test.ts

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 16, 2026

Size Change: +778 B (+0.63%)

Total Size: 124 kB

📦 View Changed
Filename Size Change
packages/eslint-plugin-wonder-blocks/dist/es/index.js 2.71 kB +778 B (+40.29%) 🚨
ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-accordion/dist/es/index.js 3 kB
packages/wonder-blocks-announcer/dist/es/index.js 2.43 kB
packages/wonder-blocks-badge/dist/es/index.js 2.02 kB
packages/wonder-blocks-banner/dist/es/index.js 2.01 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.91 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 755 B
packages/wonder-blocks-button/dist/es/index.js 4.28 kB
packages/wonder-blocks-card/dist/es/index.js 1.08 kB
packages/wonder-blocks-cell/dist/es/index.js 2.18 kB
packages/wonder-blocks-clickable/dist/es/index.js 2.6 kB
packages/wonder-blocks-core/dist/es/index.js 2.59 kB
packages/wonder-blocks-data/dist/es/index.js 5.48 kB
packages/wonder-blocks-date-picker/dist/es/index.js 8.06 kB
packages/wonder-blocks-dropdown/dist/es/index.js 19.7 kB
packages/wonder-blocks-form/dist/es/index.js 6.3 kB
packages/wonder-blocks-grid/dist/es/index.js 1.24 kB
packages/wonder-blocks-icon-button/dist/es/index.js 4.01 kB
packages/wonder-blocks-icon/dist/es/index.js 1.91 kB
packages/wonder-blocks-labeled-field/dist/es/index.js 3.47 kB
packages/wonder-blocks-layout/dist/es/index.js 1.63 kB
packages/wonder-blocks-link/dist/es/index.js 1.53 kB
packages/wonder-blocks-modal/dist/es/index.js 7.36 kB
packages/wonder-blocks-pill/dist/es/index.js 1.31 kB
packages/wonder-blocks-popover/dist/es/index.js 4.36 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.48 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.1 kB
packages/wonder-blocks-styles/dist/es/index.js 464 B
packages/wonder-blocks-switch/dist/es/index.js 1.55 kB
packages/wonder-blocks-tabs/dist/es/index.js 5.57 kB
packages/wonder-blocks-testing-core/dist/es/index.js 3.25 kB
packages/wonder-blocks-testing/dist/es/index.js 978 B
packages/wonder-blocks-theming/dist/es/index.js 384 B
packages/wonder-blocks-timing/dist/es/index.js 1.37 kB
packages/wonder-blocks-tokens/dist/es/index.js 5.18 kB
packages/wonder-blocks-toolbar/dist/es/index.js 906 B
packages/wonder-blocks-tooltip/dist/es/index.js 6.02 kB
packages/wonder-blocks-typography/dist/es/index.js 1.57 kB

compressed-size-action

@github-actions
Copy link
Copy Markdown
Contributor

npm Snapshot: Published

🎉 Good news!! We've packaged up the latest commit from this PR (0fb92c6) and published all packages with changesets to npm.

You can install the packages in frontend by running:

./dev/tools/deploy_wonder_blocks.js --tag="PR3015"

Packages can also be installed manually by running:

pnpm add @khanacademy/wonder-blocks-<package-name>@PR3015

@github-actions
Copy link
Copy Markdown
Contributor

A new build was pushed to Chromatic! 🚀

https://5e1bf4b385e3fb0020b7073c-jnevvyiccd.chromatic.com/

Chromatic results:

Metric Total
Captured snapshots 0
Tests with visual changes 0
Total stories 835
Inherited (not captured) snapshots [TurboSnap] 462
Tests on the build 462

@marcysutton marcysutton marked this pull request as draft April 16, 2026 23:15
@marcysutton marcysutton changed the title BodyText linting part 2: no-invalid-bodytext-children [Draft] BodyText linting part 2: no-invalid-bodytext-children Apr 16, 2026
@marcysutton marcysutton force-pushed the WB-2247-bodytext-lint branch 5 times, most recently from 4bc6115 to f554d3f Compare April 21, 2026 20:48
Base automatically changed from WB-2247-bodytext-lint to main April 21, 2026 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants