@@ -14,24 +14,8 @@ const astNodeTypes = require("./lib/ast-node-types"),
1414
1515const SUPPORTED_TYPESCRIPT_VERSIONS = require ( "./package.json" ) . devDependencies . typescript ;
1616const ACTIVE_TYPESCRIPT_VERSION = ts . version ;
17-
1817const isRunningSupportedTypeScriptVersion = semver . satisfies ( ACTIVE_TYPESCRIPT_VERSION , SUPPORTED_TYPESCRIPT_VERSIONS ) ;
1918
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-
3519let extra ;
3620
3721/**
@@ -49,7 +33,8 @@ function resetExtra() {
4933 errors : [ ] ,
5034 strict : false ,
5135 ecmaFeatures : { } ,
52- useJSXTextNode : false
36+ useJSXTextNode : false ,
37+ log : console . log // eslint-disable-line no-console
5338 } ;
5439}
5540
@@ -109,6 +94,27 @@ function parse(code, options) {
10994 extra . useJSXTextNode = true ;
11095 }
11196
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" ) ) ;
112118 }
113119
114120 // Even if jsx option is set in typescript compiler, filename still has to
0 commit comments