Skip to content

Commit

Permalink
fix(check-tag-names, empty-tags, sort-tags, valid-types): sup…
Browse files Browse the repository at this point in the history
…port new TypeScript `overload` and `satisfies`; fixes #1045
  • Loading branch information
brettz9 committed Apr 24, 2023
1 parent 95f126d commit ee2bae3
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 11 deletions.
28 changes: 19 additions & 9 deletions README.md

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/defaultTagOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const defaultTagOrder = [

// TypeScript
'internal',
'overload',

'const',
'constant',
Expand Down Expand Up @@ -101,6 +102,9 @@ const defaultTagOrder = [
'listens',
'this',

// TypeScript
'satisfies',

// Access
'static',
'private',
Expand Down
9 changes: 9 additions & 0 deletions src/getDefaultTagStructureForMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,15 @@ const getDefaultTagStructureForMode = (mode) => {
]),
],

[
'satisfies', new Map([
// Shows curly brackets in the doc signature and examples
[
'typeRequired', true,
],
]),
],

[
'see', new Map([
// Signature allows for "namepath" or text, so user must configure to
Expand Down
1 change: 1 addition & 0 deletions src/rules/emptyTags.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const defaultEmptyTags = new Set([

// jsdoc doesn't use but allow for TypeScript
'internal',
'overload',
]);

const emptyIfNotClosure = new Set([
Expand Down
8 changes: 8 additions & 0 deletions src/tagNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ const typeScriptTags = {
// https://www.typescriptlang.org/tsconfig/#stripInternal
internal: [],

// https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#overload-support-in-jsdoc
overload: [],

// https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#satisfies-support-in-jsdoc
satisfies: [],

// `@template` is also in TypeScript per:
// https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#supported-jsdoc
template: [],
Expand All @@ -150,6 +156,8 @@ const {
/* eslint-disable no-unused-vars */
inheritdoc,
internal,
overload,
satisfies,

// Will be inverted to prefer `return`
returns,
Expand Down
25 changes: 23 additions & 2 deletions test/rules/assertions/checkTagNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -842,9 +842,17 @@ export default {
code: `${ALL_TYPESCRIPT_TAGS_COMMENT}\nfunction quux (foo) {}`,
errors: [
{
line: lineCount(ALL_TYPESCRIPT_TAGS_COMMENT) - 1,
line: lineCount(ALL_TYPESCRIPT_TAGS_COMMENT) - 3,
message: 'Invalid JSDoc tag name "internal".',
},
{
line: lineCount(ALL_TYPESCRIPT_TAGS_COMMENT) - 2,
message: 'Invalid JSDoc tag name "overload".',
},
{
line: lineCount(ALL_TYPESCRIPT_TAGS_COMMENT) - 1,
message: 'Invalid JSDoc tag name "satisfies".',
},
{
line: lineCount(ALL_TYPESCRIPT_TAGS_COMMENT),
message: 'Invalid JSDoc tag name "template".',
Expand Down Expand Up @@ -1289,7 +1297,7 @@ export default {
* Converts the images specified by the indices to base64 synchronously.
* @function WebTwain#ConvertToBase64
* @returns {Base64Result}
ConvertToBase64(): Base64Result;
*/
Expand All @@ -1303,5 +1311,18 @@ export default {
`,
parser: require.resolve('@typescript-eslint/parser'),
},
{
code: `
/**
* @overload
* @satisfies
*/
`,
settings: {
jsdoc: {
mode: 'typescript',
},
},
},
],
};

0 comments on commit ee2bae3

Please sign in to comment.