Skip to content

Commit

Permalink
fix(require-jsdoc): avoid erring (or traversing) on object spread; f…
Browse files Browse the repository at this point in the history
…ixes gajus#378
  • Loading branch information
brettz9 committed Oct 23, 2019
1 parent 022d5da commit 45b69aa
Show file tree
Hide file tree
Showing 3 changed files with 35 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
28 changes: 28 additions & 0 deletions test/rules/assertions/requireJsdoc.js
Expand Up @@ -2325,5 +2325,33 @@ export default {
sourceType: 'module',
},
},
{
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 45b69aa

Please sign in to comment.