File tree 4 files changed +47
-1
lines changed
4 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -4500,6 +4500,15 @@ function quux (foo) {}
4500
4500
/** @jsxImportSource preact */
4501
4501
/** @jsxRuntime automatic */
4502
4502
// Message: Invalid JSDoc tag name "jsx".
4503
+
4504
+ /**
4505
+ * @constructor
4506
+ */
4507
+ function Test() {
4508
+ this.works = false;
4509
+ }
4510
+ // Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
4511
+ // Message: Invalid JSDoc tag (preference). Replace "constructor" JSDoc tag with "class".
4503
4512
````
4504
4513
4505
4514
The following patterns are not considered problems:
Original file line number Diff line number Diff line change @@ -396,7 +396,7 @@ const getPreferredTagName = (
396
396
} ) ,
397
397
) ;
398
398
399
- if ( name in tagPreferenceFixed ) {
399
+ if ( Object . prototype . hasOwnProperty . call ( tagPreferenceFixed , name ) ) {
400
400
return tagPreferenceFixed [ name ] ;
401
401
}
402
402
Original file line number Diff line number Diff line change @@ -10,6 +10,12 @@ describe('jsdocUtils', () => {
10
10
it ( 'returns the primary tag name' , ( ) => {
11
11
expect ( jsdocUtils . getPreferredTagName ( { } , 'jsdoc' , 'return' ) ) . to . equal ( 'returns' ) ;
12
12
} ) ;
13
+ it ( 'works with the constructor tag' , ( ) => {
14
+ expect ( jsdocUtils . getPreferredTagName ( { } , 'jsdoc' , 'constructor' ) ) . to . equal ( 'class' ) ;
15
+ } ) ;
16
+ } ) ;
17
+ it ( 'works with tags that clash with prototype properties' , ( ) => {
18
+ expect ( jsdocUtils . getPreferredTagName ( { } , 'jsdoc' , 'toString' ) ) . to . equal ( 'toString' ) ;
13
19
} ) ;
14
20
it ( 'returns the primary tag name' , ( ) => {
15
21
expect ( jsdocUtils . getPreferredTagName ( { } , 'jsdoc' , 'returns' ) ) . to . equal ( 'returns' ) ;
Original file line number Diff line number Diff line change @@ -641,6 +641,37 @@ export default {
641
641
} ,
642
642
] ,
643
643
} ,
644
+ {
645
+ code : `
646
+ /**
647
+ * @constructor
648
+ */
649
+ function Test() {
650
+ this.works = false;
651
+ }
652
+ ` ,
653
+ errors : [
654
+ {
655
+ line : 3 ,
656
+ message : 'Invalid JSDoc tag (preference). Replace "constructor" JSDoc tag with "class".' ,
657
+ } ,
658
+ ] ,
659
+ output : `
660
+ /**
661
+ * @class
662
+ */
663
+ function Test() {
664
+ this.works = false;
665
+ }
666
+ ` ,
667
+ settings : {
668
+ jsdoc : {
669
+ tagNamePreference : {
670
+ returns : 'return' ,
671
+ } ,
672
+ } ,
673
+ } ,
674
+ } ,
644
675
] ,
645
676
valid : [
646
677
{
You can’t perform that action at this time.
0 commit comments