Skip to content

Crashes on ESLint require-jsdoc directive comments #1090

Open
@jaydenseric

Description

@jaydenseric

This bug confused the heck out of me!

This:

// eslint-disable-next-line require-jsdoc
const Foo = () => <div />

Or this:

/* eslint-disable require-jsdoc */
const Foo = () => <div />
/* 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.<anonymous> (/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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions