Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: gajus/eslint-plugin-jsdoc
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v50.6.6
Choose a base ref
...
head repository: gajus/eslint-plugin-jsdoc
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v50.6.7
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Mar 17, 2025

  1. Copy the full SHA
    1c38930 View commit details
  2. use standard loops and array.push for performance

    realised that performance matter a lot for eslint, and functional map, recursive calls and converting forth and back between set and creating new arrays would not be very performant, so changed implementation to old style loops and working with a single SET
    sebastian-fredriksson-bernholtz authored and brettz9 committed Mar 17, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    bf0acfe View commit details
Showing with 37 additions and 0 deletions.
  1. +9 −0 docs/rules/no-undefined-types.md
  2. +16 −0 src/rules/noUndefinedTypes.js
  3. +12 −0 test/rules/assertions/noUndefinedTypes.js
9 changes: 9 additions & 0 deletions docs/rules/no-undefined-types.md
Original file line number Diff line number Diff line change
@@ -807,6 +807,15 @@ function quux(foo) {

quux(0);

function quux() {
const foo = 1;
/** {@link foo} */
const bar = foo;
console.log(bar);
}

quux();

/**
* @import BadImportIgnoredByThisRule
*/
16 changes: 16 additions & 0 deletions src/rules/noUndefinedTypes.js
Original file line number Diff line number Diff line change
@@ -222,6 +222,21 @@ export default iterateJsdoc(({
// Program scope inside
const cjsOrESMScope = globalScope.childScopes[0]?.block?.type === 'Program';

/**
* @param {import("eslint").Scope.Scope | null} scope
* @returns {Set<string>}
*/
const getValidRuntimeIdentifiers = (scope) => {
const result = new Set()
while (scope) {
for (const {name} of scope.variables) {
result.add(name)
}
scope = scope.upper
}
return result
};

const allDefinedTypes = new Set(globalScope.variables.map(({
name,
}) => {
@@ -247,6 +262,7 @@ export default iterateJsdoc(({
.concat(importTags)
.concat(definedTypes)
.concat(/** @type {string[]} */ (definedPreferredTypes))
.concat(...getValidRuntimeIdentifiers(node && sourceCode.getScope(node)))
.concat(
settings.mode === 'jsdoc' ?
[] :
12 changes: 12 additions & 0 deletions test/rules/assertions/noUndefinedTypes.js
Original file line number Diff line number Diff line change
@@ -1482,6 +1482,18 @@ export default /** @type {import('../index.js').TestCases} */ ({
'no-unused-vars': 'error',
},
},
{
code: `
function quux() {
const foo = 1;
/** {@link foo} */
const bar = foo;
console.log(bar);
}
quux();
`,
},
{
code: `
/**