Skip to content

Commit 739ed3f

Browse files
committed
Fix: add ExportNamedDeclaration to enforceExistence
Fixes #159 Closes gh-162
1 parent d2070ef commit 739ed3f

File tree

2 files changed

+40
-14
lines changed

2 files changed

+40
-14
lines changed

lib/rules/validate-jsdoc/enforce-existence.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function enforceExistence(node, err) {
7272
}
7373
}
7474
if (policy.exports === false) {
75-
if (parentNode.type === 'ExportDefaultDeclaration') {
75+
if (parentNode.type === 'ExportDefaultDeclaration' || parentNode.type === 'ExportNamedDeclaration') {
7676
// don't check es6 export
7777
return;
7878
} else if (parentNode.type === 'AssignmentExpression') {

test/lib/rules/validate-jsdoc/enforce-existence.js

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,22 +153,38 @@ describe('lib/rules/validate-jsdoc/enforce-existence', function () {
153153
checker.cases([
154154
/* jshint ignore:start */
155155
{
156-
it: 'should report jsdoc absence for named function export (#159)',
156+
it: 'should report jsdoc absence for default named function export (#159)',
157+
code: 'export default function named (v) {};',
158+
errors: 1,
159+
}, {
160+
it: 'should not report jsdoc absence for default named function export (#159)',
157161
code: [
158-
'export default function named (v) {',
159-
'};',
162+
'/** Foo bar */',
163+
'export default function named (v) {};',
160164
].join('\n'),
165+
errors: 0,
166+
}, {
167+
it: 'should report jsdoc absence for named function export (#159)',
168+
code: 'export function named (v) {};',
161169
errors: 1,
162170
}, {
163171
it: 'should not report jsdoc absence for named function export (#159)',
164172
code: [
165-
'/**',
166-
' * Foo bar',
167-
' */',
168-
'export default function named (v) {',
169-
'};',
173+
'/** Foo bar */',
174+
'export function named (v) {};',
175+
].join('\n'),
176+
}, {
177+
skip: true,
178+
it: 'should report jsdoc absence for default arrow function export (#159)',
179+
code: 'export default (v) => {};',
180+
errors: 1,
181+
}, {
182+
skip: true,
183+
it: 'should not report jsdoc absence for default arrow function export (#159)',
184+
code: [
185+
'/** Foo bar */',
186+
'export default (v) => {};',
170187
].join('\n'),
171-
errors: 0,
172188
},
173189
/* jshint ignore:end */
174190
]);
@@ -196,11 +212,21 @@ describe('lib/rules/validate-jsdoc/enforce-existence', function () {
196212
checker.cases([
197213
/* jshint ignore:start */
198214
{
215+
it: 'should not report jsdoc absence for default named function export (#159)',
216+
code: 'export default function named (v) {};',
217+
errors: 0,
218+
}, {
199219
it: 'should not report jsdoc absence for named function export (#159)',
200-
code: [
201-
'export default function named (v) {',
202-
'};',
203-
].join('\n'),
220+
code: 'export function named (v) {};',
221+
errors: 0,
222+
}, {
223+
it: 'should not report jsdoc absence for default anonymous function export (#159)',
224+
code: 'export default function (v) {};',
225+
errors: 0,
226+
}, {
227+
skip: true,
228+
it: 'should not report jsdoc absence for default arrow function export (#159)',
229+
code: 'export default (v) => {};',
204230
errors: 0,
205231
}
206232
/* jshint ignore:end */

0 commit comments

Comments
 (0)