Skip to content

Commit

Permalink
fix(require-jsdoc): avoid erring (or traversing) on object spread i…
Browse files Browse the repository at this point in the history
…n parsing for defined symbols; fixes #378
  • Loading branch information
brettz9 committed Oct 23, 2019
1 parent 022d5da commit 6ab617f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -6013,6 +6013,10 @@ enum Example {
test = 123
}
// Options: [{"contexts":["TSEnumDeclaration"]}]

const foo = {...{}};
function bar() {}
// Options: [{"exemptEmptyFunctions":false,"publicOnly":true,"require":{"ArrowFunctionExpression":true,"ClassDeclaration":true,"ClassExpression":true,"FunctionDeclaration":true,"FunctionExpression":false,"MethodDefinition":true}}]
````


Expand Down
3 changes: 3 additions & 0 deletions src/exportParser.js
Expand Up @@ -105,6 +105,9 @@ const getSymbol = function (node, globals, scope, opt) {
const val = createNode();
val.type = 'object';
node.properties.forEach((prop) => {
if (prop.type === 'ExperimentalSpreadProperty') {
return;
}
const propVal = getSymbol(prop.value, globals, scope, opts);
/* istanbul ignore next */
if (propVal) {
Expand Down
29 changes: 29 additions & 0 deletions test/rules/assertions/requireJsdoc.js
Expand Up @@ -2325,5 +2325,34 @@ export default {
sourceType: 'module',
},
},
{
// https://github.com/gajus/eslint-plugin-jsdoc/issues/378
code: `
const foo = {...{}};
function bar() {}
`,
options: [
{
exemptEmptyFunctions: false,
publicOnly: true,
require: {
ArrowFunctionExpression: true,
ClassDeclaration: true,
ClassExpression: true,
FunctionDeclaration: true,
FunctionExpression: false,
MethodDefinition: true,
},
},
],
parser: require.resolve('babel-eslint'),
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2017,
sourceType: 'module',
},
},
],
};

0 comments on commit 6ab617f

Please sign in to comment.