feat(eslint-plugin-react-components): support granular lib imports #35618
+25
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some partner codebases have a lot of
@fluentui/react/lib/*imports. The current implementation of this rule only inspects@fluentui/reactimports, so these usages are not detected and no errors / warnings are reported.Previous Behavior
@fluentui/react/lib/*imports were ignoredFAIL eslint-plugin-react-components src/rules/prefer-fluentui-v9.spec.ts prefer-fluentui-v9 valid ✓ import type { IDropdownOption } from '@fluentui/react'; (23 ms) ✓ import type { ITheme } from '@fluentui/react'; (3 ms) ✓ import { ThemeProvider } from '@fluentui/react'; (1 ms) ✓ import { Button } from '@fluentui/react-components'; (1 ms) invalid ✓ import { Dropdown, Icon } from '@fluentui/react'; (4 ms) ✓ import { Stack } from '@fluentui/react'; (2 ms) ✓ import { DatePicker } from '@fluentui/react'; (1 ms) ✕ import { CompoundButton } from '@fluentui/react/lib/Button'; (3 ms) ✕ import { Stack } from '@fluentui/react/lib/Stack'; (3 ms) ● prefer-fluentui-v9 › invalid › import { CompoundButton } from '@fluentui/react/lib/Button'; assert.strictEqual(received, expected) Expected value to strictly be equal to: 1 Received: 0 Message: Should have 1 error but had 0: [] 0 !== 1New Behavior
PASS eslint-plugin-react-components src/rules/prefer-fluentui-v9.spec.ts prefer-fluentui-v9 valid ✓ import type { IDropdownOption } from '@fluentui/react'; (22 ms) ✓ import type { ITheme } from '@fluentui/react'; (2 ms) ✓ import { ThemeProvider } from '@fluentui/react'; (2 ms) ✓ import { Button } from '@fluentui/react-components'; (1 ms) invalid ✓ import { Dropdown, Icon } from '@fluentui/react'; (4 ms) ✓ import { Stack } from '@fluentui/react'; (1 ms) ✓ import { DatePicker } from '@fluentui/react'; (2 ms) ✓ import { CompoundButton } from '@fluentui/react/lib/Button'; (1 ms) ✓ import { Stack } from '@fluentui/react/lib/Stack'; (3 ms) Test Suites: 1 passed, 1 total Tests: 9 passed, 9 total Snapshots: 0 total Time: 0.504 s, estimated 1 s Ran all test suites.