Skip to content

Commit

Permalink
[compiler:eslint] Don't crash if hermes parser fails to parse
Browse files Browse the repository at this point in the history
Eslint rules should never throw, so if we fail to parse with Babel or
Hermes, we should just ignore the error. This should fix issues such as
trying to run the eslint rule on non tsx|ts|jsx|js files, Hermes parser
not supporting certain JS syntax, etc.

I didn't add a test for this as our eslint-rule-tester config uses
hermes-eslint parser, so it wasn't possible to add a top level await as
it would crash hermes-eslint before our rule was triggered. Similarly I
couldn't add a test for non-JS files as it would not be parseable by
hermes-eslint.

Fixes #29107

ghstack-source-id: 60afcdb89ab4a8d2e4697cc50c5490803e7cbeac
Pull Request resolved: #29631

DiffTrain build for commit 113c8e7.
  • Loading branch information
poteto committed May 31, 2024
1 parent 9f66192 commit fc83ec7
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<843340fb623449714d5807ec34c388a7>>
* @generated SignedSource<<13c28188b56445576946d6d9cce624ae>>
*/

'use strict';
Expand Down Expand Up @@ -23495,7 +23495,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
return root;
}

var ReactVersion = '19.0.0-rc-adbec0c25a-20240531';
var ReactVersion = '19.0.0-rc-113c8e7f72-20240601';

/*
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<905cc175856264e313ce8da1a2a4238b>>
* @generated SignedSource<<05cdee97fcfa21f8417ae54b5d232cda>>
*/

"use strict";
Expand Down Expand Up @@ -9303,7 +9303,7 @@ var devToolsConfig$jscomp$inline_1047 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "19.0.0-rc-adbec0c25a-20240531",
version: "19.0.0-rc-113c8e7f72-20240601",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1234 = {
Expand Down Expand Up @@ -9334,7 +9334,7 @@ var internals$jscomp$inline_1234 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-rc-adbec0c25a-20240531"
reconcilerVersion: "19.0.0-rc-113c8e7f72-20240601"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1235 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<2ec503c3ec9cc5ba080608bcfdeb069e>>
* @generated SignedSource<<34119073e84da55f690530f1a9a284e2>>
*/

"use strict";
Expand Down Expand Up @@ -9925,7 +9925,7 @@ var devToolsConfig$jscomp$inline_1130 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "19.0.0-rc-adbec0c25a-20240531",
version: "19.0.0-rc-113c8e7f72-20240601",
rendererPackageName: "react-test-renderer"
};
(function (internals) {
Expand Down Expand Up @@ -9969,7 +9969,7 @@ var devToolsConfig$jscomp$inline_1130 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-rc-adbec0c25a-20240531"
reconcilerVersion: "19.0.0-rc-113c8e7f72-20240601"
});
exports._Scheduler = Scheduler;
exports.act = act;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<4f7e50456e26afbb6944fc28181daa80>>
* @generated SignedSource<<fc7b4a58c16e9a6a06af463eb929ff3c>>
*/

'use strict';
Expand All @@ -24,7 +24,7 @@ if (
}
var dynamicFlagsUntyped = require('ReactNativeInternalFeatureFlags');

var ReactVersion = '19.0.0-rc-adbec0c25a-20240531';
var ReactVersion = '19.0.0-rc-113c8e7f72-20240601';

// Re-export dynamic flags from the internal module.
var dynamicFlags = dynamicFlagsUntyped; // We destructure each value before re-exporting to avoid a dynamic look-up on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<ab9c75532395cf1647c807f37789a8e4>>
* @generated SignedSource<<b881f6bd781aa4eb543f0bd5e6192a25>>
*/

"use strict";
Expand Down Expand Up @@ -604,4 +604,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-rc-adbec0c25a-20240531";
exports.version = "19.0.0-rc-113c8e7f72-20240601";
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<9f5c8cb9b979f6b6f6c25611a0886ae3>>
* @generated SignedSource<<7fa2cdb3085d475285041527143c2b51>>
*/

"use strict";
Expand Down Expand Up @@ -608,7 +608,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactSharedInternals.H.useTransition();
};
exports.version = "19.0.0-rc-adbec0c25a-20240531";
exports.version = "19.0.0-rc-113c8e7f72-20240601";
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
"function" ===
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
adbec0c25aff07f04b0678679554505ba2813168
113c8e7f72bcf5d3bc285546da1508b45da3cf53
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<959db6b7a430088709ef79d2031321cd>>
* @generated SignedSource<<316b8f957bb17362625530eaf6d201dc>>
*/

'use strict';
Expand Down Expand Up @@ -26230,7 +26230,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
return root;
}

var ReactVersion = '19.0.0-rc-adbec0c25a-20240531';
var ReactVersion = '19.0.0-rc-113c8e7f72-20240601';

/*
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<d4d79b9c46da5483403dab31cf882201>>
* @generated SignedSource<<4f65e901516bd1fa7668509518753b5f>>
*/

"use strict";
Expand Down Expand Up @@ -10556,7 +10556,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1124 = {
findFiberByHostInstance: getInstanceFromNode,
bundleType: 0,
version: "19.0.0-rc-adbec0c25a-20240531",
version: "19.0.0-rc-113c8e7f72-20240601",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForInstance: getInspectorDataForInstance,
Expand Down Expand Up @@ -10599,7 +10599,7 @@ var internals$jscomp$inline_1350 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-rc-adbec0c25a-20240531"
reconcilerVersion: "19.0.0-rc-113c8e7f72-20240601"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1351 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<8ccb12c6c371309a0a428e1772ab27d6>>
* @generated SignedSource<<c7afcffda1ff18f1ef53fbe4a9345d01>>
*/

"use strict";
Expand Down Expand Up @@ -11262,7 +11262,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1205 = {
findFiberByHostInstance: getInstanceFromNode,
bundleType: 0,
version: "19.0.0-rc-adbec0c25a-20240531",
version: "19.0.0-rc-113c8e7f72-20240601",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForInstance: getInspectorDataForInstance,
Expand Down Expand Up @@ -11318,7 +11318,7 @@ var roots = new Map(),
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-rc-adbec0c25a-20240531"
reconcilerVersion: "19.0.0-rc-113c8e7f72-20240601"
});
exports.createPortal = function (children, containerTag) {
return createPortal$1(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<2f599e53bfb1d0ee6eaf5cd63bae3a13>>
* @generated SignedSource<<7cbcd63cae31bd6f6720af95692a3394>>
*/

'use strict';
Expand Down Expand Up @@ -26586,7 +26586,7 @@ identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, transition
return root;
}

var ReactVersion = '19.0.0-rc-adbec0c25a-20240531';
var ReactVersion = '19.0.0-rc-113c8e7f72-20240601';

/*
* The `'' + value` pattern (used in perf-sensitive code) throws for Symbol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<397a4e89bef38724e564db4d5df7d186>>
* @generated SignedSource<<40be87ce7d9c02f97689e0d361b7eeb6>>
*/

"use strict";
Expand Down Expand Up @@ -10701,11 +10701,11 @@ function traverseOwnerTreeUp(hierarchy, instance) {
traverseOwnerTreeUp(hierarchy, instance);
}
var isomorphicReactPackageVersion = React.version;
if ("19.0.0-rc-adbec0c25a-20240531" !== isomorphicReactPackageVersion)
if ("19.0.0-rc-113c8e7f72-20240601" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-native-renderer" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-native-renderer: 19.0.0-rc-adbec0c25a-20240531\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-native-renderer: 19.0.0-rc-113c8e7f72-20240601\nLearn more: https://react.dev/warnings/version-mismatch")
);
if (
"function" !==
Expand Down Expand Up @@ -10755,7 +10755,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1192 = {
findFiberByHostInstance: getInstanceFromTag,
bundleType: 0,
version: "19.0.0-rc-adbec0c25a-20240531",
version: "19.0.0-rc-113c8e7f72-20240601",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForInstance: getInspectorDataForInstance,
Expand Down Expand Up @@ -10798,7 +10798,7 @@ var internals$jscomp$inline_1439 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-rc-adbec0c25a-20240531"
reconcilerVersion: "19.0.0-rc-113c8e7f72-20240601"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1440 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<75a5028640a4a5d0e637c6be72a8cf5a>>
* @generated SignedSource<<3563cf3807975b917ca57c7f25464fd7>>
*/

"use strict";
Expand Down Expand Up @@ -11408,11 +11408,11 @@ function traverseOwnerTreeUp(hierarchy, instance) {
traverseOwnerTreeUp(hierarchy, instance);
}
var isomorphicReactPackageVersion = React.version;
if ("19.0.0-rc-adbec0c25a-20240531" !== isomorphicReactPackageVersion)
if ("19.0.0-rc-113c8e7f72-20240601" !== isomorphicReactPackageVersion)
throw Error(
'Incompatible React versions: The "react" and "react-native-renderer" packages must have the exact same version. Instead got:\n - react: ' +
(isomorphicReactPackageVersion +
"\n - react-native-renderer: 19.0.0-rc-adbec0c25a-20240531\nLearn more: https://react.dev/warnings/version-mismatch")
"\n - react-native-renderer: 19.0.0-rc-113c8e7f72-20240601\nLearn more: https://react.dev/warnings/version-mismatch")
);
if (
"function" !==
Expand Down Expand Up @@ -11462,7 +11462,7 @@ var roots = new Map(),
devToolsConfig$jscomp$inline_1273 = {
findFiberByHostInstance: getInstanceFromTag,
bundleType: 0,
version: "19.0.0-rc-adbec0c25a-20240531",
version: "19.0.0-rc-113c8e7f72-20240601",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForInstance: getInspectorDataForInstance,
Expand Down Expand Up @@ -11518,7 +11518,7 @@ var roots = new Map(),
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "19.0.0-rc-adbec0c25a-20240531"
reconcilerVersion: "19.0.0-rc-113c8e7f72-20240601"
});
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
computeComponentStackForErrorReporting: function (reactTag) {
Expand Down

0 comments on commit fc83ec7

Please sign in to comment.