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
Allow rejecting normally valid tag names and/or providing custom error messages when suggesting tags to reject or replace (#302)
* feat(check-tag-names): allow rejecting normally valid tag names and/or providing custom error messages when suggesting tags to reject or replace (fixes#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.
Also, ensure `require-param-name` and `check-examples` report preferred tag name (not necessarily `param` or `example`, respectively) and err if `example` is a rejected tag
Copy file name to clipboardExpand all lines: .README/README.md
+53Lines changed: 53 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -147,6 +147,59 @@ 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`.
151
+
152
+
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`.
153
+
154
+
```json
155
+
{
156
+
"rules": {},
157
+
"settings": {
158
+
"jsdoc": {
159
+
"tagNamePreference": {
160
+
"augments": {
161
+
"message": "@extends is to be used over @augments as it is more evocative of classes than @augments",
162
+
"replacement": "extends"
163
+
}
164
+
}
165
+
}
166
+
}
167
+
}
168
+
```
169
+
170
+
If one wishes to reject a normally valid tag, e.g., `@todo`, one may set the tag to `false`:
171
+
172
+
```json
173
+
{
174
+
"rules": {},
175
+
"settings": {
176
+
"jsdoc": {
177
+
"tagNamePreference": {
178
+
"todo": false
179
+
}
180
+
}
181
+
}
182
+
}
183
+
```
184
+
185
+
Or one may set the targeted tag to an object with a custom `message`, but without a `replacement` property:
186
+
187
+
```json
188
+
{
189
+
"rules": {},
190
+
"settings": {
191
+
"jsdoc": {
192
+
"tagNamePreference": {
193
+
"todo": {
194
+
"message": "We expect immediate perfection, so don't leave to-dos in your code."
195
+
}
196
+
}
197
+
}
198
+
}
199
+
}
200
+
```
201
+
202
+
150
203
The defaults in `eslint-plugin-jsdoc` (for tags which offer
Copy file name to clipboardExpand all lines: README.md
+204Lines changed: 204 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -197,6 +197,59 @@ 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`.
201
+
202
+
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`.
203
+
204
+
```json
205
+
{
206
+
"rules": {},
207
+
"settings": {
208
+
"jsdoc": {
209
+
"tagNamePreference": {
210
+
"augments": {
211
+
"message": "@extends is to be used over @augments as it is more evocative of classes than @augments",
212
+
"replacement": "extends"
213
+
}
214
+
}
215
+
}
216
+
}
217
+
}
218
+
```
219
+
220
+
If one wishes to reject a normally valid tag, e.g., `@todo`, one may set the tag to `false`:
221
+
222
+
```json
223
+
{
224
+
"rules": {},
225
+
"settings": {
226
+
"jsdoc": {
227
+
"tagNamePreference": {
228
+
"todo": false
229
+
}
230
+
}
231
+
}
232
+
}
233
+
```
234
+
235
+
Or one may set the targeted tag to an object with a custom `message`, but without a `replacement` property:
236
+
237
+
```json
238
+
{
239
+
"rules": {},
240
+
"settings": {
241
+
"jsdoc": {
242
+
"tagNamePreference": {
243
+
"todo": {
244
+
"message": "We expect immediate perfection, so don't leave to-dos in your code."
245
+
}
246
+
}
247
+
}
248
+
}
249
+
}
250
+
```
251
+
252
+
200
253
The defaults in `eslint-plugin-jsdoc` (for tags which offer
201
254
aliases) are as follows:
202
255
@@ -956,6 +1009,15 @@ export class SomeClass {
956
1009
constructor(privateproperty:string) {}
957
1010
}
958
1011
// Message: Expected @param names to be "property". Got "prop".
0 commit comments