Skip to content

Commit cbcb936

Browse files
Merge pull request #81 from devoxa/fix-jsonc
Add override for JSONC
2 parents 27926fa + 9b12fbe commit cbcb936

5 files changed

Lines changed: 23 additions & 2 deletions

File tree

prettier.config.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import prettier from 'prettier'
22

3-
declare const options: prettier.Options
4-
export default options
3+
declare const config: prettier.Config
4+
export default config

prettier.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,10 @@ module.exports = {
1616
arrowParens: 'always',
1717
proseWrap: 'always',
1818
endOfLine: 'lf',
19+
20+
overrides: [
21+
// Disable formatting JSONC with trailing commas (discouraged by the format)
22+
// See https://github.com/prettier/prettier/issues/15956#issuecomment-1987146114
23+
{ files: ['*.jsonc'], options: { trailingComma: 'none' } },
24+
],
1925
}

tests/basicFile.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
interface Foo {
2+
bar: number
3+
}
4+
5+
export const foo: Foo = { bar: 1 }

tests/reactFile.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import React from 'react'
2+
3+
// This is a Button component
4+
export const Button = () => {
5+
return <div>Foo Bar</div>
6+
}

tests/tokenFile.jsonc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
// This is foo.
3+
"foo": "bar"
4+
}

0 commit comments

Comments
 (0)