Release 3.0.0
This commit is contained in:
1 parent
44979b0a37
commit
186e0966b0
15 files changed
+444
-227
No files matched your search
@@ -9,7 +9,9 @@ Prettier uses [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) for co
|
||||
- A `"prettier"` key in your `package.json` file.
|
||||
- A `.prettierrc` file written in JSON or YAML.
|
||||
- A `.prettierrc.json`, `.prettierrc.yml`, `.prettierrc.yaml`, or `.prettierrc.json5` file.
|
||||
- A `.prettierrc.js`, `.prettierrc.cjs`, `prettier.config.js`, or `prettier.config.cjs` file that exports an object using `module.exports`.
|
||||
- A `.prettierrc.js`, or `prettier.config.js` file that exports an object using `export default` or `module.exports` (depends on the [`type`](https://nodejs.org/api/packages.html#type) value in your `package.json`).
|
||||
- A `.prettierrc.mjs`, or `prettier.config.mjs` file that exports an object using `export default`.
|
||||
- A `.prettierrc.cjs`, or `prettier.config.cjs` file that exports an object using `module.exports`.
|
||||
- A `.prettierrc.toml` file.
|
||||
|
||||
The configuration file will be resolved starting from the location of the file being formatted, and searching up the file tree until a config file is (or isn’t) found.
|
||||
@@ -31,16 +33,36 @@ JSON:
|
||||
}
|
||||
```
|
||||
|
||||
JS:
|
||||
JS(ESM):
|
||||
|
||||
```js
|
||||
// prettier.config.js or .prettierrc.js
|
||||
module.exports = {
|
||||
// prettier.config.js, .prettierrc.js, prettier.config.mjs, or .prettierrc.mjs
|
||||
|
||||
/** @type {import("prettier").Options} */
|
||||
const config = {
|
||||
trailingComma: "es5",
|
||||
tabWidth: 4,
|
||||
semi: false,
|
||||
singleQuote: true,
|
||||
};
|
||||
|
||||
export default config;
|
||||
```
|
||||
|
||||
JS(CommonJS):
|
||||
|
||||
```js
|
||||
// prettier.config.js, .prettierrc.js, prettier.config.cjs, or .prettierrc.cjs
|
||||
|
||||
/** @type {import("prettier").Options} */
|
||||
const config = {
|
||||
trailingComma: "es5",
|
||||
tabWidth: 4,
|
||||
semi: false,
|
||||
singleQuote: true,
|
||||
};
|
||||
|
||||
module.exports = config;
|
||||
```
|
||||
|
||||
YAML:
|
||||
@@ -131,8 +153,10 @@ An example configuration repository is available [here](https://github.com/azz/p
|
||||
> Note: This method does **not** offer a way to _extend_ the configuration to overwrite some properties from the shared configuration. If you need to do that, import the file in a `.prettierrc.js` file and export the modifications, e.g:
|
||||
>
|
||||
> ```js
|
||||
> module.exports = {
|
||||
> ...require("@company/prettier-config"),
|
||||
> import companyPrettierConfig from "@company/prettier-config";
|
||||
>
|
||||
> export default {
|
||||
> ...companyPrettierConfig,
|
||||
> semi: false,
|
||||
> };
|
||||
> ```
|
||||
|
||||
Reference in new issue
Block a user