Skip to content

Commit

Permalink
version detection: Do not throw a raw error after the first warning
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
abhishekdev committed Jun 28, 2019
1 parent f59e927 commit 8fbf50c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/util/version.js
Expand Up @@ -20,10 +20,12 @@ function detectReactVersion() {
const react = require(reactPath); // eslint-disable-line import/no-dynamic-require
return react.version;
} catch (e) {
if (!warnedForMissingVersion && e.code === 'MODULE_NOT_FOUND') {
error('Warning: React version was set to "detect" in eslint-plugin-react settings, ' +
if (e.code === 'MODULE_NOT_FOUND') {
if (!warnedForMissingVersion) {
error('Warning: React version was set to "detect" in eslint-plugin-react settings, ' +
'but the "react" package is not installed. Assuming latest React version for linting.');
warnedForMissingVersion = true;
warnedForMissingVersion = true;
}
return '999.999.999';
}
throw e;
Expand Down

0 comments on commit 8fbf50c

Please sign in to comment.