Skip to content

Commit

Permalink
fix(require-jsdoc): handle spread elements in typescript-eslint/par…
Browse files Browse the repository at this point in the history
…ser; for #378
  • Loading branch information
brettz9 committed Jan 7, 2020
1 parent b1ce407 commit 3e8ea59
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8171,6 +8171,14 @@ export default class Foo {
// ....
}
// Options: [{"exemptEmptyFunctions":false,"require":{"ClassDeclaration":true}}]
const a = {};
const b = {
...a
};
export default b;
// Options: [{"contexts":["ObjectExpression"],"exemptEmptyFunctions":false,"publicOnly":true}]
````
Expand Down
8 changes: 7 additions & 1 deletion src/exportParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ const getSymbol = function (node, globals, scope, opt) {
const val = createNode();
val.type = 'object';
node.properties.forEach((prop) => {
if (prop.type === 'ExperimentalSpreadProperty') {
if ([
// @typescript-eslint/parser, espree, acorn, etc.
'SpreadElement',

// babel-eslint
'ExperimentalSpreadProperty',
].includes(prop.type)) {
return;
}
const propVal = getSymbol(prop.value, globals, scope, opts);
Expand Down
21 changes: 21 additions & 0 deletions test/rules/assertions/requireJsdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2383,5 +2383,26 @@ export default {
sourceType: 'module',
},
},
{
code: `
const a = {};
const b = {
...a
};
export default b;
`,
options: [
{
contexts: ['ObjectExpression'],
exemptEmptyFunctions: false,
publicOnly: true,
},
],
parser: require.resolve('@typescript-eslint/parser'),
parserOptions: {
sourceType: 'module',
},
},
],
};

0 comments on commit 3e8ea59

Please sign in to comment.