Skip to content

Commit a0e3a2b

Browse files
authored
Merge pull request #22 from homer0/next
Fix typos, support the `@notes` tag, and make Prettier a peer dep
2 parents 9a96cef + 7e6d23e commit a0e3a2b

26 files changed

+1536
-1231
lines changed

README.md

Lines changed: 45 additions & 9 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)
@@ -29,7 +65,7 @@ A [Prettier](https://prettier.io) plugin to format [JSDoc](https://jsdoc.app) bl
2965
- [Manage indentation for pseudo code examples](#manage-indentation-for-pseudo-code-examples)
3066
- [`@access` tag](#access-tag)
3167
- [Allow @access tag](#allow-access-tag)
32-
- [Enfore the use of the @access tag](#enfore-the-use-of-the-access-tag)
68+
- [Enforce the use of the @access tag](#enfore-the-use-of-the-access-tag)
3369
- [Types with string literals](#types-with-string-literals)
3470
- [Format types with string literals](#format-types-with-string-literals)
3571
- [Specify quotes types for string literals](#specify-quotes-types-for-string-literals)
@@ -249,7 +285,7 @@ Whether or not the `@access` tag can be used; if `false`, when a tag is found, i
249285
*/
250286
```
251287

252-
##### Enfore the use of the @access tag
288+
##### Enforce the use of the @access tag
253289

254290
| Option | Type | Default |
255291
| ----------------------- | ------- | ------- |
@@ -529,9 +565,9 @@ Whether or not to sort the tags of a JSDoc block.
529565

530566
| Option | Type | Default |
531567
| ---------------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
532-
| `jsdocTagsOrder` | array | <ul><li>`type`</li><li>`typedef`</li><li>`callback`</li><li>`function`</li><li>`method`</li><li>`class`</li><li>`file`</li><li>`constant`</li><li>`description`</li><li>`classdesc`</li><li>`example`</li><li>`param`</li><li>`property`</li><li>`returns`</li><li>`template`</li><li>`augments`</li><li>`extends`</li><li>`throws`</li><li>`yields`</li><li>`fires`</li><li>`listens`</li><li>`async`</li><li>`abstract`</li><li>`override`</li><li>`private`</li><li>`protected`</li><li>`public`</li><li>`access`</li><li>`desprecated`</li><li>`author`</li><li>`version`</li><li>`since`</li><li>`member`</li><li>`memberof`</li><li>`category`</li><li>`external`</li><li>`see`</li><li>`other`</li><li>`todo`</li></ul> |
568+
| `jsdocTagsOrder` | array | <ul><li>`type`</li><li>`typedef`</li><li>`callback`</li><li>`function`</li><li>`method`</li><li>`class`</li><li>`file`</li><li>`constant`</li><li>`description`</li><li>`classdesc`</li><li>`example`</li><li>`param`</li><li>`property`</li><li>`returns`</li><li>`template`</li><li>`augments`</li><li>`extends`</li><li>`throws`</li><li>`yields`</li><li>`fires`</li><li>`listens`</li><li>`async`</li><li>`abstract`</li><li>`override`</li><li>`private`</li><li>`protected`</li><li>`public`</li><li>`access`</li><li>`deprecated`</li><li>`author`</li><li>`version`</li><li>`since`</li><li>`member`</li><li>`memberof`</li><li>`category`</li><li>`external`</li><li>`see`</li><li>`other`</li><li>`todo`</li></ul> |
533569

534-
A list specifing the order in which the the tags of a JSDoc block should be sorted. It supports an `other` item to place tags that are not on the list.
570+
A list specifying the order in which the the tags of a JSDoc block should be sorted. It supports an `other` item to place tags that are not on the list.
535571

536572
#### Rendering
537573

@@ -608,7 +644,7 @@ The alternative:
608644
| ------------------------ | ------- | ------- |
609645
| `jsdocGroupColumnsByTag` | boolean | `true` |
610646

611-
Whether to respect column alignment within the same tag. For example: all `@param` tags are agligned with eachother, but not with all the `@throws` tags.
647+
Whether to respect column alignment within the same tag. For example: all `@param` tags are aligned with each other, but not with all the `@throws` tags.
612648

613649
```js
614650
// jsdocGroupColumnsByTag: false
@@ -642,7 +678,7 @@ Whether to respect column alignment within the same tag. For example: all `@para
642678
| ------------------------ | ------- | ------- |
643679
| `jsdocConsistentColumns` | boolean | `true` |
644680

645-
This is for when the columns are algined by tags; if `true` and one tag can't use columns, no other tag will use them either.
681+
This is for when the columns are aligned by tags; if `true` and one tag can't use columns, no other tag will use them either.
646682

647683
```js
648684
// jsdocConsistentColumns: true
@@ -997,7 +1033,7 @@ The problem is that the plugin will end up putting those lines together, as it w
9971033
*/
9981034
```
9991035

1000-
It may look like a bug, but this is actually the functionality that formats the the descriptions in order to respect the [`printWidth`/`jsodcPrintWidth`](#custom-width) option.
1036+
It may look like a bug, but this is actually the functionality that formats the the descriptions in order to respect the [`printWidth`/`jsdocPrintWidth`](#custom-width) option.
10011037

10021038
The way you can solve this is by adding a period at the end of the line, which will tell the plugin that you ended the sentence and that it should respect the line break
10031039

@@ -1097,7 +1133,7 @@ module.exports = { only: true, jsdocPrintWidth: 70 };
10971133
*/
10981134
```
10991135

1100-
- The `module.exports` specifiy the plugin options for that specific case.
1136+
- The `module.exports` defines the plugin options for that specific case.
11011137
- `only: true` is not a plugin option, but will make the test runner ignore all the other tests, and only run the one you specify.
11021138
- Below `//# input` you can put any number of comment blocks, in the state you would expect the plugin to pick them.
11031139
- Below `//# output` you have to put the expected output after formatting the input with the plugin.
@@ -1113,4 +1149,4 @@ Ok, there won't accept options requests? that's perfect, it doesn't make sense t
11131149

11141150
Enough rant; I started using Prettier a couple of weeks ago and being a huge fan of JSDoc, I wanted to use it to format JSDoc blocks too, something I've doing, for sometime now, using a Node script that I was trying to make into a VSCode plugin :P.
11151151

1116-
I found [prettier-plugin-jsdoc](https://github.com/hosseinmd/prettier-plugin-jsdoc/) by [@hosseinmd](https://github.com/hosseinmd), but it (currently) doesn't cover most of the cases I wanted (like columns creations), it's written in TypeScript (which I don't like very much) and if I were to fork and send PRs, it could've taken forever (you can see the commits for this package), and it seemed like the perfect oportunity to try [Ramda](https://ramdajs.com) and functional programming... so I started a new one.
1152+
I found [prettier-plugin-jsdoc](https://github.com/hosseinmd/prettier-plugin-jsdoc/) by [@hosseinmd](https://github.com/hosseinmd), but it (currently) doesn't cover most of the cases I wanted (like columns creations), it's written in TypeScript (which I don't like very much) and if I were to fork and send PRs, it could've taken forever (you can see the commits for this package), and it seemed like the perfect opportunity to try [Ramda](https://ramdajs.com) and functional programming... so I started a new one.

package.json

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,27 @@
1818
"type": "commonjs",
1919
"dependencies": {
2020
"comment-parser": "^1.4.1",
21-
"prettier": "^3.3.3",
2221
"ramda": "0.30.1"
2322
},
2423
"devDependencies": {
25-
"@commitlint/cli": "^19.5.0",
26-
"@commitlint/config-conventional": "^19.5.0",
27-
"@homer0/eslint-plugin": "^12.0.6",
24+
"@commitlint/cli": "^19.8.0",
25+
"@commitlint/config-conventional": "^19.8.0",
26+
"@homer0/eslint-plugin": "^12.0.8",
2827
"@homer0/prettier-config": "^1.1.3",
2928
"@semantic-release/changelog": "^6.0.3",
3029
"@semantic-release/git": "^10.0.1",
3130
"eslint": "^8.57.1",
32-
"husky": "^9.1.6",
33-
"is-ci": "^3.0.1",
31+
"husky": "^9.1.7",
32+
"is-ci": "^4.1.0",
3433
"jest": "^29.7.0",
3534
"jest-environment-node": "^29.7.0",
3635
"leasot": "^14.4.0",
37-
"lint-staged": "^15.2.10",
38-
"prettier": "^3.3.3",
39-
"semantic-release": "^24.2.0"
36+
"lint-staged": "^15.5.0",
37+
"prettier": "^3.5.3",
38+
"semantic-release": "^24.2.3"
39+
},
40+
"peerDependencies": {
41+
"prettier": "^3.5.3"
4042
},
4143
"engine-strict": true,
4244
"engines": {

0 commit comments

Comments
 (0)