Skip to content

Commit

Permalink
fix: correctly parse tsconfig.json when they have comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavopch committed May 28, 2020
1 parent bbcbf12 commit 9fda2c4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down

0 comments on commit 9fda2c4

Please sign in to comment.