Skip to content

Commit

Permalink
Fix: add ExportNamedDeclaration to enforceExistence
Browse files Browse the repository at this point in the history
Fixes #159
Closes gh-162
  • Loading branch information
qfox committed Oct 1, 2015
1 parent 5f7d756 commit b122c9d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/rules/validate-jsdoc/enforce-existence.js
Expand Up @@ -72,7 +72,7 @@ function enforceExistence(node, err) {
}
}
if (policy.exports === false) {
if (parentNode.type === 'ExportDefaultDeclaration') {
if (parentNode.type === 'ExportDefaultDeclaration' || parentNode.type === 'ExportNamedDeclaration') {
// don't check es6 export
return;
} else if (parentNode.type === 'AssignmentExpression') {
Expand Down
52 changes: 39 additions & 13 deletions test/lib/rules/validate-jsdoc/enforce-existence.js
Expand Up @@ -153,22 +153,38 @@ describe('lib/rules/validate-jsdoc/enforce-existence', function () {
checker.cases([
/* jshint ignore:start */
{
it: 'should report jsdoc absence for named function export (#159)',
it: 'should report jsdoc absence for default named function export (#159)',
code: 'export default function named (v) {};',
errors: 1,
}, {
it: 'should not report jsdoc absence for default named function export (#159)',
code: [
'export default function named (v) {',
'};',
'/** Foo bar */',
'export default function named (v) {};',
].join('\n'),
errors: 0,
}, {
it: 'should report jsdoc absence for named function export (#159)',
code: 'export function named (v) {};',
errors: 1,
}, {
it: 'should not report jsdoc absence for named function export (#159)',
code: [
'/**',
' * Foo bar',
' */',
'export default function named (v) {',
'};',
'/** Foo bar */',
'export function named (v) {};',
].join('\n'),
}, {
skip: true,
it: 'should report jsdoc absence for default arrow function export (#159)',
code: 'export default (v) => {};',
errors: 1,
}, {
skip: true,
it: 'should not report jsdoc absence for default arrow function export (#159)',
code: [
'/** Foo bar */',
'export default (v) => {};',
].join('\n'),
errors: 0,
},
/* jshint ignore:end */
]);
Expand Down Expand Up @@ -196,11 +212,21 @@ describe('lib/rules/validate-jsdoc/enforce-existence', function () {
checker.cases([
/* jshint ignore:start */
{
it: 'should not report jsdoc absence for default named function export (#159)',
code: 'export default function named (v) {};',
errors: 0,
}, {
it: 'should not report jsdoc absence for named function export (#159)',
code: [
'export default function named (v) {',
'};',
].join('\n'),
code: 'export function named (v) {};',
errors: 0,
}, {
it: 'should not report jsdoc absence for default anonymous function export (#159)',
code: 'export default function (v) {};',
errors: 0,
}, {
skip: true,
it: 'should not report jsdoc absence for default arrow function export (#159)',
code: 'export default (v) => {};',
errors: 0,
}
/* jshint ignore:end */
Expand Down

0 comments on commit b122c9d

Please sign in to comment.