Skip to content

Commit

Permalink
fix(informative-docs): check default named declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
brettz9 committed Feb 6, 2024
1 parent 6fcb47f commit e9a9b74
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/rules/informative-docs.md
Expand Up @@ -263,6 +263,15 @@ export function packageNameFromPath(path) {
return /^vd+(.d+)?$/.exec(base) || /^tsd.d/.exec(base) ? basename(dirname(path)) : base;
}
// Message: This description only repeats the name it describes.

/**
* package name from path
*/
export default function packageNameFromPath(path) {
const base = basename(path);
return /^vd+(.d+)?$/.exec(base) || /^tsd.d/.exec(base) ? basename(dirname(path)) : base;
}
// Message: This description only repeats the name it describes.
````


Expand Down
1 change: 1 addition & 0 deletions src/rules/informativeDocs.js
Expand Up @@ -39,6 +39,7 @@ const getNamesFromNode = (node) => {
),
];

case 'ExportDefaultDeclaration':
case 'ExportNamedDeclaration':
return getNamesFromNode(
/** @type {import('@typescript-eslint/types').TSESTree.ExportNamedDeclaration} */
Expand Down
17 changes: 17 additions & 0 deletions test/rules/assertions/informativeDocs.js
Expand Up @@ -517,6 +517,23 @@ export default {
message: 'This description only repeats the name it describes.',
},
],
},
{
code: `
/**
* package name from path
*/
export default function packageNameFromPath(path) {
const base = basename(path);
return /^v\d+(\.\d+)?$/.exec(base) || /^ts\d\.\d/.exec(base) ? basename(dirname(path)) : base;
}
`,
errors: [
{
line: 2,
message: 'This description only repeats the name it describes.',
},
],
}
],
valid: [
Expand Down

0 comments on commit e9a9b74

Please sign in to comment.