Skip to content

Commit e9ff4c7

Browse files
authored
fix(no-undefined-types): also allow globals defined on languageOptions (#1415)
1 parent 08f7834 commit e9ff4c7

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

docs/rules/no-undefined-types.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,9 @@ export class Code {
939939

940940
/** @type {AnotherGlobal.AnotherMethod} */
941941
static #test4
942+
943+
/** @type {AGlobal.AnotherMethod} */
944+
static #test5
942945
}
943946
````
944947

src/rules/noUndefinedTypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export default iterateJsdoc(({
126126
return (/^\s*globals/u).test(comment.value);
127127
}).flatMap((commentNode) => {
128128
return commentNode.value.replace(/^\s*globals/u, '').trim().split(/,\s*/u);
129-
});
129+
}).concat(Object.keys(context.languageOptions.globals ?? []));
130130

131131
const typedefDeclarations = comments
132132
.flatMap((doc) => {

test/rules/assertions/noUndefinedTypes.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,9 +1645,15 @@ export default /** @type {import('../index.js').TestCases} */ ({
16451645
16461646
/** @type {AnotherGlobal.AnotherMethod} */
16471647
static #test4
1648+
1649+
/** @type {AGlobal.AnotherMethod} */
1650+
static #test5
16481651
}
16491652
`,
16501653
languageOptions: {
1654+
globals: {
1655+
AGlobal: 'readonly',
1656+
},
16511657
parser: typescriptEslintParser,
16521658
},
16531659
},

0 commit comments

Comments
 (0)