Skip to content

Commit 6ab617f

Browse files
committed
fix(require-jsdoc): avoid erring (or traversing) on object spread in parsing for defined symbols; fixes #378
1 parent 022d5da commit 6ab617f

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6013,6 +6013,10 @@ enum Example {
60136013
test = 123
60146014
}
60156015
// Options: [{"contexts":["TSEnumDeclaration"]}]
6016+
6017+
const foo = {...{}};
6018+
function bar() {}
6019+
// Options: [{"exemptEmptyFunctions":false,"publicOnly":true,"require":{"ArrowFunctionExpression":true,"ClassDeclaration":true,"ClassExpression":true,"FunctionDeclaration":true,"FunctionExpression":false,"MethodDefinition":true}}]
60166020
````
60176021

60186022

src/exportParser.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ const getSymbol = function (node, globals, scope, opt) {
105105
const val = createNode();
106106
val.type = 'object';
107107
node.properties.forEach((prop) => {
108+
if (prop.type === 'ExperimentalSpreadProperty') {
109+
return;
110+
}
108111
const propVal = getSymbol(prop.value, globals, scope, opts);
109112
/* istanbul ignore next */
110113
if (propVal) {

test/rules/assertions/requireJsdoc.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2325,5 +2325,34 @@ export default {
23252325
sourceType: 'module',
23262326
},
23272327
},
2328+
{
2329+
// https://github.com/gajus/eslint-plugin-jsdoc/issues/378
2330+
code: `
2331+
const foo = {...{}};
2332+
function bar() {}
2333+
`,
2334+
options: [
2335+
{
2336+
exemptEmptyFunctions: false,
2337+
publicOnly: true,
2338+
require: {
2339+
ArrowFunctionExpression: true,
2340+
ClassDeclaration: true,
2341+
ClassExpression: true,
2342+
FunctionDeclaration: true,
2343+
FunctionExpression: false,
2344+
MethodDefinition: true,
2345+
},
2346+
},
2347+
],
2348+
parser: require.resolve('babel-eslint'),
2349+
parserOptions: {
2350+
ecmaFeatures: {
2351+
jsx: true,
2352+
},
2353+
ecmaVersion: 2017,
2354+
sourceType: 'module',
2355+
},
2356+
},
23282357
],
23292358
};

0 commit comments

Comments
 (0)