Skip to content

Commit

Permalink
fix(prettier): Add default parser for prettier
Browse files Browse the repository at this point in the history
Prettier is no longer support default parser since 1.13.0.
This change is to add `parser: 'babylon'` into prettier options.

Fix: gregberge#108
  • Loading branch information
starkwang committed May 28, 2018
1 parent c61438b commit 294f77d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/configToOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const defaultConfig = {
jsxBracketSameLine: undefined, // default to prettier
keepUselessDefs: false,
native: false,
parser: 'babylon', // default to prettier
precision: 3, // default to svgo
prettier: true,
ref: false,
Expand Down Expand Up @@ -77,6 +78,7 @@ function configToOptions(config = {}) {
trailingComma: config.trailingComma,
bracketSpacing: config.bracketSpacing,
jsxBracketSameLine: config.jsxBracketSameLine,
parser: config.parser
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/prettier.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import prettier from './prettier'

describe('prettier', () => {
it('should prettify code', () => {
const result = prettier(`const foo = <div></div>`)
const result = prettier(`const foo = <div></div>`, { parser: 'babylon' })
expect(result).toBe('const foo = <div />;\n')
})

it('should support options', () => {
const result = prettier(`const foo = <div></div>`, { semi: false })
const result = prettier(`const foo = <div></div>`, { semi: false, parser: 'babylon' })
expect(result).toBe('const foo = <div />\n')
})
})

0 comments on commit 294f77d

Please sign in to comment.