Skip to content

chore: add React Compiler eslint rule#31457

Merged
spmonahan merged 6 commits into
microsoft:masterfrom
spmonahan:chore/react-compiler
Jun 21, 2024
Merged

chore: add React Compiler eslint rule#31457
spmonahan merged 6 commits into
microsoft:masterfrom
spmonahan:chore/react-compiler

Conversation

@spmonahan

@spmonahan spmonahan commented May 22, 2024

Copy link
Copy Markdown
Contributor

Previous Behavior

No linting for the Rules of React.

New Behavior

Apologies for the massive PR but this change touches all or nearly all Fluent v9 components!

Adds eslint-plugin-react-compiler. For background information on React Compiler (previously "React Forget") see: https://react.dev/learn/react-compiler

While React Compiler require React 19, the eslint plugin does not.

This lint rule will help us adhere to the Rules of React much like the lint rule that enforces the Rules of Hooks.

The "use no memo" directive is used to disable the linter rather than an eslint-disable-* comment as the directive will also instruct the actual React Forget compiler.

Summary of changes

  1. I've disabled this linter for all the styles hooks. After looking at this the conclusion about the reported error is that this is a false positive as the state being mutated is not React state but "Fluent state". Further experimentation showed that the Compiler does not change this code when it has been modified to be immutable (i.e. there are no real upsides to change it).
  2. The template for style hooks has been updated to disable this lint rule for all future components.

@codesandbox-ci

codesandbox-ci Bot commented May 22, 2024

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@spmonahan
spmonahan force-pushed the chore/react-compiler branch from 4aaec5b to b360d2c Compare May 22, 2024 20:21
@fabricteam

fabricteam commented May 22, 2024

Copy link
Copy Markdown
Collaborator

Perf Analysis (@fluentui/react-components)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 611 618 5000
Button mount 306 302 5000
Field mount 1118 1077 5000
FluentProvider mount 712 691 5000
FluentProviderWithTheme mount 87 83 10
FluentProviderWithTheme virtual-rerender 34 33 10
FluentProviderWithTheme virtual-rerender-with-unmount 73 73 10
MakeStyles mount 869 866 50000
Persona mount 1772 1707 5000
SpinButton mount 1417 1425 5000
SwatchPicker mount 1633 1651 5000

@fabricteam

fabricteam commented May 22, 2024

Copy link
Copy Markdown
Collaborator

Perf Analysis (@fluentui/react-northstar)

Perf tests with no regressions
Scenario Current PR Ticks Baseline Ticks Ratio
ButtonMinimalPerf.default 98 85 1.15:1
TreeWith60ListItems.default 92 81 1.14:1
GridMinimalPerf.default 199 176 1.13:1
FlexMinimalPerf.default 169 152 1.11:1
PortalMinimalPerf.default 92 83 1.11:1
ProviderMinimalPerf.default 208 192 1.08:1
ChatDuplicateMessagesPerf.default 158 147 1.07:1
LabelMinimalPerf.default 223 209 1.07:1
BoxMinimalPerf.default 199 188 1.06:1
ButtonSlotsPerf.default 319 300 1.06:1
ListNestedPerf.default 330 311 1.06:1
VideoMinimalPerf.default 456 430 1.06:1
ReactionMinimalPerf.default 216 206 1.05:1
SegmentMinimalPerf.default 202 192 1.05:1
IconMinimalPerf.default 398 380 1.05:1
MenuMinimalPerf.default 509 490 1.04:1
SliderMinimalPerf.default 747 719 1.04:1
TableMinimalPerf.default 239 230 1.04:1
RosterPerf.default 1614 1572 1.03:1
RadioGroupMinimalPerf.default 271 262 1.03:1
TableManyItemsPerf.default 1104 1075 1.03:1
TooltipMinimalPerf.default 1288 1249 1.03:1
AnimationMinimalPerf.default 304 299 1.02:1
ButtonOverridesMissPerf.default 672 656 1.02:1
ChatWithPopoverPerf.default 205 201 1.02:1
CheckboxMinimalPerf.default 1166 1148 1.02:1
DialogMinimalPerf.default 440 433 1.02:1
DividerMinimalPerf.default 205 200 1.02:1
LayoutMinimalPerf.default 204 200 1.02:1
ListWith60ListItems.default 371 363 1.02:1
ProviderMergeThemesPerf.default 656 644 1.02:1
SkeletonMinimalPerf.default 198 195 1.02:1
SplitButtonMinimalPerf.default 2283 2237 1.02:1
TextMinimalPerf.default 198 195 1.02:1
TextAreaMinimalPerf.default 293 287 1.02:1
CardMinimalPerf.default 302 299 1.01:1
HeaderMinimalPerf.default 208 205 1.01:1
ItemLayoutMinimalPerf.default 708 698 1.01:1
ListMinimalPerf.default 306 303 1.01:1
PopupMinimalPerf.default 350 348 1.01:1
AttachmentSlotsPerf.default 632 631 1:1
DatepickerMinimalPerf.default 3517 3515 1:1
DropdownMinimalPerf.default 1419 1414 1:1
EmbedMinimalPerf.default 1869 1862 1:1
FormMinimalPerf.default 233 233 1:1
HeaderSlotsPerf.default 461 461 1:1
InputMinimalPerf.default 547 545 1:1
RefMinimalPerf.default 111 111 1:1
StatusMinimalPerf.default 387 386 1:1
CustomToolbarPrototype.default 1451 1456 1:1
AccordionMinimalPerf.default 80 81 0.99:1
DropdownManyItemsPerf.default 400 404 0.99:1
ImageMinimalPerf.default 226 228 0.99:1
MenuButtonMinimalPerf.default 939 953 0.99:1
TreeMinimalPerf.default 471 477 0.99:1
ChatMinimalPerf.default 432 441 0.98:1
ToolbarMinimalPerf.default 532 544 0.98:1
AvatarMinimalPerf.default 106 109 0.97:1
CarouselMinimalPerf.default 262 273 0.96:1
ListCommonPerf.default 373 389 0.96:1
AlertMinimalPerf.default 154 162 0.95:1
LoaderMinimalPerf.default 183 193 0.95:1
AttachmentMinimalPerf.default 73 84 0.87:1

@fabricteam

fabricteam commented May 22, 2024

Copy link
Copy Markdown
Collaborator

🕵 FluentUIV0 No visual regressions between this PR and main

@fabricteam

fabricteam commented May 22, 2024

Copy link
Copy Markdown
Collaborator

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-components
react-components: entire library
1.093 MB
270.372 kB
1.093 MB
270.391 kB
1 B
19 B
react-tag-picker
@fluentui/react-tag-picker - package
180.139 kB
54.231 kB
180.14 kB
54.239 kB
1 B
8 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
global-context
createContext
510 B
328 B
global-context
createContextSelector
537 B
339 B
keyboard-key
keyboard-key package
3.746 kB
1.928 kB
priority-overflow
createOverflowManager
4.457 kB
1.856 kB
react
ActivityItem
71.094 kB
23.309 kB
react
Announced
38.366 kB
13.259 kB
react
Autofill
15.365 kB
4.743 kB
react
Breadcrumb
201.952 kB
60.34 kB
react
Button
195.42 kB
56.534 kB
react
ButtonGrid
180.363 kB
54.589 kB
react
Calendar
121.617 kB
36.963 kB
react
Callout
84.183 kB
27.574 kB
react
Check
53.038 kB
17.798 kB
react
Checkbox
59.826 kB
19.83 kB
react
ChoiceGroup
65.351 kB
21.457 kB
react
ChoiceGroupOption
58.606 kB
19.332 kB
react
Coachmark
93.012 kB
29.377 kB
react
Color
7.737 kB
3.106 kB
react
ColorPicker
133.06 kB
41.521 kB
react
ComboBox
251.721 kB
72.161 kB
react
CommandBar
202.989 kB
60.048 kB
react
ContextualMenu
154.945 kB
48.139 kB
react
DatePicker
184.014 kB
56.1 kB
react
DateTimeUtilities
5.244 kB
1.849 kB
react
DetailsList
229.392 kB
65.655 kB
react
Dialog
211.276 kB
63.066 kB
react
Divider
19.478 kB
6.825 kB
react
DocumentCard
216.961 kB
64.34 kB
react
DragDrop
8.343 kB
2.724 kB
react
DraggableZone
34.188 kB
11.472 kB
react
Dropdown
233.882 kB
68.535 kB
react
ExtendedPicker
96.64 kB
27.827 kB
react
Fabric
41.612 kB
14.306 kB
react
Facepile
210.537 kB
63.11 kB
react
FloatingPicker
242.007 kB
68.903 kB
react
FocusTrapZone
16.979 kB
5.921 kB
react
FocusZone
54.919 kB
17.421 kB
react
Grid
180.363 kB
54.589 kB
react
GroupedList
134.709 kB
40.617 kB
react
GroupedListV2
122.326 kB
37.724 kB
react
HoverCard
97.044 kB
30.76 kB
react
Icon
51.719 kB
17.219 kB
react
Icons
66.309 kB
24.381 kB
react
Image
46.776 kB
15.668 kB
react
Keytip
81.557 kB
26.731 kB
react
KeytipData
13.973 kB
4.573 kB
react
KeytipLayer
103.353 kB
31.983 kB
react
Keytips
106.121 kB
32.986 kB
react
Label
38.213 kB
13.226 kB
react
Layer
47.962 kB
16.316 kB
react
Link
39.563 kB
13.637 kB
react
List
39.251 kB
12.405 kB
react
MarqueeSelection
74.396 kB
22.41 kB
react
MessageBar
190.467 kB
57.013 kB
react
Modal
93.515 kB
30.201 kB
react
Nav
187.945 kB
56.45 kB
react
OverflowSet
33.266 kB
11.28 kB
react
Overlay
40.769 kB
14.046 kB
react
Panel
200.987 kB
59.938 kB
react
Persona
114.692 kB
36.466 kB
react
PersonaCoin
114.692 kB
36.466 kB
react
PersonaPresence
57.908 kB
19.327 kB
react
Pickers
293.697 kB
82.241 kB
react
Pivot
188.859 kB
57.186 kB
react
Popup
12.242 kB
4.181 kB
react
Positioning
22.683 kB
7.651 kB
react
PositioningContainer
73.722 kB
23.735 kB
react
ProgressIndicator
39.361 kB
13.505 kB
react
Rating
81.837 kB
26.078 kB
react
Fluent UI React (entire library)
1.013 MB
281.366 kB
react
ResizeGroup
13.286 kB
4.365 kB
react
ResponsiveMode
8.078 kB
2.95 kB
react
ScrollablePane
55.404 kB
17.693 kB
react
SearchBox
188.742 kB
56.617 kB
react
SelectableOption
724 B
413 B
react
SelectedItemsList
232.506 kB
67.852 kB
react
Selection
42.327 kB
12.227 kB
react
Separator
35.262 kB
12.117 kB
react
Shimmer
49.124 kB
16.228 kB
react
ShimmeredDetailsList
240.167 kB
68.421 kB
react
Slider
57.524 kB
19.164 kB
react
SpinButton
192.47 kB
57.735 kB
react
Spinner
41.556 kB
14.431 kB
react
Stack
41.622 kB
14.253 kB
react
Sticky
32.541 kB
10.49 kB
react
Styling
45.928 kB
15.103 kB
react
SwatchColorPicker
190.689 kB
58.074 kB
react
TeachingBubble
205.742 kB
60.967 kB
react
Text
36.798 kB
12.785 kB
react
TextField
80.63 kB
25.28 kB
react
Theme
43.396 kB
14.154 kB
react
ThemeGenerator
12.34 kB
4.106 kB
react
TimePicker
241.525 kB
69.93 kB
react
Toggle
46.095 kB
15.926 kB
react
Tooltip
87.211 kB
28.189 kB
react
Utilities
82.57 kB
25.068 kB
react
Viewport
23.778 kB
7.614 kB
react
WeeklyDayPicker
101.761 kB
31.775 kB
react
WindowProvider
1.059 kB
541 B
react-accordion
Accordion (including children components)
99.097 kB
30.197 kB
react-avatar
Avatar
49.301 kB
15.838 kB
react-avatar
AvatarGroup
20.107 kB
7.973 kB
react-avatar
AvatarGroupItem
63.445 kB
20.061 kB
react-badge
Badge
25.952 kB
8.614 kB
react-badge
CounterBadge
26.731 kB
8.887 kB
react-badge
PresenceBadge
25.719 kB
9.485 kB
react-breadcrumb
@fluentui/react-breadcrumb - package
113.657 kB
31.532 kB
react-button
Button
37.105 kB
10.785 kB
react-button
CompoundButton
43.516 kB
12.076 kB
react-button
MenuButton
41.886 kB
12.133 kB
react-button
SplitButton
49.898 kB
13.725 kB
react-button
ToggleButton
53.032 kB
12.545 kB
react-calendar-compat
Calendar Compat
149.583 kB
39.839 kB
react-card
Card - All
100.845 kB
28.873 kB
react-card
Card
93.629 kB
27.077 kB
react-card
CardFooter
14.356 kB
5.798 kB
react-card
CardHeader
16.879 kB
6.664 kB
react-card
CardPreview
14.42 kB
5.934 kB
react-checkbox
Checkbox
35.105 kB
12.112 kB
react-combobox
Combobox (including child components)
100.436 kB
33.139 kB
react-combobox
Dropdown (including child components)
101.069 kB
33.081 kB
react-components
react-components: Button, FluentProvider & webLightTheme
69.141 kB
20.157 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
211.741 kB
60.957 kB
react-components
react-components: FluentProvider & webLightTheme
44.442 kB
14.607 kB
react-datepicker-compat
DatePicker Compat
223.007 kB
63.137 kB
react-dialog
Dialog (including children components)
98.908 kB
29.807 kB
react-divider
Divider
21.328 kB
7.965 kB
react-field
Field
23.384 kB
8.903 kB
react-image
Image
15.362 kB
6.248 kB
react-input
Input
27.987 kB
9.446 kB
react-jsx-runtime
Classic Pragma
1.057 kB
530 B
react-jsx-runtime
JSX Dev Runtime
3.781 kB
1.646 kB
react-jsx-runtime
JSX Runtime
4.377 kB
1.881 kB
react-label
Label
14.672 kB
6.002 kB
react-link
Link
17.193 kB
6.993 kB
react-menu
Menu (including children components)
151.246 kB
45.708 kB
react-menu
Menu (including selectable components)
153.932 kB
46.201 kB
react-message-bar
MessageBar (all components)
24.413 kB
9.117 kB
react-motion
@fluentui/react-motion - createMotionComponent()
4.1 kB
1.828 kB
react-motion
@fluentui/react-motion - createPresenceComponent()
4.767 kB
2.112 kB
react-motion
@fluentui/react-motion - PresenceGroup
1.714 kB
819 B
react-northstar
Accordion
85.392 kB
26.518 kB
react-northstar
Alert
87.45 kB
26.902 kB
react-northstar
Animation
55.34 kB
17.829 kB
react-northstar
Attachment
86.844 kB
26.692 kB
react-northstar
Avatar
80.279 kB
24.629 kB
react-northstar
Box
75.248 kB
23.806 kB
react-northstar
Breadcrumb
79.92 kB
24.709 kB
react-northstar
Button
83.16 kB
25.947 kB
react-northstar
Card
82.705 kB
25.023 kB
react-northstar
Carousel
105.182 kB
31.871 kB
react-northstar
Chat
154.09 kB
46.847 kB
react-northstar
Checkbox
79.807 kB
25.078 kB
react-northstar
Datepicker
186.651 kB
56.973 kB
react-northstar
Debug
8.801 kB
3.594 kB
react-northstar
Design
36.589 kB
12.067 kB
react-northstar
Dialog
112.058 kB
33.615 kB
react-northstar
Divider
76.619 kB
24.129 kB
react-northstar
Dropdown
198.211 kB
60.214 kB
react-northstar
Embed
81.477 kB
25.417 kB
react-northstar
Flex
47.728 kB
15.438 kB
react-northstar
Form
92.527 kB
28.879 kB
react-northstar
Grid
70.584 kB
22.278 kB
react-northstar
Header
74.756 kB
23.461 kB
react-northstar
Image
73.591 kB
23.329 kB
react-northstar
Input
88.346 kB
27.78 kB
react-northstar
ItemLayout
78.231 kB
24.454 kB
react-northstar
Label
77.92 kB
24.41 kB
react-northstar
Layout
75.393 kB
23.798 kB
react-northstar
List
88.493 kB
27.547 kB
react-northstar
Loader
78.616 kB
24.729 kB
react-northstar
Menu
128.602 kB
40.717 kB
react-northstar
MenuButton
163.008 kB
49.606 kB
react-northstar
Pill
83.722 kB
26.069 kB
react-northstar
Popup
135.316 kB
42.242 kB
react-northstar
Portal
58.338 kB
18.852 kB
react-northstar
Provider
93.138 kB
29.63 kB
react-northstar
RadioGroup
83.282 kB
26.053 kB
react-northstar
Reaction
77.28 kB
24.122 kB
react-northstar
Segment
76.209 kB
23.892 kB
react-northstar
Skeleton
77.765 kB
24.2 kB
react-northstar
Slider
84.27 kB
26.737 kB
react-northstar
SplitButton
178.246 kB
53.42 kB
react-northstar
Status
76.272 kB
24.05 kB
react-northstar
SvgIcon
36.823 kB
11.743 kB
react-northstar
Table
80.796 kB
25.154 kB
react-northstar
Text
74.114 kB
23.507 kB
react-northstar
TextArea
74.248 kB
23.492 kB
react-northstar
Toolbar
175.057 kB
52.832 kB
react-northstar
Tooltip
109.973 kB
35.227 kB
react-northstar
Tree
87.855 kB
27.217 kB
react-northstar
Video
75.411 kB
23.799 kB
react-overflow
hooks only
12.821 kB
4.813 kB
react-persona
Persona
56.192 kB
17.728 kB
react-popover
Popover
127.198 kB
39.776 kB
react-portal
Portal
14.563 kB
5.118 kB
react-portal-compat
PortalCompatProvider
8.39 kB
2.64 kB
react-positioning
usePositioning
26.489 kB
9.552 kB
react-progress
ProgressBar
17.086 kB
6.906 kB
react-provider
FluentProvider
24.618 kB
8.906 kB
react-radio
Radio
32.673 kB
10.351 kB
react-radio
RadioGroup
15.76 kB
6.433 kB
react-select
Select
27.638 kB
10.108 kB
react-slider
Slider
37.17 kB
12.547 kB
react-spinbutton
SpinButton
36.049 kB
11.835 kB
react-spinner
Spinner
25.246 kB
8.554 kB
react-swatch-picker
@fluentui/react-swatch-picker - package
103.495 kB
30.046 kB
react-switch
Switch
35.301 kB
11.348 kB
react-table
DataGrid
160.297 kB
45.656 kB
react-table
Table (Primitives only)
42.482 kB
13.868 kB
react-table
Table as DataGrid
131.102 kB
36.346 kB
react-table
Table (Selection only)
70.336 kB
20.028 kB
react-table
Table (Sort only)
68.979 kB
19.633 kB
react-tags
InteractionTag
15.167 kB
6.135 kB
react-tags
Tag
28.996 kB
9.52 kB
react-tags
TagGroup
82.084 kB
24.34 kB
react-text
Text - Default
17.063 kB
6.733 kB
react-text
Text - Wrappers
20.235 kB
7.064 kB
react-textarea
Textarea
26.521 kB
9.741 kB
react-theme
Single theme token import
69 B
89 B
react-theme
Teams: all themes
35.666 kB
7.453 kB
react-theme
Teams: Light theme
19.642 kB
5.549 kB
react-timepicker-compat
TimePicker
103.427 kB
34.598 kB
react-toast
Toast (including Toaster)
97.525 kB
29.326 kB
react-tooltip
Tooltip
54.558 kB
19.23 kB
react-utilities
SSRProvider
180 B
160 B
🤖 This report was generated against 6ef86787fa4b44ea07f78d6f3ce18b6e97088852

@fabricteam

fabricteam commented May 22, 2024

Copy link
Copy Markdown
Collaborator

Perf Analysis (@fluentui/react)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
BaseButton mount 641 621 5000
Breadcrumb mount 1686 1682 1000
Checkbox mount 1733 1720 5000
CheckboxBase mount 1474 1496 5000
ChoiceGroup mount 3002 2958 5000
ComboBox mount 695 677 1000
CommandBar mount 6536 6528 1000
ContextualMenu mount 12727 12962 1000
DefaultButton mount 779 800 5000
DetailsRow mount 2254 2213 5000
DetailsRowFast mount 2221 2255 5000
DetailsRowNoStyles mount 2069 2047 5000
Dialog mount 2812 2657 1000
DocumentCardTitle mount 227 228 1000
Dropdown mount 2031 2061 5000
FocusTrapZone mount 1151 1166 5000
FocusZone mount 1080 1086 5000
GroupedList mount 38462 43280 2
GroupedList virtual-rerender 18320 20396 2
GroupedList virtual-rerender-with-unmount 51498 51321 2
GroupedListV2 mount 223 228 2
GroupedListV2 virtual-rerender 215 217 2
GroupedListV2 virtual-rerender-with-unmount 232 227 2
IconButton mount 1114 1138 5000
Label mount 338 342 5000
Layer mount 2729 2746 5000
Link mount 388 383 5000
MenuButton mount 989 981 5000
MessageBar mount 21467 21492 5000
Nav mount 2024 2078 1000
OverflowSet mount 793 766 5000
Panel mount 1814 1845 1000
Persona mount 744 748 1000
Pivot mount 923 910 1000
PrimaryButton mount 936 962 5000
Rating mount 4689 4656 5000
SearchBox mount 925 915 5000
Shimmer mount 1939 1932 5000
Slider mount 1356 1339 5000
SpinButton mount 2992 2970 5000
Spinner mount 393 386 5000
SplitButton mount 1847 1871 5000
Stack mount 418 418 5000
StackWithIntrinsicChildren mount 856 864 5000
StackWithTextChildren mount 2697 2637 5000
SwatchColorPicker mount 6433 6485 5000
TagPicker mount 1456 1483 5000
Text mount 381 394 5000
TextField mount 950 956 5000
ThemeProvider mount 826 842 5000
ThemeProvider virtual-rerender 583 577 5000
ThemeProvider virtual-rerender-with-unmount 1299 1298 5000
Toggle mount 623 615 5000
buttonNative mount 201 195 5000

@khmakoto

khmakoto commented May 24, 2024

Copy link
Copy Markdown
Member

Note for everyone looking at files: These are the reasons why we need to turn off React forget in non-style files:

Disabling exhaustive deps lint rule in hooks

  • useComboboxBaseState.ts
  • useDatePicker.tsx
  • useMotion.ts
  • createPresenceComponent.ts
  • usePositioning.ts
  • useFluentProvider.ts
  • useMergeTabsterAttributes.ts
  • useHeadlessFlatTree.ts
  • useMergedRefs.ts
  • useVirtualizer.ts
  • useVirtualizerScrollViewDynamic.ts
  • useDynamicPagination.ts
  • useResizeObserverRef.ts
  • useStaticPagination.ts
  • useWeeks.ts

Mutating params to a hook

  • useCharacterSearch.ts
  • usePopover.ts
  • useSliderState.tsx

Modifying state returned by a hook

  • useMenuButton.tsx
  • useCheckbox.tsx
  • useInputTriggerSlot.ts
  • useButtonTriggerSlot.ts
  • CheckboxShim.tsx
  • createPreset.ts
  • useTooltip.tsx
  • useFlatTreeNavigation.ts
  • useTreeNavigation.ts

Mutating a variable that React considers immutable

  • useMenuPopover.ts

Conditionally calling hooks

  • createMotionComponent.ts
  • PortalCompatProvider.tsx
  • usePortalMountNode.ts
  • usePositioning.ts
  • useFluentProviderThemeStyleTag.ts
  • useCarousel.ts
  • useFlatTree.ts
  • useTree.ts
  • useTreeContextValues.ts
  • useControllableState.ts
  • useId.ts
  • useSelection.ts
  • Carousel.tsx
  • useCombobox.tsx
  • useDropdown.tsx

Calling hooks from something that is not a functional component

  • useTableColumnSizing.tsx
  • useTableSelection.ts
  • useTableSort.ts

Hook might be a different function on different renders

  • useToaster.tsx

@spmonahan
spmonahan requested a review from Hotell June 4, 2024 16:59
@spmonahan
spmonahan force-pushed the chore/react-compiler branch 2 times, most recently from e4836b3 to 7118b55 Compare June 4, 2024 20:35
@spmonahan
spmonahan force-pushed the chore/react-compiler branch from 15723db to 2b42d4a Compare June 5, 2024 15:31
@spmonahan

Copy link
Copy Markdown
Contributor Author

Note for everyone looking at files: These are the reasons why we need to turn off React forget in non-style files:

Disabling exhaustive deps lint rule in hooks

  • useComboboxBaseState.ts
  • useDatePicker.tsx
  • useMotion.ts
  • createPresenceComponent.ts
  • usePositioning.ts
  • useFluentProvider.ts
  • useMergeTabsterAttributes.ts
  • useHeadlessFlatTree.ts
  • useMergedRefs.ts
  • useVirtualizer.ts
  • useVirtualizerScrollViewDynamic.ts
  • useDynamicPagination.ts
  • useResizeObserverRef.ts
  • useStaticPagination.ts
  • useWeeks.ts

Mutating params to a hook

  • useCharacterSearch.ts
  • usePopover.ts
  • useSliderState.tsx

Modifying state returned by a hook

  • useMenuButton.tsx
  • useCheckbox.tsx
  • useInputTriggerSlot.ts
  • useButtonTriggerSlot.ts
  • CheckboxShim.tsx
  • createPreset.ts
  • useTooltip.tsx
  • useFlatTreeNavigation.ts
  • useTreeNavigation.ts

Mutating a variable that React considers immutable

  • useMenuPopover.ts

Conditionally calling hooks

  • createMotionComponent.ts
  • PortalCompatProvider.tsx
  • usePortalMountNode.ts
  • usePositioning.ts
  • useFluentProviderThemeStyleTag.ts
  • useCarousel.ts
  • useFlatTree.ts
  • useTree.ts
  • useTreeContextValues.ts
  • useControllableState.ts
  • useId.ts
  • useSelection.ts
  • Carousel.tsx
  • useCombobox.tsx
  • useDropdown.tsx

Calling hooks from something that is not a functional component

  • useTableColumnSizing.tsx
  • useTableSelection.ts
  • useTableSort.ts

Hook might be a different function on different renders

  • useToaster.tsx

Made an issue to follow up here: #31537

@Hotell

Hotell commented Jun 7, 2024

Copy link
Copy Markdown
Contributor

The "use no memo" directive is used to disable the linter rather than an eslint-disable-* comment as the directive will also instruct the actual React Forget compiler.

to clarify, this pragma is a proprietary thing that react-compiler eslint plugin understands + react-compiler will not be used in these places, correct ?

Comment thread packages/eslint-plugin/src/configs/react-config.js Outdated
@Hotell

Hotell commented Jun 7, 2024

Copy link
Copy Markdown
Contributor

I tested this PR locally and it seems that eslint plugin doesn't work at all. Am I missing something ?

  • if it doesn't work, I'd bring this to our repo only after it will provide some value

With pragma in place:

image

Without:

image

@spmonahan

Copy link
Copy Markdown
Contributor Author

I tested this PR locally and it seems that eslint plugin doesn't work at all. Am I missing something ?

  • if it doesn't work, I'd bring this to our repo only after it will provide some value

With pragma in place:

image Without: image

Interesting. It was definitely failing when I first turned it on. I'll debug.

@spmonahan

Copy link
Copy Markdown
Contributor Author

The "use no memo" directive is used to disable the linter rather than an eslint-disable-* comment as the directive will also instruct the actual React Forget compiler.

to clarify, this pragma is a proprietary thing that react-compiler eslint plugin understands + react-compiler will not be used in these places, correct ?

Correct.

@spmonahan

Copy link
Copy Markdown
Contributor Author

@Hotell I took a lookt at

I tested this PR locally and it seems that eslint plugin doesn't work at all. Am I missing something ?

And it seems like you may have found a bug. The same repro but with useCardStyles.styles.ts triggers the eslint error. I haven't tried exhaustively but useButtonStyles.styles.ts and useRadioStyles.styles.ts also trigger the issue.

I think we should keep the pragma across the board and report this as a bug against React Compiler. WDYT?

@spmonahan
spmonahan force-pushed the chore/react-compiler branch 2 times, most recently from 78c62ea to 824d670 Compare June 12, 2024 23:47
@spmonahan
spmonahan requested a review from Hotell June 12, 2024 23:51
@spmonahan
spmonahan force-pushed the chore/react-compiler branch from c90e418 to 2f29a4d Compare June 13, 2024 17:53
@fabricteam

Copy link
Copy Markdown
Collaborator

🕵 fluentuiv8 No visual regressions between this PR and main

@spmonahan
spmonahan enabled auto-merge (squash) June 18, 2024 17:10
@Hotell

Hotell commented Jun 19, 2024

Copy link
Copy Markdown
Contributor

I think we should keep the pragma across the board and report this as a bug against React Compiler. WDYT?

yes please, in general the rule should be - do not have/add things in our codebase that don't work :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants