Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSDoc Comment Issues #7

Closed
nazhujan opened this issue Mar 8, 2023 · 2 comments
Closed

JSDoc Comment Issues #7

nazhujan opened this issue Mar 8, 2023 · 2 comments
Labels
question Further information is requested

Comments

@nazhujan
Copy link

nazhujan commented Mar 8, 2023

Currently working on project to throw error for unnecessary comment without correct label, which is easily to identify and helpful for the long run. But then I got 1 issue which is unable to ignore the JSDoc Comment which also become a blocker and i need to disable/warn the rules? any solution for this?

@wisniewski94
Copy link
Owner

wisniewski94 commented Mar 8, 2023

Yes, under the hood plugin is doing regex match, so there is nothing to stop you from creating your own regex and adding it into allowlist. Note that /* and */ delimiters are not part of the tested string.

module.exports = {
    "env": {
        "browser": true,
        "es2021": true
    },
    "extends": "eslint:recommended",
    "parserOptions": {
        "ecmaVersion": 12
    },
    "plugins": ["no-comments"],
    "rules": {
        "no-comments/disallowComments": [
          "error",
          {
            "allow": [
              "global",
              "eslint",
              "TODO",
              "FIXME",
              "todo",
              `\\*\\s.*\n\\s\\*\\s+@`
            ]
          }
        ]
    }
};

Explanation:

  • \* matches the literal * character
  • \s matches any whitespace character (space, tab, etc.)
  • .* matches any character zero or more times (except for newline)
  • \n matches a newline character
  • \*\s+ matches the * character followed by one or more whitespace characters
  • @ matches the @ character

image

image

Note I am not adding this to the source code as regexp is usually heavy in terms of required computation power. Adding such rules will slow down all workspaces including ones that don't use jsdoc

What makes it more difficult is the fact that jsdoc examples tend to vary depending on a project. I don't think I will be able to cover all possible use cases so you have to come up with your own RegExp. ** I know some people might be unhappy of this decision** but there isn't anything worse than a loud spinning mac fan because eslint is running on a 1k lines file.

@wisniewski94 wisniewski94 added wontfix This will not be worked on question Further information is requested and removed wontfix This will not be worked on labels Mar 8, 2023
@tomerh2001
Copy link

tomerh2001 commented Aug 19, 2024

@nazhujan I have a no-comments rule that supports jsdoc in my custom eslint rules: https://github.com/tomerh2001/eslint-plugin-th-rules

Feel free to check it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants