Skip to content

Commit 84397ff

Browse files
committed
enhancement(check-types): Allow replacement in place of preferredType for parity with supplied argument of the same name
1 parent d994fda commit 84397ff

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

.README/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ The format of the configuration is as follows:
236236
forbidding the type. The message string will have the following
237237
substrings with special meaning replaced with their corresponding
238238
value (`{{tagName}}`, `{{tagValue}}`, `{{badType}}`, and
239-
`{{preferredType}}`, noting that the latter is of no use when one is
240-
merely forbidding a type).
239+
`{{preferredType}}` (or `{{replacement}}`), noting that the latter is
240+
of no use when one is merely forbidding a type).
241241

242242
If `no-undefined-types` has the option key `preferredTypesDefined` set to
243243
`true`, the preferred types indicated in the `settings.jsdoc.preferredTypes`

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,8 @@ The format of the configuration is as follows:
289289
forbidding the type. The message string will have the following
290290
substrings with special meaning replaced with their corresponding
291291
value (`{{tagName}}`, `{{tagValue}}`, `{{badType}}`, and
292-
`{{preferredType}}`, noting that the latter is of no use when one is
293-
merely forbidding a type).
292+
`{{preferredType}}` (or `{{replacement}}`), noting that the latter is
293+
of no use when one is merely forbidding a type).
294294

295295
If `no-undefined-types` has the option key `preferredTypesDefined` set to
296296
`true`, the preferred types indicated in the `settings.jsdoc.preferredTypes`
@@ -1402,7 +1402,7 @@ function qux(foo) {
14021402
*/
14031403
function qux(foo) {
14041404
}
1405-
// Settings: {"jsdoc":{"preferredTypes":{"abc":{"message":"Messed up JSDoc @{{tagName}}{{tagValue}} type \"{{badType}}\"; prefer: \"{{preferredType}}\".","replacement":"Abc"},"string":"Str"}}}
1405+
// Settings: {"jsdoc":{"preferredTypes":{"abc":{"message":"Messed up JSDoc @{{tagName}}{{tagValue}} type \"{{badType}}\"; prefer: \"{{replacement}}\".","replacement":"Abc"},"string":"Str"}}}
14061406
// Message: Messed up JSDoc @param "foo" type "abc"; prefer: "Abc".
14071407

14081408
/**

src/rules/checkTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export default iterateJsdoc(({
109109
message ? {
110110
badType,
111111
preferredType,
112+
replacement: preferredType,
112113
tagName,
113114
tagValue
114115
} : null

test/rules/assertions/checkTypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export default {
191191
jsdoc: {
192192
preferredTypes: {
193193
abc: {
194-
message: 'Messed up JSDoc @{{tagName}}{{tagValue}} type "{{badType}}"; prefer: "{{preferredType}}".',
194+
message: 'Messed up JSDoc @{{tagName}}{{tagValue}} type "{{badType}}"; prefer: "{{replacement}}".',
195195
replacement: 'Abc'
196196
},
197197
string: 'Str'

0 commit comments

Comments
 (0)