File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -807,6 +807,15 @@ function quux(foo) {
807807
808808quux (0 );
809809
810+ function quux() {
811+ const foo = 1 ;
812+ /** {@link foo } */
813+ const bar = foo ;
814+ console .log (bar );
815+ }
816+
817+ quux ();
818+
810819/**
811820 * @import BadImportIgnoredByThisRule
812821 */
Original file line number Diff line number Diff line change @@ -222,6 +222,19 @@ export default iterateJsdoc(({
222222 // Program scope inside
223223 const cjsOrESMScope = globalScope . childScopes [ 0 ] ?. block ?. type === 'Program' ;
224224
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+
225238 const allDefinedTypes = new Set ( globalScope . variables . map ( ( {
226239 name,
227240 } ) => {
@@ -247,6 +260,7 @@ export default iterateJsdoc(({
247260 . concat ( importTags )
248261 . concat ( definedTypes )
249262 . concat ( /** @type {string[] } */ ( definedPreferredTypes ) )
263+ . concat ( ...getValidRuntimeIdentifiers ( node && sourceCode . getScope ( node ) ) )
250264 . concat (
251265 settings . mode === 'jsdoc' ?
252266 [ ] :
Original file line number Diff line number Diff line change @@ -1482,6 +1482,18 @@ export default /** @type {import('../index.js').TestCases} */ ({
14821482 'no-unused-vars' : 'error' ,
14831483 } ,
14841484 } ,
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+ } ,
14851497 {
14861498 code : `
14871499 /**
You can’t perform that action at this time.
0 commit comments