File tree Expand file tree Collapse file tree 3 files changed +115
-3
lines changed Expand file tree Collapse file tree 3 files changed +115
-3
lines changed Original file line number Diff line number Diff line change @@ -5013,6 +5013,27 @@ function Test() {
5013
5013
}
5014
5014
// Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
5015
5015
// Message: Invalid JSDoc tag (preference). Replace "constructor" JSDoc tag with "class".
5016
+
5017
+ /** @typedef {Object} MyObject
5018
+ * @property {string} id - my id
5019
+ */
5020
+ // "jsdoc/check-tag-names": ["error"|"warn", {"typed":true}]
5021
+ // Message: '@typedef' is redundant when using a type system.
5022
+
5023
+ /**
5024
+ * @property {string} id - my id
5025
+ */
5026
+ // "jsdoc/check-tag-names": ["error"|"warn", {"typed":true}]
5027
+ // Message: '@property' is redundant when using a type system.
5028
+
5029
+ /** @typedef {Object} MyObject */
5030
+ // "jsdoc/check-tag-names": ["error"|"warn", {"typed":true}]
5031
+ // Message: '@typedef' is redundant when using a type system.
5032
+
5033
+ /** @typedef {Object} MyObject
5034
+ */
5035
+ // "jsdoc/check-tag-names": ["error"|"warn", {"typed":true}]
5036
+ // Message: '@typedef' is redundant when using a type system.
5016
5037
````
5017
5038
5018
5039
The following patterns are not considered problems:
Original file line number Diff line number Diff line change @@ -407,11 +407,15 @@ const getUtils = (
407
407
} = jsdoc . source [ spliceIdx ] . tokens ;
408
408
409
409
/* istanbul ignore if -- Currently want to clear entirely if removing tags */
410
- if ( ! removeEmptyBlock && ( end || delimiter === '/**' ) ) {
410
+ if (
411
+ spliceIdx === 0 && jsdoc . tags . length >= 2 ||
412
+ ! removeEmptyBlock && ( end || delimiter === '/**' )
413
+ ) {
411
414
const {
412
415
tokens,
413
416
} = jsdoc . source [ spliceIdx ] ;
414
417
for ( const item of [
418
+ 'postDelimiter' ,
415
419
'tag' ,
416
420
'postTag' ,
417
421
'type' ,
@@ -423,10 +427,10 @@ const getUtils = (
423
427
tokens [ item ] = '' ;
424
428
}
425
429
} else {
426
- jsdoc . source . splice ( spliceIdx , spliceCount - tagSourceOffset ) ;
430
+ jsdoc . source . splice ( spliceIdx , spliceCount - tagSourceOffset + ( spliceIdx ? 0 : jsdoc . source . length ) ) ;
431
+ tagSource . splice ( tagIdx + tagSourceOffset , spliceCount - tagSourceOffset + ( spliceIdx ? 0 : jsdoc . source . length ) ) ;
427
432
}
428
433
429
- tagSource . splice ( tagIdx + tagSourceOffset , spliceCount - tagSourceOffset ) ;
430
434
lastIndex = sourceIndex ;
431
435
432
436
return true ;
Original file line number Diff line number Diff line change @@ -925,6 +925,93 @@ export default {
925
925
} ,
926
926
} ,
927
927
} ,
928
+ {
929
+ code : `
930
+ /** @typedef {Object} MyObject
931
+ * @property {string} id - my id
932
+ */
933
+ ` ,
934
+ errors : [
935
+ {
936
+ line : 2 ,
937
+ message : '\'@typedef\' is redundant when using a type system.' ,
938
+ } ,
939
+ {
940
+ line : 3 ,
941
+ message : '\'@property\' is redundant when using a type system.' ,
942
+ } ,
943
+ ] ,
944
+ options : [
945
+ {
946
+ typed : true ,
947
+ } ,
948
+ ] ,
949
+ output : `
950
+ /**
951
+ * @property {string} id - my id
952
+ */
953
+ ` ,
954
+ } ,
955
+ {
956
+ code : `
957
+ /**
958
+ * @property {string} id - my id
959
+ */
960
+ ` ,
961
+ errors : [
962
+ {
963
+ line : 3 ,
964
+ message : '\'@property\' is redundant when using a type system.' ,
965
+ } ,
966
+ ] ,
967
+ options : [
968
+ {
969
+ typed : true ,
970
+ } ,
971
+ ] ,
972
+ output : `
973
+ /**
974
+ * id - my id
975
+ */
976
+ ` ,
977
+ } ,
978
+ {
979
+ code : `
980
+ /** @typedef {Object} MyObject */
981
+ ` ,
982
+ errors : [
983
+ {
984
+ line : 2 ,
985
+ message : '\'@typedef\' is redundant when using a type system.' ,
986
+ } ,
987
+ ] ,
988
+ options : [
989
+ {
990
+ typed : true ,
991
+ } ,
992
+ ] ,
993
+ output : `
994
+ ` ,
995
+ } ,
996
+ {
997
+ code : `
998
+ /** @typedef {Object} MyObject
999
+ */
1000
+ ` ,
1001
+ errors : [
1002
+ {
1003
+ line : 2 ,
1004
+ message : '\'@typedef\' is redundant when using a type system.' ,
1005
+ } ,
1006
+ ] ,
1007
+ options : [
1008
+ {
1009
+ typed : true ,
1010
+ } ,
1011
+ ] ,
1012
+ output : `
1013
+ ` ,
1014
+ } ,
928
1015
] ,
929
1016
valid : [
930
1017
{
You can’t perform that action at this time.
0 commit comments