File tree 3 files changed +35
-0
lines changed
3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -807,6 +807,15 @@ function quux(foo) {
807
807
808
808
quux (0 );
809
809
810
+ function quux() {
811
+ const foo = 1 ;
812
+ /** {@link foo } */
813
+ const bar = foo ;
814
+ console .log (bar );
815
+ }
816
+
817
+ quux ();
818
+
810
819
/**
811
820
* @import BadImportIgnoredByThisRule
812
821
*/
Original file line number Diff line number Diff line change @@ -222,6 +222,19 @@ export default iterateJsdoc(({
222
222
// Program scope inside
223
223
const cjsOrESMScope = globalScope . childScopes [ 0 ] ?. block ?. type === 'Program' ;
224
224
225
+ /**
226
+ * @param {import("eslint").Scope.Scope | null } scope
227
+ * @returns {Set<string> }
228
+ */
229
+ const getValidRuntimeIdentifiers = ( scope ) => {
230
+ return scope
231
+ ? new Set ( [
232
+ ...new Set ( scope . variables . map ( ( { name } ) => name ) ) ,
233
+ ...getValidRuntimeIdentifiers ( scope . upper ) ,
234
+ ] )
235
+ : new Set ( ) ;
236
+ } ;
237
+
225
238
const allDefinedTypes = new Set ( globalScope . variables . map ( ( {
226
239
name,
227
240
} ) => {
@@ -247,6 +260,7 @@ export default iterateJsdoc(({
247
260
. concat ( importTags )
248
261
. concat ( definedTypes )
249
262
. concat ( /** @type {string[] } */ ( definedPreferredTypes ) )
263
+ . concat ( ...getValidRuntimeIdentifiers ( node && sourceCode . getScope ( node ) ) )
250
264
. concat (
251
265
settings . mode === 'jsdoc' ?
252
266
[ ] :
Original file line number Diff line number Diff line change @@ -1482,6 +1482,18 @@ export default /** @type {import('../index.js').TestCases} */ ({
1482
1482
'no-unused-vars' : 'error' ,
1483
1483
} ,
1484
1484
} ,
1485
+ {
1486
+ code : `
1487
+ function quux() {
1488
+ const foo = 1;
1489
+ /** {@link foo} */
1490
+ const bar = foo;
1491
+ console.log(bar);
1492
+ }
1493
+
1494
+ quux();
1495
+ ` ,
1496
+ } ,
1485
1497
{
1486
1498
code : `
1487
1499
/**
You can’t perform that action at this time.
0 commit comments