File tree 2 files changed +19
-1
lines changed
packages/typescript-estree
2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -224,7 +224,11 @@ function applyParserOptionsToExtra(options: TSESTreeOptions): void {
224
224
}
225
225
226
226
function warnAboutTSVersion ( ) : void {
227
- if ( ! isRunningSupportedTypeScriptVersion && ! warnedAboutTSVersion ) {
227
+ if (
228
+ ! isRunningSupportedTypeScriptVersion &&
229
+ ! warnedAboutTSVersion &&
230
+ process . stdout . isTTY
231
+ ) {
228
232
const border = '=============' ;
229
233
const versionWarning = [
230
234
border ,
Original file line number Diff line number Diff line change @@ -3,20 +3,34 @@ import * as parser from '../../src/parser';
3
3
4
4
jest . mock ( 'semver' ) ;
5
5
6
+ const resetIsTTY = process . stdout . isTTY ;
7
+
6
8
describe ( 'Warn on unsupported TypeScript version' , ( ) => {
7
9
afterEach ( ( ) => {
8
10
jest . resetModules ( ) ;
9
11
jest . resetAllMocks ( ) ;
12
+ process . stdout . isTTY = resetIsTTY ;
10
13
} ) ;
11
14
12
15
it ( 'should warn the user if they are using an unsupported TypeScript version' , ( ) => {
13
16
( semver . satisfies as jest . Mock ) . mockReturnValue ( false ) ;
14
17
jest . spyOn ( console , 'log' ) . mockImplementation ( ) ;
18
+ process . stdout . isTTY = true ;
19
+
15
20
parser . parse ( '' ) ;
16
21
expect ( console . log ) . toHaveBeenCalledWith (
17
22
expect . stringContaining (
18
23
'WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree' ,
19
24
) ,
20
25
) ;
21
26
} ) ;
27
+
28
+ it ( 'should not warn the user when the user is running on a non TTY process' , ( ) => {
29
+ ( semver . satisfies as jest . Mock ) . mockReturnValue ( false ) ;
30
+ jest . spyOn ( console , 'log' ) . mockImplementation ( ) ;
31
+ process . stdout . isTTY = false ;
32
+
33
+ parser . parse ( '' ) ;
34
+ expect ( console . log ) . not . toHaveBeenCalled ( ) ;
35
+ } ) ;
22
36
} ) ;
You can’t perform that action at this time.
0 commit comments