Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit 547db22

Browse files
committed
Move the warning message outside of the parser function
1 parent e687d36 commit 547db22

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

parser.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,21 @@ const SUPPORTED_TYPESCRIPT_VERSIONS = require("./package.json").devDependencies.
1616
const ACTIVE_TYPESCRIPT_VERSION = ts.version;
1717
const isRunningSupportedTypeScriptVersion = semver.satisfies(ACTIVE_TYPESCRIPT_VERSION, SUPPORTED_TYPESCRIPT_VERSIONS);
1818

19+
if (!isRunningSupportedTypeScriptVersion) {
20+
const border = "=============";
21+
const versionWarning = [
22+
border,
23+
"WARNING: You are currently running a version of TypeScript which is not officially supported by typescript-eslint-parser.",
24+
"You may find that it works just fine, or you may not.",
25+
`SUPPORTED TYPESCRIPT VERSIONS: ${SUPPORTED_TYPESCRIPT_VERSIONS}`,
26+
`YOUR TYPESCRIPT VERSION: ${ACTIVE_TYPESCRIPT_VERSION}`,
27+
"Please only submit bug reports when using the officially supported version.",
28+
border
29+
];
30+
console.log(versionWarning.join("\n\n"));
31+
}
32+
1933
let extra;
20-
let warnedAboutTSVersion = false;
2134

2235
/**
2336
* Resets the extra config object
@@ -104,21 +117,6 @@ function parse(code, options) {
104117

105118
}
106119

107-
if (!isRunningSupportedTypeScriptVersion && !warnedAboutTSVersion) {
108-
const border = "=============";
109-
const versionWarning = [
110-
border,
111-
"WARNING: You are currently running a version of TypeScript which is not officially supported by typescript-eslint-parser.",
112-
"You may find that it works just fine, or you may not.",
113-
`SUPPORTED TYPESCRIPT VERSIONS: ${SUPPORTED_TYPESCRIPT_VERSIONS}`,
114-
`YOUR TYPESCRIPT VERSION: ${ACTIVE_TYPESCRIPT_VERSION}`,
115-
"Please only submit bug reports when using the officially supported version.",
116-
border
117-
];
118-
extra.log(versionWarning.join("\n\n"));
119-
warnedAboutTSVersion = true;
120-
}
121-
122120
// Even if jsx option is set in typescript compiler, filename still has to
123121
// contain .tsx file extension
124122
const FILENAME = (extra.ecmaFeatures.jsx) ? "eslint.tsx" : "eslint.ts";

0 commit comments

Comments
 (0)