Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/rules/no-undefined-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -943,5 +943,33 @@ export class Code {
/** @type {AGlobal.AnotherMethod} */
static #test5
}

import jsdoc from "eslint-plugin-jsdoc";

/**
* @import { Linter } from "eslint"
*/

/**
* @type {Linter.Config}
*/
export default [
{
plugins: { jsdoc },
rules: {
"jsdoc/no-undefined-types": "error"
}
}
];

/**
* @typedef {object} Abc
* @property {string} def Some string
*/

/**
* @type {Abc['def']}
*/
export const a = 'someString';
````

2 changes: 2 additions & 0 deletions src/rules/noUndefinedTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ export default iterateJsdoc(({
// Avoid appending for imports and globals since we don't want to
// check their properties which may or may not exist
!imports.includes(val) && !globals.includes(val) &&
!importTags.includes(val) &&
!typedefDeclarations.includes(val) &&
currNode && 'right' in currNode &&
currNode.right?.type === 'JsdocTypeProperty') {
val = val + '.' + currNode.right.value;
Expand Down
35 changes: 35 additions & 0 deletions test/rules/assertions/noUndefinedTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -1657,5 +1657,40 @@ export default /** @type {import('../index.js').TestCases} */ ({
parser: typescriptEslintParser,
},
},
{
code: `
import jsdoc from "eslint-plugin-jsdoc";

/**
* @import { Linter } from "eslint"
*/

/**
* @type {Linter.Config}
*/
export default [
{
plugins: { jsdoc },
rules: {
"jsdoc/no-undefined-types": "error"
}
}
];
`,
},
{
code: `
/**
* @typedef {object} Abc
* @property {string} def Some string
*/

/**
* @type {Abc['def']}
*/
export const a = 'someString';

`,
},
],
});
Loading