Skip to content

Commit

Permalink
fix(require-jsdoc): allow TSTypeLiteral and `TSTypeAliasDeclarati…
Browse files Browse the repository at this point in the history
…on` to have `TSPropertySignature` checks pass through them toward public export for `publicOnly` checks; fixes #852
  • Loading branch information
brettz9 committed Mar 14, 2022
1 parent 5e8e0c7 commit 19e4f6f
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/exportParser.js
Expand Up @@ -456,6 +456,8 @@ const canBeExportedByAncestorType = new Set([
const canExportChildrenType = new Set([
'TSInterfaceBody',
'TSInterfaceDeclaration',
'TSTypeLiteral',
'TSTypeAliasDeclaration',
'ClassDeclaration',
'ClassBody',
'ClassDefinition',
Expand Down
90 changes: 90 additions & 0 deletions test/rules/assertions/requireJsdoc.js
Expand Up @@ -3726,6 +3726,96 @@ function quux (foo) {
`,
parser: require.resolve('@typescript-eslint/parser'),
},
{
code: `
/** Alpha of all types */
export type Alpha = {
one: string;
two: number;
};
`,
errors: [
{
line: 4,
message: 'Missing JSDoc comment.',
},
{
line: 5,
message: 'Missing JSDoc comment.',
},
],
ignoreReadme: true,
options: [
{
contexts: [
'TSPropertySignature',
],
publicOnly: true,
},
],
output: `
/** Alpha of all types */
export type Alpha = {
/**
*
*/
one: string;
/**
*
*/
two: number;
};
`,
parser: require.resolve('@typescript-eslint/parser'),
},
{
code: `
export type Alpha = {
one: string;
two: number;
};
`,
errors: [
{
line: 2,
message: 'Missing JSDoc comment.',
},
{
line: 3,
message: 'Missing JSDoc comment.',
},
{
line: 4,
message: 'Missing JSDoc comment.',
},
],
ignoreReadme: true,
options: [
{
contexts: [
'TSTypeAliasDeclaration',
'TSPropertySignature',
],
publicOnly: true,
},
],
output: `
/**
*
*/
export type Alpha = {
/**
*
*/
one: string;
/**
*
*/
two: number;
};
`,
parser: require.resolve('@typescript-eslint/parser'),
},
],
valid: [
{
Expand Down

0 comments on commit 19e4f6f

Please sign in to comment.