Skip to content

Commit 854c8dd

Browse files
authored
fix(check-types): remove template substitution variables, badType, preferredType, and replacement (#310)
BREAKING CHANGE: In place of the substitution variables, one must now hard-code the type in the message
1 parent 2072735 commit 854c8dd

File tree

4 files changed

+15
-22
lines changed

4 files changed

+15
-22
lines changed

.README/README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -309,11 +309,9 @@ but restricted to `@param`. These settings are now deprecated.
309309
when encountering the discouraged type and, if a type is to be preferred
310310
in its place, the key `replacement` to indicate the type that should be
311311
used in its place (and which `fix` mode can replace) or `false` if
312-
forbidding the type. The message string will have the following
313-
substrings with special meaning replaced with their corresponding
314-
value (`{{tagName}}`, `{{tagValue}}`, `{{badType}}`, and
315-
`{{preferredType}}` (or `{{replacement}}`), noting that the latter is
316-
of no use when one is merely forbidding a type).
312+
forbidding the type. The message string will have the substrings with
313+
special meaning, `{{tagName}}` and `{{tagValue}}`, replaced with their
314+
corresponding value.
317315

318316
Note that the preferred types indicated as targets in `settings.jsdoc.preferredTypes`
319317
map will be assumed to be defined by `no-undefined-types`.

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,9 @@ but restricted to `@param`. These settings are now deprecated.
360360
when encountering the discouraged type and, if a type is to be preferred
361361
in its place, the key `replacement` to indicate the type that should be
362362
used in its place (and which `fix` mode can replace) or `false` if
363-
forbidding the type. The message string will have the following
364-
substrings with special meaning replaced with their corresponding
365-
value (`{{tagName}}`, `{{tagValue}}`, `{{badType}}`, and
366-
`{{preferredType}}` (or `{{replacement}}`), noting that the latter is
367-
of no use when one is merely forbidding a type).
363+
forbidding the type. The message string will have the substrings with
364+
special meaning, `{{tagName}}` and `{{tagValue}}`, replaced with their
365+
corresponding value.
368366

369367
Note that the preferred types indicated as targets in `settings.jsdoc.preferredTypes`
370368
map will be assumed to be defined by `no-undefined-types`.
@@ -1693,7 +1691,7 @@ function qux(foo) {
16931691
*/
16941692
function qux(foo) {
16951693
}
1696-
// Settings: {"jsdoc":{"preferredTypes":{"abc":{"message":"Messed up JSDoc @{{tagName}}{{tagValue}} type \"{{badType}}\"; prefer: \"{{replacement}}\".","replacement":"Abc"},"string":"Str"}}}
1694+
// Settings: {"jsdoc":{"preferredTypes":{"abc":{"message":"Messed up JSDoc @{{tagName}}{{tagValue}} type \"abc\"; prefer: \"Abc\".","replacement":"Abc"},"string":"Str"}}}
16971695
// Message: Messed up JSDoc @param "foo" type "abc"; prefer: "Abc".
16981696

16991697
/**
@@ -1703,23 +1701,23 @@ function qux(foo) {
17031701
*/
17041702
function qux(foo, bar, baz) {
17051703
}
1706-
// Settings: {"jsdoc":{"preferredTypes":{"abc":{"message":"Messed up JSDoc @{{tagName}}{{tagValue}} type \"{{badType}}\"; prefer: \"{{preferredType}}\".","replacement":"Abc"},"cde":{"message":"More messed up JSDoc @{{tagName}}{{tagValue}} type \"{{badType}}\"; prefer: \"{{preferredType}}\".","replacement":"Cde"},"object":"Object"}}}
1704+
// Settings: {"jsdoc":{"preferredTypes":{"abc":{"message":"Messed up JSDoc @{{tagName}}{{tagValue}} type \"abc\"; prefer: \"Abc\".","replacement":"Abc"},"cde":{"message":"More messed up JSDoc @{{tagName}}{{tagValue}} type \"cde\"; prefer: \"Cde\".","replacement":"Cde"},"object":"Object"}}}
17071705
// Message: Messed up JSDoc @param "foo" type "abc"; prefer: "Abc".
17081706

17091707
/**
17101708
* @param {abc} foo
17111709
*/
17121710
function qux(foo) {
17131711
}
1714-
// Settings: {"jsdoc":{"preferredTypes":{"abc":{"message":"Messed up JSDoc @{{tagName}}{{tagValue}} type \"{{badType}}\".","replacement":false},"string":"Str"}}}
1712+
// Settings: {"jsdoc":{"preferredTypes":{"abc":{"message":"Messed up JSDoc @{{tagName}}{{tagValue}} type \"abc\".","replacement":false},"string":"Str"}}}
17151713
// Message: Messed up JSDoc @param "foo" type "abc".
17161714

17171715
/**
17181716
* @param {abc} foo
17191717
*/
17201718
function qux(foo) {
17211719
}
1722-
// Settings: {"jsdoc":{"preferredTypes":{"abc":{"message":"Messed up JSDoc @{{tagName}}{{tagValue}} type \"{{badType}}\"."},"string":"Str"}}}
1720+
// Settings: {"jsdoc":{"preferredTypes":{"abc":{"message":"Messed up JSDoc @{{tagName}}{{tagValue}} type \"abc\"."},"string":"Str"}}}
17231721
// Message: Messed up JSDoc @param "foo" type "abc".
17241722

17251723
/**

src/rules/checkTypes.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,6 @@ export default iterateJsdoc(({
206206
preferredType ? fix : null,
207207
jsdocTag,
208208
message ? {
209-
badType,
210-
preferredType,
211-
replacement: preferredType,
212209
tagName,
213210
tagValue
214211
} : null

test/rules/assertions/checkTypes.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ export default {
262262
jsdoc: {
263263
preferredTypes: {
264264
abc: {
265-
message: 'Messed up JSDoc @{{tagName}}{{tagValue}} type "{{badType}}"; prefer: "{{replacement}}".',
265+
message: 'Messed up JSDoc @{{tagName}}{{tagValue}} type "abc"; prefer: "Abc".',
266266
replacement: 'Abc'
267267
},
268268
string: 'Str'
@@ -298,11 +298,11 @@ export default {
298298
jsdoc: {
299299
preferredTypes: {
300300
abc: {
301-
message: 'Messed up JSDoc @{{tagName}}{{tagValue}} type "{{badType}}"; prefer: "{{preferredType}}".',
301+
message: 'Messed up JSDoc @{{tagName}}{{tagValue}} type "abc"; prefer: "Abc".',
302302
replacement: 'Abc'
303303
},
304304
cde: {
305-
message: 'More messed up JSDoc @{{tagName}}{{tagValue}} type "{{badType}}"; prefer: "{{preferredType}}".',
305+
message: 'More messed up JSDoc @{{tagName}}{{tagValue}} type "cde"; prefer: "Cde".',
306306
replacement: 'Cde'
307307
},
308308
object: 'Object'
@@ -328,7 +328,7 @@ export default {
328328
jsdoc: {
329329
preferredTypes: {
330330
abc: {
331-
message: 'Messed up JSDoc @{{tagName}}{{tagValue}} type "{{badType}}".',
331+
message: 'Messed up JSDoc @{{tagName}}{{tagValue}} type "abc".',
332332
replacement: false
333333
},
334334
string: 'Str'
@@ -354,7 +354,7 @@ export default {
354354
jsdoc: {
355355
preferredTypes: {
356356
abc: {
357-
message: 'Messed up JSDoc @{{tagName}}{{tagValue}} type "{{badType}}".'
357+
message: 'Messed up JSDoc @{{tagName}}{{tagValue}} type "abc".'
358358
},
359359
string: 'Str'
360360
}

0 commit comments

Comments
 (0)