Skip to content

Commit 8fbf50c

Browse files
committed
version detection: Do not throw a raw error after the first warning
- Adjust the conditions to always assume a latest react version when e.code === 'MODULE_NOT_FOUND' - The `warnedForMissingVersion` flag only controls the warning message and not the handling of the error Ref: jsx-eslint#2276
1 parent f59e927 commit 8fbf50c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/util/version.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ function detectReactVersion() {
2020
const react = require(reactPath); // eslint-disable-line import/no-dynamic-require
2121
return react.version;
2222
} catch (e) {
23-
if (!warnedForMissingVersion && e.code === 'MODULE_NOT_FOUND') {
24-
error('Warning: React version was set to "detect" in eslint-plugin-react settings, ' +
23+
if (e.code === 'MODULE_NOT_FOUND') {
24+
if (!warnedForMissingVersion) {
25+
error('Warning: React version was set to "detect" in eslint-plugin-react settings, ' +
2526
'but the "react" package is not installed. Assuming latest React version for linting.');
26-
warnedForMissingVersion = true;
27+
warnedForMissingVersion = true;
28+
}
2729
return '999.999.999';
2830
}
2931
throw e;

0 commit comments

Comments
 (0)