Skip to content

Commit ee2bae3

Browse files
committed
fix(check-tag-names, empty-tags, sort-tags, valid-types): support new TypeScript overload and satisfies; fixes #1045
1 parent 95f126d commit ee2bae3

File tree

6 files changed

+64
-11
lines changed

6 files changed

+64
-11
lines changed

README.md

Lines changed: 19 additions & 9 deletions
Large diffs are not rendered by default.

src/defaultTagOrder.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const defaultTagOrder = [
5555

5656
// TypeScript
5757
'internal',
58+
'overload',
5859

5960
'const',
6061
'constant',
@@ -101,6 +102,9 @@ const defaultTagOrder = [
101102
'listens',
102103
'this',
103104

105+
// TypeScript
106+
'satisfies',
107+
104108
// Access
105109
'static',
106110
'private',

src/getDefaultTagStructureForMode.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,15 @@ const getDefaultTagStructureForMode = (mode) => {
756756
]),
757757
],
758758

759+
[
760+
'satisfies', new Map([
761+
// Shows curly brackets in the doc signature and examples
762+
[
763+
'typeRequired', true,
764+
],
765+
]),
766+
],
767+
759768
[
760769
'see', new Map([
761770
// Signature allows for "namepath" or text, so user must configure to

src/rules/emptyTags.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const defaultEmptyTags = new Set([
1010

1111
// jsdoc doesn't use but allow for TypeScript
1212
'internal',
13+
'overload',
1314
]);
1415

1516
const emptyIfNotClosure = new Set([

src/tagNames.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ const typeScriptTags = {
124124
// https://www.typescriptlang.org/tsconfig/#stripInternal
125125
internal: [],
126126

127+
// https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#overload-support-in-jsdoc
128+
overload: [],
129+
130+
// https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#satisfies-support-in-jsdoc
131+
satisfies: [],
132+
127133
// `@template` is also in TypeScript per:
128134
// https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#supported-jsdoc
129135
template: [],
@@ -150,6 +156,8 @@ const {
150156
/* eslint-disable no-unused-vars */
151157
inheritdoc,
152158
internal,
159+
overload,
160+
satisfies,
153161

154162
// Will be inverted to prefer `return`
155163
returns,

test/rules/assertions/checkTagNames.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,9 +842,17 @@ export default {
842842
code: `${ALL_TYPESCRIPT_TAGS_COMMENT}\nfunction quux (foo) {}`,
843843
errors: [
844844
{
845-
line: lineCount(ALL_TYPESCRIPT_TAGS_COMMENT) - 1,
845+
line: lineCount(ALL_TYPESCRIPT_TAGS_COMMENT) - 3,
846846
message: 'Invalid JSDoc tag name "internal".',
847847
},
848+
{
849+
line: lineCount(ALL_TYPESCRIPT_TAGS_COMMENT) - 2,
850+
message: 'Invalid JSDoc tag name "overload".',
851+
},
852+
{
853+
line: lineCount(ALL_TYPESCRIPT_TAGS_COMMENT) - 1,
854+
message: 'Invalid JSDoc tag name "satisfies".',
855+
},
848856
{
849857
line: lineCount(ALL_TYPESCRIPT_TAGS_COMMENT),
850858
message: 'Invalid JSDoc tag name "template".',
@@ -1289,7 +1297,7 @@ export default {
12891297
* Converts the images specified by the indices to base64 synchronously.
12901298
* @function WebTwain#ConvertToBase64
12911299
* @returns {Base64Result}
1292-
1300+
12931301
ConvertToBase64(): Base64Result;
12941302
*/
12951303
@@ -1303,5 +1311,18 @@ export default {
13031311
`,
13041312
parser: require.resolve('@typescript-eslint/parser'),
13051313
},
1314+
{
1315+
code: `
1316+
/**
1317+
* @overload
1318+
* @satisfies
1319+
*/
1320+
`,
1321+
settings: {
1322+
jsdoc: {
1323+
mode: 'typescript',
1324+
},
1325+
},
1326+
},
13061327
],
13071328
};

0 commit comments

Comments
 (0)