Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

JSDoc rule should not block arbitrary comments like /********/ #1543

Merged
merged 3 commits into from
Sep 10, 2016
Merged

JSDoc rule should not block arbitrary comments like /********/ #1543

merged 3 commits into from
Sep 10, 2016

Conversation

nomaed
Copy link
Contributor

@nomaed nomaed commented Sep 8, 2016

Problem

There are 2 prime examples of comments that confuse tslint JSDoc detection regex:
A separator:

class MyClass {
    public prop1;
    public prop2;
    /********************************************/
    constructor() { ... }
    public method1() { ... }
    public method2() { ... }
    /********************************************/
    private internal1() { ... }
}

and

/**************
 * my-file.ts *
 **************/

These can be used as visual separator or guides, and are definitely not JSDocs.
Was also reported in issue #1121 several months ago.

Solution

Instead of matching any /^\s*\/\*\*/, I suggest that when there are more than 2 asterisks in a row, it should not be tested as a JSDoc comment.
Thus, the regex is updated to /^\s*\/\*\*([^*]|$)/ which would accept /** followed by anything but another *.

matched as jsdoc

/** (space) */ // valid, empty
/**text */ // invalid
/**_ */ // invalid
/** (new-line) // valid
 */

not jsdoc

/***/
/*/
/*******/
/******
*******/

@jkillian
Copy link
Contributor

This seems reasonable, thanks @nomaed!

@jkillian jkillian merged commit e9bedf9 into palantir:master Sep 10, 2016
@nomaed nomaed deleted the jsdoc-not-a-comment branch September 10, 2016 16:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants