[charts][data-grid][pickers] Enforce top-level type imports#22679
[charts][data-grid][pickers] Enforce top-level type imports#22679Janpot wants to merge 2 commits into
Conversation
Deploy previewhttps://deploy-preview-22679--material-ui-x.netlify.app/ Bundle size
PerformanceTotal duration: 1,974.19 ms +75.36 ms(+4.0%) | Renders: 63 (+0)
…and 1 more (+20 within noise) — details Metric alarms
Check out the code infra dashboard for more information about this PR. |
consistent-type-imports
LukasTy
left a comment
There was a problem hiding this comment.
LGTM. 👍
What's the plan with import type {} going forward?
Should we do a follow-up replacing those with inline imports?
Is there any benefit to inline imports, or are they equal in performance or other relevant metrics?
My personal preference would be to decide on a style and fix existing issues first, but the team didn't express interest. |
Do you mean Code Infra or the X team? |
There was a discussion in https://mui-org.slack.com/archives/C011VC970AW/p1780421406363449
Yeah, either way is fine. If you prefer type imports and the rest of the team doesn't care then we simply do type imports. The trade-off of it is that we do two import statements instead of one, which is not a problem ofcourse, it purely comes down to preference. advantage is that it's also the default |
Gotcha.
If the change towards type imports is considerably smaller in scope, I'm on board. 😊 |
consistent-type-imports|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Looks like the inline type imports cause about 10% fewer changes than separating them. But I wouldn't necessarily call that "considerably" smaller. |
7f9e33d to
dfbb9dd
Compare
Switch consistent-type-imports to separate-type-imports and add import/consistent-type-specifier-style (prefer-top-level) so type-only imports use top-level `import type {}` rather than inline specifiers.
Mechanical result of eslint --fix + prettier for the rules enabled in the previous commit.
dfbb9dd to
534f7ff
Compare
Sets the
consistent-type-importsautofix style to block style (separate-type-imports) and adds the secondaryimport/consistent-type-specifier-stylerule (prefer-top-level) across charts, data-grid, and date-pickers, merged into one config block.Together the two rules enforce top-level
import type { Foo }and disallow inlineimport { type Foo }:@typescript-eslint/consistent-type-imports(fixStyle: 'separate-type-imports'): marks unmarked type-only imports as a top-levelimport type.import/consistent-type-specifier-style(prefer-top-level): moves any remaining inlinetypespecifiers (import { type X }) up to a top-levelimport type.The bulk of the diff is the autofix converting existing inline imports to block style across the three packages.
To review just the config change: d4aaa07