4.0.0 • Published 8 months ago
prettier-format v4.0.0
prettier-format
auto load config and run prettier on code
Motivation
To load config and format code with prettier, you have to do
const config = await prettier.resolveConfig('path/to/file', {useCache: false})
const formatted = await prettier.format(source, {...config, semi: false})
I want it simple
const formatted = await format(source, {
filepath: 'path/to/file',
useCache: false,
semi: false,
})
Install
yarn add prettier-format
Usage
import format from 'prettier-format'
await format(`hello ( 'world' )`)
// => hello("world");\n
API
format(source, options?)
Returns promise
resolves with formatted code.
source
Type: string
Source code you want to format.
options
Type: object
any value prettier.resolveConfig
takes
any value prettier.format
takes
options.filepath
Type: string
The filepath of source code, if filepath is not empty, config will load automaticly.
Related
- write-prettier-file write formatted code to file.
3.2.2
9 months ago
3.2.1
9 months ago
3.2.0
10 months ago
3.2.3
9 months ago
4.0.0
8 months ago
3.1.0
2 years ago
3.0.4
2 years ago
3.0.3
3 years ago
3.0.2
3 years ago
3.0.1
3 years ago
3.0.0
3 years ago
2.0.2
3 years ago
2.0.1
3 years ago
2.0.0
3 years ago
1.1.5
4 years ago
1.1.4
4 years ago
1.1.3
4 years ago
1.1.2
4 years ago
1.1.1
4 years ago
1.1.0
4 years ago
1.0.1
5 years ago
1.0.0
5 years ago
0.0.0
5 years ago