documentationjs / documentationjs/documentation

Crashes on ESLint require-jsdoc directive comments

Open
#1,090 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
5.8k
Forks
481
PR merge metrics
No merged PRs in 30d

Description

This bug confused the heck out of me!

This:

```js
// eslint-disable-next-line require-jsdoc
const Foo = () =>


```

Or this:

```js
/* eslint-disable require-jsdoc */
const Foo = () =>


/* eslint-enable require-jsdoc */
```

Will cause the documentation.js CLI to crash for either `lint` or `readme` operations with an error similar to this example:

```
Error: Parsing file /Users/jaydenseric/Sites/graphql-react/src/test.mjs: Unexpected token (130:4)
at Deps.parseDeps (/Users/jaydenseric/Sites/graphql-react/node_modules/module-deps-sortable/index.js:467:28)
at fromSource (/Users/jaydenseric/Sites/graphql-react/node_modules/module-deps-sortable/index.js:402:44)
at /Users/jaydenseric/Sites/graphql-react/node_modules/module-deps-sortable/index.js:396:17
at ConcatStream. (/Users/jaydenseric/Sites/graphql-react/node_modules/module-deps-sortable/node_modules/concat-stream/index.js:36:43)
at ConcatStream.emit (events.js:187:15)
at finishMaybe (/Users/jaydenseric/Sites/graphql-react/node_modules/module-deps-sortable/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:475:14)
at endWritable (/Users/jaydenseric/Sites/graphql-react/node_modules/module-deps-sortable/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:485:3)
at ConcatStream.Writable.end (/Users/jaydenseric/Sites/graphql-react/node_modules/module-deps-sortable/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:455:41)
at DuplexWrapper.onend (/Users/jaydenseric/Sites/graphql-react/node_modules/readable-stream/lib/_stream_readable.js:577:10)
at Object.onceWrapper (events.js:273:13)
```

Take away the comments and it works fine. I think the `require` part of the comment is erroneously causing some sort of import analysis to happen, which happens to fail because there is JSX in the file. Maybe this accidental analysis would go unnoticed if it weren't for the JSX, or maybe it would error on something else. I don't know.

* What version of documentation.js are you using?: v8.0.0
* How are you running documentation.js (on the CLI, Node.js API, Grunt, other?): CLI

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.