prettier.star¶
Set Prettier options in whichever config a repo uses.
Supports .prettierrc (JSON or YAML), .prettierrc.json, .prettierrc.yaml,
.prettierrc.yml and the prettier key of package.json. JavaScript
configs (prettier.config.js and friends) can't be edited safely and are
not supported.
| Function | What it does |
|---|---|
find |
Finds the repo's Prettier config. |
get |
Reads an option from the Prettier config. |
set_option |
Sets an option in the Prettier config, keeping its format. |
find¶
Finds the repo's Prettier config.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
Returns: The path of the first of .prettierrc, .prettierrc.json,
.prettierrc.yaml and .prettierrc.yml that exists, package.json
when it has a prettier key, or None.
Example
get¶
Reads an option from the Prettier config.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
option |
The option, such as printWidth. |
Returns: The value, or None when it isn't set or there is no config. YAML values come back as strings.
Example
set_option¶
Sets an option in the Prettier config, keeping its format.
Arguments
| Name | Description |
|---|---|
repo |
The repo passed to change(repo). |
option |
The option, such as printWidth or trailingComma. |
value |
A string, number or boolean. |
Returns: True when the file changed; False when the repo has no config.
Example
Used in: prettier-eslint