@@ -14,24 +14,8 @@ const astNodeTypes = require("./lib/ast-node-types"),
14
14
15
15
const SUPPORTED_TYPESCRIPT_VERSIONS = require ( "./package.json" ) . devDependencies . typescript ;
16
16
const ACTIVE_TYPESCRIPT_VERSION = ts . version ;
17
-
18
17
const isRunningSupportedTypeScriptVersion = semver . satisfies ( ACTIVE_TYPESCRIPT_VERSION , SUPPORTED_TYPESCRIPT_VERSIONS ) ;
19
18
20
- if ( ! isRunningSupportedTypeScriptVersion ) {
21
- const border = "=============" ;
22
- const versionWarning = [
23
- border ,
24
- "WARNING: You are currently running a version of TypeScript which is not officially supported by typescript-eslint-parser." ,
25
- "You may find that it works just fine, or you may not." ,
26
- `SUPPORTED TYPESCRIPT VERSIONS: ${ SUPPORTED_TYPESCRIPT_VERSIONS } ` ,
27
- `YOUR TYPESCRIPT VERSION: ${ ACTIVE_TYPESCRIPT_VERSION } ` ,
28
- "Please only submit bug reports when using the officially supported version." ,
29
- border
30
- ] ;
31
-
32
- console . warn ( versionWarning . join ( "\n\n" ) ) ; // eslint-disable-line no-console
33
- }
34
-
35
19
let extra ;
36
20
37
21
/**
@@ -49,7 +33,8 @@ function resetExtra() {
49
33
errors : [ ] ,
50
34
strict : false ,
51
35
ecmaFeatures : { } ,
52
- useJSXTextNode : false
36
+ useJSXTextNode : false ,
37
+ log : console . log // eslint-disable-line no-console
53
38
} ;
54
39
}
55
40
@@ -109,6 +94,27 @@ function parse(code, options) {
109
94
extra . useJSXTextNode = true ;
110
95
}
111
96
97
+ /**
98
+ * Allow the user to override the function used for logging
99
+ */
100
+ if ( typeof options . loggerFn === "function" ) {
101
+ extra . log = options . loggerFn ;
102
+ }
103
+
104
+ }
105
+
106
+ if ( ! isRunningSupportedTypeScriptVersion ) {
107
+ const border = "=============" ;
108
+ const versionWarning = [
109
+ border ,
110
+ "WARNING: You are currently running a version of TypeScript which is not officially supported by typescript-eslint-parser." ,
111
+ "You may find that it works just fine, or you may not." ,
112
+ `SUPPORTED TYPESCRIPT VERSIONS: ${ SUPPORTED_TYPESCRIPT_VERSIONS } ` ,
113
+ `YOUR TYPESCRIPT VERSION: ${ ACTIVE_TYPESCRIPT_VERSION } ` ,
114
+ "Please only submit bug reports when using the officially supported version." ,
115
+ border
116
+ ] ;
117
+ extra . log ( versionWarning . join ( "\n\n" ) ) ;
112
118
}
113
119
114
120
// Even if jsx option is set in typescript compiler, filename still has to
0 commit comments