[code-infra] Always enforce consistent-type-imports#1357
Conversation
Deploy previewhttps://deploy-preview-1357--mui-internal.netlify.app/ Bundle size
PerformanceTotal duration: 16.47 ms +0.62 ms(+3.9%) | Renders: 4 (+0) | Paint: 69.40 ms +2.46 ms(+3.7%)
Check out the code infra dashboard for more information about this PR. |
mui/mui-public#1357 makes consistent-type-imports always-on in the shared base config, so the per-package override here would become redundant once material-ui bumps @mui/internal-code-infra.
|
@Janpot I suppose you meant removing the option in order to force it globally? |
Nuance, it was just a question 😬. By no means did I volunteer the code infra team to own this change across all projects. But I don't mind adding an opt-in for it in the config factory so you can propagate it gradually across all repos. Let's build a good case to motivate this update. Can you put together a small code example that our build tool produces output for that is not consumable by vite 8? |
It was already an option though 😆 |
My issue is that we would require it to support vite v8. In https://github.com/mui/mui-x/pull/22243/changes I need to keep two versions of vite. v7 for regular codebase, and v8 for the performance tests due to vite 8 using rolldown instead of rollup. This PR is not really required though. As we could simply apply that to the offending package, which is |
|
Ok, so we see for instance in the diff that the |
The option is exactly there to allow for gradually rolling it out across the company. "Rolling it out" means "enable the flag on every repo", not "remove the flag". Reverting those changes to the flag and setting the option instead in our config. |
Co-authored-by: Janpot <2109932+Janpot@users.noreply.github.com>
Summary
Make
@typescript-eslint/consistent-type-imports(fixStyle: 'inline-type-imports') part of the shared base ESLint config — always on, no opt-in flag.Why
Type-only imports get erased at compile time, so they never reach a downstream bundler. A value-import that references a TypeScript-only name (e.g.
import { Theme } from '@mui/material/styles') survives the build and trips strict bundlers:Vite 8 / Rolldown surfaces this as a hard error (Rollup tolerated it). We hit this in mui/mui-x#22260 while bundling MUI X regression tests — the failing import lives in
@mui/internal-core-docs. The single-package fix is in mui/material-ui#48386 (originally also added a per-package ESLint override there); per @Janpot's suggestion we move that override into the shared config so the rule applies everywhere.Changes
packages/code-infra/src/eslint/baseConfig.mjs: drop theconsistentTypeImportsparameter; the rule is always applied.packages/code-infra/src/eslint/mui/config.mjs: same — remove conditional, hardcode the rule with a comment explaining the bundler-strictness motivation.Downstream
Consumers (
mui/material-ui,mui/mui-x,mui/base-ui, …) will pick up the rule automatically when they bump@mui/internal-code-infra. They will need to either run the autofix or accept the inlinetypemodifier across their codebases. BecausefixStyleisinline-type-imports, the autofix is non-disruptive.