[code-infra] Clean-up warnOnce() duplication
- Dominant language
- TypeScript
- Stars
- 10.9k
- Forks
- 543
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 101
Description
### Problem
The `warnOnce()` logic is duplicated all over the place in the MUI codebase:
- [x] MUI X: We have a couple of identical helpers https://github.com/search?q=org%3Amui+%22function+warnOnce%28%22&type=code
- [ ] MUI X Data Grid: We duplicate the logic too: https://github.com/mui/mui-x/blob/13a2ff112d2a7dec41625b06db04db860f590f58/packages/x-data-grid/src/components/GridPagination.tsx#L132
- [ ] Material UI: We duplicate the logic: https://github.com/mui/material-ui/blob/9e18971ee00c222c1ae317d673555187c9982ca2/packages/mui-material/src/Tabs/Tabs.js#L419
- [ ] Base UI: We call the same helper `warn()` but it's a warnOnce https://github.com/mui/base-ui/blob/master/packages/utils/src/warn.ts#L6. That's a bit confusing, no? It's also very hard to grep to figure out where the use of warn and error are correct. For example "error" could be `new Error()` or `console.error()` or `error()`.
### Context
I initially worked on this because of https://github.com/mui/mui-x/pull/13911. This looks like a perfect helper for `@base-ui/internals` per https://www.notion.so/mui-org/engineering-mui-utils-purpose-9a9fc9da3a004864b6c4e1f4d1f24f95.
The broader issue: https://github.com/mui/material-ui/issues/21979.
**Search keywords**:
Contributor guide
Assessment
This issue has not been assessed yet.