File tree Expand file tree Collapse file tree 3 files changed +112
-0
lines changed Expand file tree Collapse file tree 3 files changed +112
-0
lines changed Original file line number Diff line number Diff line change @@ -865,5 +865,44 @@ quux();
865
865
/**
866
866
* @type {Linters}
867
867
*/
868
+
869
+ class Filler {
870
+ static methodOne () {
871
+ return ' Method One' ;
872
+ }
873
+
874
+ nonStaticMethodTwo (param ) {
875
+ return ` Method Two received: ${param } ` ;
876
+ }
877
+
878
+ /**
879
+ * {@link methodOne } shouldn't report eslint error
880
+ * {@link nonStaticMethodTwo } also shouldn't report eslint error
881
+ * @returns {number} A number representing the answer to everything.
882
+ */
883
+ static methodThree () {
884
+ return 42 ;
885
+ }
886
+
887
+ /**
888
+ * {@link Filler.methodOne } doesn't report eslint error
889
+ * {@link Filler.nonStaticMethodTwo } also doesn't report eslint error
890
+ * @returns {string} A string indicating the method's purpose.
891
+ */
892
+ methodFour() {
893
+ return ' Method Four' ;
894
+ }
895
+ }
896
+
897
+ class Foo {
898
+ foo = " foo" ;
899
+ /**
900
+ * Something related to {@link foo }
901
+ * @returns {string} Something awesome
902
+ */
903
+ bar() {
904
+ return " bar" ;
905
+ }
906
+ }
868
907
````
869
908
Original file line number Diff line number Diff line change @@ -267,6 +267,31 @@ export default iterateJsdoc(({
267
267
. concat ( importTags )
268
268
. concat ( definedTypes )
269
269
. concat ( /** @type {string[] } */ ( definedPreferredTypes ) )
270
+ . concat ( ( ( ) => {
271
+ // Other methods are not in scope, but we need them, and we grab them here
272
+ if ( node ?. type === 'MethodDefinition' ) {
273
+ return /** @type {import('estree').ClassBody } */ ( node . parent ) . body . map ( ( methodOrProp ) => {
274
+ if ( methodOrProp . type === 'MethodDefinition' ) {
275
+ // eslint-disable-next-line unicorn/no-lonely-if -- Pattern
276
+ if ( methodOrProp . key . type === 'Identifier' ) {
277
+ return methodOrProp . key . name ;
278
+ }
279
+ }
280
+
281
+ if ( methodOrProp . type === 'PropertyDefinition' ) {
282
+ // eslint-disable-next-line unicorn/no-lonely-if -- Pattern
283
+ if ( methodOrProp . key . type === 'Identifier' ) {
284
+ return methodOrProp . key . name ;
285
+ }
286
+ }
287
+ /* c8 ignore next 2 -- Not yet built */
288
+
289
+ return '' ;
290
+ } ) . filter ( Boolean ) ;
291
+ }
292
+
293
+ return [ ] ;
294
+ } ) ( ) )
270
295
. concat ( ...getValidRuntimeIdentifiers ( node && (
271
296
( sourceCode . getScope &&
272
297
/* c8 ignore next 2 */
Original file line number Diff line number Diff line change @@ -1549,5 +1549,53 @@ export default /** @type {import('../index.js').TestCases} */ ({
1549
1549
*/
1550
1550
` ,
1551
1551
} ,
1552
+ {
1553
+ code : `
1554
+ class Filler {
1555
+ static methodOne () {
1556
+ return 'Method One';
1557
+ }
1558
+
1559
+ nonStaticMethodTwo (param) {
1560
+ return \`Method Two received: $\{param}\`;
1561
+ }
1562
+
1563
+ /**
1564
+ * {@link methodOne} shouldn't report eslint error
1565
+ * {@link nonStaticMethodTwo} also shouldn't report eslint error
1566
+ * @returns {number} A number representing the answer to everything.
1567
+ */
1568
+ static methodThree () {
1569
+ return 42;
1570
+ }
1571
+
1572
+ /**
1573
+ * {@link Filler.methodOne} doesn't report eslint error
1574
+ * {@link Filler.nonStaticMethodTwo} also doesn't report eslint error
1575
+ * @returns {string} A string indicating the method's purpose.
1576
+ */
1577
+ methodFour() {
1578
+ return 'Method Four';
1579
+ }
1580
+ }
1581
+ ` ,
1582
+ } ,
1583
+ {
1584
+ code : `
1585
+ class Foo {
1586
+ foo = "foo";
1587
+ /**
1588
+ * Something related to {@link foo}
1589
+ * @returns {string} Something awesome
1590
+ */
1591
+ bar() {
1592
+ return "bar";
1593
+ }
1594
+ }
1595
+ ` ,
1596
+ languageOptions : {
1597
+ ecmaVersion : 2_022 ,
1598
+ } ,
1599
+ } ,
1552
1600
] ,
1553
1601
} ) ;
You can’t perform that action at this time.
0 commit comments