Skip to content

Commit c9e3893

Browse files
committed
docs: update README with installation info
1 parent 4f650cd commit c9e3893

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,49 @@ A [Prettier](https://prettier.io) plugin to format [JSDoc](https://jsdoc.app) bl
1010

1111
> If you are wondering why I built this, go to the [Motivation](#motivation) section.
1212
13+
- 📦 [Installation](#-Installation)
1314
- ⚙️ [Options](#%EF%B8%8F-options)
1415
- 🚫 [Ignoring blocks](#-ignoring-blocks)
1516
- ⚡️ [Modifying the functionality](#%EF%B8%8F-modifying-the-functionality)
1617
- 📖 [Troubleshooting](#-troubleshooting)
1718
- 🤘 [Development](#-development)
1819
- 🐞 [Validating bugs](#-validating-bugs)
1920

21+
### 📦 Installation
22+
23+
First, please check the [official documentation](https://prettier.io/docs/plugins#using-plugins) on how plugins are used.
24+
25+
Just to recap, and focusing in the configuration file approach, there are two ways in which you are probably going to be using this plugin:
26+
27+
#### 1. Adding it to your existing configuration
28+
29+
The simplest use case: you have a configuration with your rules, and you want to add the plugin. You'd need to define the `plugins` array, if you don't have it already, and add the plugin name to it:
30+
31+
```json
32+
{
33+
"tabWidth": 90,
34+
"plugins": ["@homer0/prettier-plugin-jsdoc"]
35+
}
36+
```
37+
38+
#### 2. Extending an existing configuration and adding the plugin
39+
40+
This is kind of confusing in the official docs, because it's not linked in the "using plugins" section, but rather in the ["using a shareable config"](https://prettier.io/docs/sharing-configurations#using-a-shareable-config) section.
41+
42+
Unfortunately, Prettier doesn't have a way to use and extend an existing configuration with a JSON syntax, so you have to change to a JavaScript file:
43+
44+
```js
45+
const config = require('@homer0/prettier-config');
46+
47+
module.exports = {
48+
...config,
49+
plugins: [
50+
...(config.plugins || []),
51+
'@homer0/prettier-plugin-jsdoc'
52+
],
53+
};
54+
```
55+
2056
### ⚙️ Options
2157

2258
- [`@description` tag](#description-tag)

0 commit comments

Comments
 (0)