You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(check-tag-names): allow rejecting normally valid tag names and/or providing custom error messages when suggesting tags to reject or replace (fixesgajus#108)
Reporting normally valid tags may be of interest for tags like `@todo`. This is implemented by allowing the user to set targeted `tagNamePreference` tags to `false` or to an object with only a `message` and no `replacement`
Custom messages for `check-tag-names` are implemented by allowing the user to set targeted `tagNamePreference` tags to an object with `message` and `replacement` (mirroring `preferredTypes` behavior). Note that for other rules leveraging `tagNamePreference` (via `utils.getPreferredTagName`) to find the user's preferred tag name, the `replacement` will be used in the likes of error messages but not the `message`.
Also, for various (param, return, and description-related) rules which have used `tagNamePreference` (via the `utils.getPreferredTagName` utility), report to user if they have blocked (probably inadvertently) and not indicated a replacement for the relevant tag needed by the rule in the `tagNamePreference` setting.
Copy file name to clipboardExpand all lines: .README/README.md
+54Lines changed: 54 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -147,6 +147,60 @@ Use `settings.jsdoc.tagNamePreference` to configure a preferred alias name for a
147
147
}
148
148
```
149
149
150
+
One may also use an object with a `message` and `replacement`, with `{{tagName}}` and `{{preferredType}}` (or its alias `{{replacement}}`) as template variables to be
151
+
substituted within `message`.
152
+
153
+
The following will report the message `@extends is to be used over @augments as it is more evocative of classes than @augments` upon encountering `@augments`.
154
+
155
+
```json
156
+
{
157
+
"rules": {},
158
+
"settings": {
159
+
"jsdoc": {
160
+
"tagNamePreference": {
161
+
"augments": {
162
+
"message": "@{{replacement}} is to be used over @{{tagName}} as it is more evocative of classes than @augments",
163
+
"replacement": "extends"
164
+
}
165
+
}
166
+
}
167
+
}
168
+
}
169
+
```
170
+
171
+
If one wishes to reject a normally valid tag, e.g., `@todo`, one may set the tag to `false`:
172
+
173
+
```json
174
+
{
175
+
"rules": {},
176
+
"settings": {
177
+
"jsdoc": {
178
+
"tagNamePreference": {
179
+
"todo": false
180
+
}
181
+
}
182
+
}
183
+
}
184
+
```
185
+
186
+
Or one may set the targeted tag to an object with a custom `message`, but without a `replacement` property:
187
+
188
+
```json
189
+
{
190
+
"rules": {},
191
+
"settings": {
192
+
"jsdoc": {
193
+
"tagNamePreference": {
194
+
"todo": {
195
+
"message": "We expect immediate perfection, so don't leave to-dos in your code."
196
+
}
197
+
}
198
+
}
199
+
}
200
+
}
201
+
```
202
+
203
+
150
204
The defaults in `eslint-plugin-jsdoc` (for tags which offer
Copy file name to clipboardExpand all lines: README.md
+205Lines changed: 205 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -197,6 +197,60 @@ Use `settings.jsdoc.tagNamePreference` to configure a preferred alias name for a
197
197
}
198
198
```
199
199
200
+
One may also use an object with a `message` and `replacement`, with `{{tagName}}` and `{{preferredType}}` (or its alias `{{replacement}}`) as template variables to be
201
+
substituted within `message`.
202
+
203
+
The following will report the message `@extends is to be used over @augments as it is more evocative of classes than @augments` upon encountering `@augments`.
204
+
205
+
```json
206
+
{
207
+
"rules": {},
208
+
"settings": {
209
+
"jsdoc": {
210
+
"tagNamePreference": {
211
+
"augments": {
212
+
"message": "@{{replacement}} is to be used over @{{tagName}} as it is more evocative of classes than @augments",
213
+
"replacement": "extends"
214
+
}
215
+
}
216
+
}
217
+
}
218
+
}
219
+
```
220
+
221
+
If one wishes to reject a normally valid tag, e.g., `@todo`, one may set the tag to `false`:
222
+
223
+
```json
224
+
{
225
+
"rules": {},
226
+
"settings": {
227
+
"jsdoc": {
228
+
"tagNamePreference": {
229
+
"todo": false
230
+
}
231
+
}
232
+
}
233
+
}
234
+
```
235
+
236
+
Or one may set the targeted tag to an object with a custom `message`, but without a `replacement` property:
237
+
238
+
```json
239
+
{
240
+
"rules": {},
241
+
"settings": {
242
+
"jsdoc": {
243
+
"tagNamePreference": {
244
+
"todo": {
245
+
"message": "We expect immediate perfection, so don't leave to-dos in your code."
246
+
}
247
+
}
248
+
}
249
+
}
250
+
}
251
+
```
252
+
253
+
200
254
The defaults in `eslint-plugin-jsdoc` (for tags which offer
201
255
aliases) are as follows:
202
256
@@ -955,6 +1009,15 @@ export class SomeClass {
955
1009
constructor(privateproperty:string) {}
956
1010
}
957
1011
// Message: Expected @param names to be "property". Got "prop".
0 commit comments