Skip to content

Commit 0bea154

Browse files
committed
fix(no-undefined-types): prevent linting of "type" within @import; fixes #1242
1 parent 8603579 commit 0bea154

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

docs/rules/no-undefined-types.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,5 +776,9 @@ function quux(foo) {
776776
}
777777

778778
quux(0);
779+
780+
/**
781+
* @import { Linter } from "eslint"
782+
*/
779783
````
780784

src/rules/noUndefinedTypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ export default iterateJsdoc(({
245245
const typeTags = utils.filterTags(({
246246
tag,
247247
}) => {
248-
return utils.tagMightHaveTypePosition(tag) && (tag !== 'suppress' || settings.mode !== 'closure');
248+
return tag !== 'import' && utils.tagMightHaveTypePosition(tag) && (tag !== 'suppress' || settings.mode !== 'closure');
249249
}).map(tagToParsedType('type'));
250250

251251
const namepathReferencingTags = utils.filterTags(({

src/tagNames.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ const typeScriptTags = {
137137
...jsdocTags,
138138

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

142143
// https://www.typescriptlang.org/tsconfig/#stripInternal

test/rules/assertions/noUndefinedTypes.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,5 +1436,12 @@ export default {
14361436
'no-unused-vars': 'error',
14371437
},
14381438
},
1439+
{
1440+
code: `
1441+
/**
1442+
* @import { Linter } from "eslint"
1443+
*/
1444+
`,
1445+
},
14391446
],
14401447
};

0 commit comments

Comments
 (0)