From 9fda2c44918efdc412020db317a784b5ed47b5c2 Mon Sep 17 00:00:00 2001 From: Gustavo Date: Thu, 21 May 2020 19:44:11 -0300 Subject: [PATCH] fix: correctly parse tsconfig.json when they have comments --- lib/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 3c1ff4e..0cc9814 100755 --- a/lib/index.js +++ b/lib/index.js @@ -16,7 +16,10 @@ if (filesToCheck.length === 0) { // Load existing config const tsconfigPath = resolveFromRoot('tsconfig.json') -const tsconfig = require(tsconfigPath) +const tsconfigContent = fs.readFileSync(tsconfigPath).toString() +// Use 'eval' to read the JSON as regular JavaScript syntax so that comments are allowed +let tsconfig = {} +eval(`tsconfig = ${tsconfigContent}`) // Write a temp config file const tmpTsconfigPath = resolveFromRoot(`tsconfig.${randomChars()}.json`)