File tree 2 files changed +9
-2
lines changed
2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -9,15 +9,20 @@ const error = require('./error');
9
9
10
10
let warnedForMissingVersion = false ;
11
11
12
+ function resetWarningFlag ( ) {
13
+ warnedForMissingVersion = false ;
14
+ }
15
+
12
16
function detectReactVersion ( ) {
13
17
try {
14
18
const reactPath = resolve . sync ( 'react' , { basedir : process . cwd ( ) } ) ;
15
19
const react = require ( reactPath ) ;
16
20
return react . version ;
17
21
} catch ( e ) {
18
- if ( e . code === 'MODULE_NOT_FOUND' ) {
22
+ if ( ! warnedForMissingVersion && e . code === 'MODULE_NOT_FOUND' ) {
19
23
error ( 'Warning: React version was set to "detect" in eslint-plugin-react settings, ' +
20
24
'but the "react" package is not installed. Assuming latest React version for linting.' ) ;
25
+ warnedForMissingVersion = true ;
21
26
return '999.999.999' ;
22
27
}
23
28
throw e ;
@@ -107,5 +112,6 @@ function testFlowVersion(context, methodVer) {
107
112
108
113
module . exports = {
109
114
testReactVersion,
110
- testFlowVersion
115
+ testFlowVersion,
116
+ resetWarningFlag
111
117
} ;
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ describe('Version', () => {
15
15
process . chdir ( base ) ;
16
16
sinon . stub ( console , 'error' ) ;
17
17
expectedErrorArgs = [ ] ;
18
+ versionUtil . resetWarningFlag ( ) ;
18
19
} ) ;
19
20
20
21
afterEach ( ( ) => {
You can’t perform that action at this time.
0 commit comments