Skip to content

Commit e9a9b74

Browse files
committed
fix(informative-docs): check default named declaration
1 parent 6fcb47f commit e9a9b74

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

docs/rules/informative-docs.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,15 @@ export function packageNameFromPath(path) {
263263
return /^vd+(.d+)?$/.exec(base) || /^tsd.d/.exec(base) ? basename(dirname(path)) : base;
264264
}
265265
// Message: This description only repeats the name it describes.
266+
267+
/**
268+
* package name from path
269+
*/
270+
export default function packageNameFromPath(path) {
271+
const base = basename(path);
272+
return /^vd+(.d+)?$/.exec(base) || /^tsd.d/.exec(base) ? basename(dirname(path)) : base;
273+
}
274+
// Message: This description only repeats the name it describes.
266275
````
267276

268277

src/rules/informativeDocs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const getNamesFromNode = (node) => {
3939
),
4040
];
4141

42+
case 'ExportDefaultDeclaration':
4243
case 'ExportNamedDeclaration':
4344
return getNamesFromNode(
4445
/** @type {import('@typescript-eslint/types').TSESTree.ExportNamedDeclaration} */

test/rules/assertions/informativeDocs.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,23 @@ export default {
517517
message: 'This description only repeats the name it describes.',
518518
},
519519
],
520+
},
521+
{
522+
code: `
523+
/**
524+
* package name from path
525+
*/
526+
export default function packageNameFromPath(path) {
527+
const base = basename(path);
528+
return /^v\d+(\.\d+)?$/.exec(base) || /^ts\d\.\d/.exec(base) ? basename(dirname(path)) : base;
529+
}
530+
`,
531+
errors: [
532+
{
533+
line: 2,
534+
message: 'This description only repeats the name it describes.',
535+
},
536+
],
520537
}
521538
],
522539
valid: [

0 commit comments

Comments
 (0)