Skip to content

Commit 709b610

Browse files
author
22388o
committed
Support eslint 8+ flat plugin syntax out of the box for eslint-plugin-react-compiler (facebook#32120)
## Summary The current docs for the react compiler eslint plugin is based on integrating with the old-style eslint config format. This is generally fine, but most plugins (and the [official docs](https://eslint.org/docs/latest/use/configure/configuration-files#configuration-file)) are now describing themselves in the new format. This PR has two changes: - Update the exports to include a "flat configuration" - Adds a README change describing how to handle both configs The solution is semi-based on @guillaumebrunerie's answer in reactwg/react-compiler#25 mixed with reading the source code for [eslint-plugin-react-refresh](https://github.com/ArnaudBarre/eslint-plugin-react-refresh/blob/main/src/index.ts) ## How did you test this change? I faked this API in the most recent deploy: ![Screenshot 2025-01-18 at 19 58 44](https://github.com/user-attachments/assets/ae0e4bea-fb96-4073-a5f7-c886d087b6af) Then used that in my app: ![Screenshot 2025-01-18 at 20 04 33](https://github.com/user-attachments/assets/21f77158-7535-453a-b988-49cf59d22d71) and get myself some compiler messages: ``` /Users/orta/dev/app/apps/puzzmo.com/src/palette/HoverPopover.tsx 31:37 error Hooks must always be called in a consistent order, and may not be called conditionally. See the Rules of Hooks (https://react.dev/warnings/invalid-hook-call-warning) react-compiler/react-compiler /Users/orta/dev/app/apps/puzzmo.com/src/components/gameplay/PlayGamePauseOverlay.tsx 33:7 error Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) react-compiler/react-compiler 35:5 error Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef) react-compiler/react-compiler ``` DiffTrain build for [18eaf51](facebook@18eaf51)
1 parent e3a23e7 commit 709b610

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+4206
-2608
lines changed

compiled/facebook-www/JSXDEVRuntime-dev.classic.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,21 @@ __DEV__ &&
2222
_key2++
2323
)
2424
args[_key2 - 1] = arguments[_key2];
25-
_len2 = format;
26-
_key2 =
27-
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
28-
null != _key2 &&
29-
_key2.getCurrentStack &&
30-
((_key2 = _key2.getCurrentStack()),
31-
"" !== _key2 && ((_len2 += "%s"), args.push(_key2)));
32-
args.unshift(_len2);
33-
args.unshift(!1);
34-
warningWWW.apply(null, args);
25+
if (enableRemoveConsolePatches) {
26+
var _console2;
27+
(_console2 = console).error.apply(_console2, [format].concat(args));
28+
} else
29+
(_len2 = format),
30+
enableRemoveConsolePatches ||
31+
((_key2 =
32+
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE),
33+
null != _key2 &&
34+
_key2.getCurrentStack &&
35+
((_key2 = _key2.getCurrentStack()),
36+
"" !== _key2 && ((_len2 += "%s"), args.push(_key2))),
37+
args.unshift(_len2),
38+
args.unshift(!1),
39+
warningWWW.apply(null, args));
3540
}
3641
function getComponentNameFromType(type) {
3742
if (null == type) return null;
@@ -727,6 +732,8 @@ __DEV__ &&
727732
REACT_TRACING_MARKER_TYPE = Symbol.for("react.tracing_marker"),
728733
REACT_VIEW_TRANSITION_TYPE = Symbol.for("react.view_transition"),
729734
MAYBE_ITERATOR_SYMBOL = Symbol.iterator,
735+
enableRemoveConsolePatches =
736+
require("ReactFeatureFlags").enableRemoveConsolePatches,
730737
warningWWW = require("warning"),
731738
REACT_CLIENT_REFERENCE$2 = Symbol.for("react.client.reference"),
732739
ReactSharedInternals =

compiled/facebook-www/JSXDEVRuntime-dev.modern.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,21 @@ __DEV__ &&
2222
_key2++
2323
)
2424
args[_key2 - 1] = arguments[_key2];
25-
_len2 = format;
26-
_key2 =
27-
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
28-
null != _key2 &&
29-
_key2.getCurrentStack &&
30-
((_key2 = _key2.getCurrentStack()),
31-
"" !== _key2 && ((_len2 += "%s"), args.push(_key2)));
32-
args.unshift(_len2);
33-
args.unshift(!1);
34-
warningWWW.apply(null, args);
25+
if (enableRemoveConsolePatches) {
26+
var _console2;
27+
(_console2 = console).error.apply(_console2, [format].concat(args));
28+
} else
29+
(_len2 = format),
30+
enableRemoveConsolePatches ||
31+
((_key2 =
32+
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE),
33+
null != _key2 &&
34+
_key2.getCurrentStack &&
35+
((_key2 = _key2.getCurrentStack()),
36+
"" !== _key2 && ((_len2 += "%s"), args.push(_key2))),
37+
args.unshift(_len2),
38+
args.unshift(!1),
39+
warningWWW.apply(null, args));
3540
}
3641
function getComponentNameFromType(type) {
3742
if (null == type) return null;
@@ -727,6 +732,8 @@ __DEV__ &&
727732
REACT_TRACING_MARKER_TYPE = Symbol.for("react.tracing_marker"),
728733
REACT_VIEW_TRANSITION_TYPE = Symbol.for("react.view_transition"),
729734
MAYBE_ITERATOR_SYMBOL = Symbol.iterator,
735+
enableRemoveConsolePatches =
736+
require("ReactFeatureFlags").enableRemoveConsolePatches,
730737
warningWWW = require("warning"),
731738
REACT_CLIENT_REFERENCE$2 = Symbol.for("react.client.reference"),
732739
ReactSharedInternals =

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
886c5ad936428f168e50e077bd37fe9472ff8d3e
1+
18eaf51bd51fed8dfed661d64c306759101d0bfd
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
886c5ad936428f168e50e077bd37fe9472ff8d3e
1+
18eaf51bd51fed8dfed661d64c306759101d0bfd

compiled/facebook-www/React-dev.classic.js

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ __DEV__ &&
4141
_key++
4242
)
4343
args[_key - 1] = arguments[_key];
44-
printWarning("warn", format, args);
44+
if (enableRemoveConsolePatches) {
45+
var _console;
46+
(_console = console).warn.apply(_console, [format].concat(args));
47+
} else printWarning("warn", format, args);
4548
}
4649
function error$jscomp$0(format) {
4750
for (
@@ -52,18 +55,22 @@ __DEV__ &&
5255
_key2++
5356
)
5457
args[_key2 - 1] = arguments[_key2];
55-
printWarning("error", format, args);
58+
if (enableRemoveConsolePatches) {
59+
var _console2;
60+
(_console2 = console).error.apply(_console2, [format].concat(args));
61+
} else printWarning("error", format, args);
5662
}
5763
function printWarning(level, format, args) {
58-
level =
59-
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
60-
null != level &&
61-
level.getCurrentStack &&
62-
((level = level.getCurrentStack()),
63-
"" !== level && ((format += "%s"), args.push(level)));
64-
args.unshift(format);
65-
args.unshift(!1);
66-
warningWWW.apply(null, args);
64+
enableRemoveConsolePatches ||
65+
((level =
66+
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE),
67+
null != level &&
68+
level.getCurrentStack &&
69+
((level = level.getCurrentStack()),
70+
"" !== level && ((format += "%s"), args.push(level))),
71+
args.unshift(format),
72+
args.unshift(!1),
73+
warningWWW.apply(null, args));
6774
}
6875
function warnNoop(publicInstance, callerName) {
6976
publicInstance =
@@ -1139,6 +1146,8 @@ __DEV__ &&
11391146
REACT_TRACING_MARKER_TYPE = Symbol.for("react.tracing_marker"),
11401147
REACT_VIEW_TRANSITION_TYPE = Symbol.for("react.view_transition"),
11411148
MAYBE_ITERATOR_SYMBOL = Symbol.iterator,
1149+
enableRemoveConsolePatches =
1150+
require("ReactFeatureFlags").enableRemoveConsolePatches,
11421151
warningWWW = require("warning"),
11431152
didWarnStateUpdateForUnmountedComponent = {},
11441153
ReactNoopUpdateQueue = {
@@ -1947,7 +1956,7 @@ __DEV__ &&
19471956
exports.useTransition = function () {
19481957
return resolveDispatcher().useTransition();
19491958
};
1950-
exports.version = "19.1.0-www-classic-886c5ad9-20250115";
1959+
exports.version = "19.1.0-www-classic-18eaf51b-20250118";
19511960
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
19521961
"function" ===
19531962
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-dev.modern.js

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ __DEV__ &&
4141
_key++
4242
)
4343
args[_key - 1] = arguments[_key];
44-
printWarning("warn", format, args);
44+
if (enableRemoveConsolePatches) {
45+
var _console;
46+
(_console = console).warn.apply(_console, [format].concat(args));
47+
} else printWarning("warn", format, args);
4548
}
4649
function error$jscomp$0(format) {
4750
for (
@@ -52,18 +55,22 @@ __DEV__ &&
5255
_key2++
5356
)
5457
args[_key2 - 1] = arguments[_key2];
55-
printWarning("error", format, args);
58+
if (enableRemoveConsolePatches) {
59+
var _console2;
60+
(_console2 = console).error.apply(_console2, [format].concat(args));
61+
} else printWarning("error", format, args);
5662
}
5763
function printWarning(level, format, args) {
58-
level =
59-
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
60-
null != level &&
61-
level.getCurrentStack &&
62-
((level = level.getCurrentStack()),
63-
"" !== level && ((format += "%s"), args.push(level)));
64-
args.unshift(format);
65-
args.unshift(!1);
66-
warningWWW.apply(null, args);
64+
enableRemoveConsolePatches ||
65+
((level =
66+
require("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE),
67+
null != level &&
68+
level.getCurrentStack &&
69+
((level = level.getCurrentStack()),
70+
"" !== level && ((format += "%s"), args.push(level))),
71+
args.unshift(format),
72+
args.unshift(!1),
73+
warningWWW.apply(null, args));
6774
}
6875
function warnNoop(publicInstance, callerName) {
6976
publicInstance =
@@ -1139,6 +1146,8 @@ __DEV__ &&
11391146
REACT_TRACING_MARKER_TYPE = Symbol.for("react.tracing_marker"),
11401147
REACT_VIEW_TRANSITION_TYPE = Symbol.for("react.view_transition"),
11411148
MAYBE_ITERATOR_SYMBOL = Symbol.iterator,
1149+
enableRemoveConsolePatches =
1150+
require("ReactFeatureFlags").enableRemoveConsolePatches,
11421151
warningWWW = require("warning"),
11431152
didWarnStateUpdateForUnmountedComponent = {},
11441153
ReactNoopUpdateQueue = {
@@ -1947,7 +1956,7 @@ __DEV__ &&
19471956
exports.useTransition = function () {
19481957
return resolveDispatcher().useTransition();
19491958
};
1950-
exports.version = "19.1.0-www-modern-886c5ad9-20250115";
1959+
exports.version = "19.1.0-www-modern-18eaf51b-20250118";
19511960
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
19521961
"function" ===
19531962
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-prod.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,4 +630,4 @@ exports.useSyncExternalStore = function (
630630
exports.useTransition = function () {
631631
return ReactSharedInternals.H.useTransition();
632632
};
633-
exports.version = "19.1.0-www-classic-886c5ad9-20250115";
633+
exports.version = "19.1.0-www-classic-18eaf51b-20250118";

compiled/facebook-www/React-prod.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,4 +630,4 @@ exports.useSyncExternalStore = function (
630630
exports.useTransition = function () {
631631
return ReactSharedInternals.H.useTransition();
632632
};
633-
exports.version = "19.1.0-www-modern-886c5ad9-20250115";
633+
exports.version = "19.1.0-www-modern-18eaf51b-20250118";

compiled/facebook-www/React-profiling.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ exports.useSyncExternalStore = function (
634634
exports.useTransition = function () {
635635
return ReactSharedInternals.H.useTransition();
636636
};
637-
exports.version = "19.1.0-www-classic-886c5ad9-20250115";
637+
exports.version = "19.1.0-www-classic-18eaf51b-20250118";
638638
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
639639
"function" ===
640640
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-profiling.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ exports.useSyncExternalStore = function (
634634
exports.useTransition = function () {
635635
return ReactSharedInternals.H.useTransition();
636636
};
637-
exports.version = "19.1.0-www-modern-886c5ad9-20250115";
637+
exports.version = "19.1.0-www-modern-18eaf51b-20250118";
638638
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
639639
"function" ===
640640
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)