Skip to content

Quotes that look like they could be a name cause unpaired bracket errors #173

@LukeAbby

Description

@LukeAbby

Both of these below error with an unpaired brackets error:

/**
 * @defaultValue `[`
 */
/**
 * @defaultValue '['
 */

In theory I think adding this to nameTokenizer would fix the error:

    if (source.startsWith("`") || source.startsWith("'")) {
      return spec;
    }

And I'd be happy to PR this but I wanted to check if this made sense first. The reason why " doesn't have these issues is because of this code:

    const quotedGroups = source.split('"');

    // if it starts with quoted group, assume it is a literal
    if (
      quotedGroups.length > 1 &&
      quotedGroups[0] === '' &&
      quotedGroups.length % 2 === 1
    ) {
      spec.name = quotedGroups[1];
      tokens.name = `"${quotedGroups[1]}"`;
      [tokens.postName, tokens.description] = splitSpace(
        source.slice(tokens.name.length)
      );
      return spec;
    }

Though admittedly I'm not sure I'd expect "[" to be the name. I understand it's a non-goal of comment-parser to deal with all possible ambiguities though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions