Skip to content

[infra] Enable mui/no-floating-cleanup ESLint rule#22789

Open
romgrk wants to merge 1 commit into
mui:masterfrom
romgrk:chore-eslint-cleanup-leak
Open

[infra] Enable mui/no-floating-cleanup ESLint rule#22789
romgrk wants to merge 1 commit into
mui:masterfrom
romgrk:chore-eslint-cleanup-leak

Conversation

@romgrk

@romgrk romgrk commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Enables the new type-aware mui/no-floating-cleanup ESLint rule across packages/*/src. The rule (added to code-infra in mui/mui-public#1538) is modeled on @typescript-eslint/no-floating-promises, but for functions: it flags call statements whose return value is a discarded callable (e.g. an unsubscribe / cleanup callback) — a common source of subscription leaks.

subscribe(() => {});            // ✗ discarded unsubscribe — leak
const un = subscribe(() => {}); // ✓
void subscribe(() => {});       // ✓ explicit opt-out

Also flags discards behind unary/logical/conditional wrappers (!subscribe(), a && subscribe(), cond ? subscribe() : x); fluent/builder calls that return this (e.g. d3 scale chaining, incl. inferred this) are not reported.

⚠️ Temporary override — depends on mui-public#1538

The rule isn't released yet, so this branch overrides @mui/internal-code-infra to a local mui-public checkout (the rule's PR):

# pnpm-workspace.yaml
overrides:
  '@mui/internal-code-infra': link:../mui-public/packages/code-infra

This requires mui-public checked out as a sibling ../mui-public on the mui-public#1538 branch, so CI can't install it as-is. Before merge: drop the override and bump @mui/internal-code-infra to a published release containing the rule. The eslint.config.mjs block is the only permanent change.

Leaks found

Running the rule surfaces genuine discarded-cleanup leaks, e.g. MoreEventsPopover.tsx:73 (a subscribeCloseHandler(...) in a useEffect whose unsubscribe is dropped instead of returned as cleanup), plus store subscribe() / plugin-register sites across Data Grid, Scheduler, Tree View, and Chat. The rule is set to error, so the lint job reports these until they're fixed (or it's set to warn) — that surfacing is the point of this PR.

🤖 Generated with Claude Code

@romgrk romgrk force-pushed the chore-eslint-cleanup-leak branch from 5ebf6fc to 5e0bb61 Compare June 11, 2026 20:06
@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jun 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@romgrk romgrk force-pushed the chore-eslint-cleanup-leak branch from 5e0bb61 to 5129c50 Compare June 11, 2026 21:08
Enables the new type-aware `mui/no-floating-cleanup` rule (added in
mui-public#1538) across `packages/*/src`. It flags discarded
unsubscribe/cleanup return values, like no-floating-promises but for
functions.

TEMPORARY: overrides `@mui/internal-code-infra` to a local mui-public
checkout (sibling `../mui-public`, on the PR branch) so the rule can be
tested before it is released. Revert once a code-infra release with the
rule is published.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@romgrk romgrk force-pushed the chore-eslint-cleanup-leak branch from 5129c50 to f47ed2b Compare June 11, 2026 21:24
@zannager zannager added the scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd). label Jun 12, 2026
@zannager zannager requested a review from brijeshb42 June 12, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: out-of-date The pull request has merge conflicts and can't be merged. scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants