Skip to content

Conversation

@dmytrokirpa
Copy link
Contributor

Previous Behavior

The prefer-fluentui-v9 ESLint rule did not detect or report dynamic imports (using .then or async/await patterns) of Fluent UI v8 components from @fluentui/react. As a result, v8/compat components could be dynamically imported without triggering migration warnings.

New Behavior

The rule now detects and reports dynamic imports of Fluent UI v8 components from @fluentui/react using both .then and async/await patterns. It flags these usages and suggests the appropriate v9 alternatives, ensuring consistent enforcement of migration guidance for both static and dynamic imports.

Related Issue(s)

@github-actions
Copy link

github-actions bot commented Jun 24, 2025

📊 Bundle size report

✅ No changes found

@github-actions
Copy link

Pull request demo site: URL

@dmytrokirpa dmytrokirpa changed the title Feat/eslint plugin prefere fluentui v9/dynamic imports support feat(eslint-plugin-react-components): add dynamic imports support to prefer-fluentui-v9 rule Jun 24, 2025
specifier.type === AST_NODE_TYPES.ImportSpecifier &&
specifier.imported.type === AST_NODE_TYPES.Identifier
) {
const name = specifier.imported.name;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to the reusable function reportIfMigration

@dmytrokirpa dmytrokirpa marked this pull request as ready for review June 25, 2025 10:58
@dmytrokirpa dmytrokirpa requested a review from a team as a code owner June 25, 2025 10:58
@dmytrokirpa dmytrokirpa requested a review from Hotell June 26, 2025 14:23
Copy link
Contributor

@Hotell Hotell left a comment

Choose a reason for hiding this comment

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

left some comments, looking forward to get this in

*/
function reportIfMigration(componentName: string, node: TSESTree.Node) {
if (!componentName) return;
if (componentName === 'Icon') {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we refactor this to have exit early logic, which will simplify the implementation and reduce cognitive load ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

*/
CallExpression(node) {
if (
node.callee.type === AST_NODE_TYPES.MemberExpression &&
Copy link
Contributor

Choose a reason for hiding this comment

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

couldn't this be simplified to chunked nodes in visitor pattern ? this seems very complex ?

have we tried the opposite approach ? focusing solely on finding import('url') and traversing the AST up to obtain the results ?

],
},
{
code: `const Calendar = React.lazy(() => import('@fluentui/react').then(m => ({ default: m.Calendar })));`,
Copy link
Contributor

Choose a reason for hiding this comment

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

will this catch also standard dynamic imports outside React.lazy() ?

contrived example:

function hello(){
 import('@fluentui/react').then(m => ( 
window.v8 = m
console.log('react loaded') )
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dmytrokirpa dmytrokirpa requested a review from Hotell January 6, 2026 11:06
@dmytrokirpa dmytrokirpa requested review from a team as code owners January 7, 2026 11:33
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