Skip to content

Commit f2c5878

Browse files
authored
feat(eslint-plugin-react-components): support granular lib imports (#35618)
1 parent a122e94 commit f2c5878

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ common/_themeOverrides.scss @microsoft/cxe-red @phkuo
194194
common/_common.scss @microsoft/cxe-red @phkuo
195195

196196
## vNext packages
197+
packages/react-components/eslint-plugin-react-components @microsoft/fluentui-react-build @microsoft/cxe-prg
197198
packages/react-components/keyboard-keys @microsoft/teams-prg
198199
packages/react-components/react-accordion/library @microsoft/cxe-prg @marcosmoura
199200
packages/react-components/react-accordion/stories @microsoft/cxe-prg @marcosmoura
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "fix: support granular lib imports",
4+
"packageName": "@fluentui/eslint-plugin-react-components",
5+
"email": "vgenaev@gmail.com",
6+
"dependentChangeType": "patch"
7+
}

packages/react-components/eslint-plugin-react-components/src/rules/prefer-fluentui-v9.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,18 @@ ruleTester.run(RULE_NAME, rule, {
3636
},
3737
],
3838
},
39+
{
40+
code: `import { CompoundButton } from '@fluentui/react/lib/Button';`,
41+
errors: [
42+
{
43+
messageId: 'replaceFluent8With9',
44+
data: { fluent8: 'CompoundButton', fluent9: 'CompoundButton', package: '@fluentui/react-components' },
45+
},
46+
],
47+
},
48+
{
49+
code: `import { Stack } from '@fluentui/react/lib/Stack';`,
50+
errors: [{ messageId: 'replaceStackWithFlex' }],
51+
},
3952
],
4053
});

packages/react-components/eslint-plugin-react-components/src/rules/prefer-fluentui-v9.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ export const rule = createRule<Options, MessageIds>({
2727
create(context) {
2828
return {
2929
ImportDeclaration(node) {
30-
if (node.source.value !== '@fluentui/react') {
30+
const source = node.source.value;
31+
const isFluentV8Import = source === '@fluentui/react' || source.startsWith('@fluentui/react/');
32+
33+
if (!isFluentV8Import) {
3134
return;
3235
}
3336

0 commit comments

Comments
 (0)