Skip to content

Commit

Permalink
fix(no-undefined-types): prevent linting of "type" within @import; f…
Browse files Browse the repository at this point in the history
…ixes #1242
  • Loading branch information
brettz9 committed Jun 22, 2024
1 parent 8603579 commit 0bea154
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/rules/no-undefined-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -776,5 +776,9 @@ function quux(foo) {
}

quux(0);

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

2 changes: 1 addition & 1 deletion src/rules/noUndefinedTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export default iterateJsdoc(({
const typeTags = utils.filterTags(({
tag,
}) => {
return utils.tagMightHaveTypePosition(tag) && (tag !== 'suppress' || settings.mode !== 'closure');
return tag !== 'import' && utils.tagMightHaveTypePosition(tag) && (tag !== 'suppress' || settings.mode !== 'closure');
}).map(tagToParsedType('type'));

const namepathReferencingTags = utils.filterTags(({
Expand Down
1 change: 1 addition & 0 deletions src/tagNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ const typeScriptTags = {
...jsdocTags,

// https://github.com/microsoft/TypeScript/issues/22160
// https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/#the-jsdoc-import-tag
import: [],

// https://www.typescriptlang.org/tsconfig/#stripInternal
Expand Down
7 changes: 7 additions & 0 deletions test/rules/assertions/noUndefinedTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -1436,5 +1436,12 @@ export default {
'no-unused-vars': 'error',
},
},
{
code: `
/**
* @import { Linter } from "eslint"
*/
`,
},
],
};

0 comments on commit 0bea154

Please sign in to comment.