Skip to content

Commit

Permalink
Fix parsing tsconfig in json5 format (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
shrpne committed Feb 4, 2023
1 parent c22b3a0 commit 658cc6b
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 14 deletions.
3 changes: 2 additions & 1 deletion check.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { location } from 'vfile-location'
import { Worker } from 'worker_threads'
import pico from 'picocolors'
import glob from 'fast-glob'
import JSON5 from 'json5'

let require = createRequire(import.meta.url)

Expand Down Expand Up @@ -76,7 +77,7 @@ export async function check(
let compilerOptions
let tsconfigPath = join(cwd, 'tsconfig.json')
if (existsSync(tsconfigPath)) {
let tsconfig = JSON.parse(await fs.readFile(tsconfigPath))
let tsconfig = JSON5.parse(await fs.readFile(tsconfigPath))
compilerOptions = tsconfig.compilerOptions
}

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
},
"dependencies": {
"fast-glob": "^3.2.11",
"json5": "^2.2.3",
"nanospinner": "^1.1.0",
"picocolors": "^1.0.0",
"vfile-location": "^4.0.1"
Expand Down
64 changes: 52 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion test/fixtures/tsconfig/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
// tsconfig should support comments
"compilerOptions": {
"target": "ES5",
"experimentalDecorators": true,
"moduleResolution": "Node",
"lib": [
"ES2020.Promise"
]
}
}, // tsconfig should support trailing commas
}

0 comments on commit 658cc6b

Please sign in to comment.