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

38.0.5 generates Cannot read property 'tags' of undefined when comment includes extra asterisks #853

Closed
KeithGillette opened this issue Mar 19, 2022 · 2 comments

Comments

@KeithGillette
Copy link

Expected behavior

Linting should not throw an unhandled exception when a JSDoc block includes an extra asterisk.

Actual behavior

A comment of the following form:
/*** Oops that's too many asterisks by accident **/

Produces

An unhandled exception occurred: Cannot read property 'tags' of undefined
Occurred while linting /some/path/to/a/file:#
Rule: "jsdoc/no-types"
See "/private/var/folders/t5/nv32j92n7rngpy281m6gj8n00000gn/T/ng-1nKMmj/angular-errors.log" for further details.
[error] TypeError: Cannot read property 'tags' of undefined
Occurred while linting /some/path/to/a/file:#
Rule: "jsdoc/no-types"
    at Object.utils.filterTags (.../node_modules/eslint-plugin-jsdoc/dist/iterateJsdoc.js:622:49)
    at Object.utils.getPresentTags (.../node_modules/eslint-plugin-jsdoc/dist/iterateJsdoc.js:616:18)
    at _default.contextDefaults (.../node_modules/eslint-plugin-jsdoc/dist/rules/noTypes.js:26:22)
    at iterate (.../node_modules/eslint-plugin-jsdoc/dist/iterateJsdoc.js:830:3)
    at checkJsdoc (.../node_modules/eslint-plugin-jsdoc/dist/iterateJsdoc.js:1132:9)
    at ruleErrorHandler (.../node_modules/eslint/lib/linter/linter.js:1114:28)
    at .../node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (.../node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (.../node_modules/eslint/lib/linter/node-event-generator.js:297:26)

Removing the extra asterisks prevents the unhandled exception.

ESLint Config

{
  "root": true,
  "ignorePatterns": [
    "projects/**/*"
  ],
  "overrides": [
    {
      "files": [
        "*.ts"
      ],
      "parserOptions": {
        "project": [
          "tsconfig.json"
        ]
      },
      "extends": [
        "eslint:recommended",
        "plugin:@angular-eslint/ng-cli-compat",
        "plugin:@angular-eslint/ng-cli-compat--formatting-add-on",
        "plugin:@angular-eslint/template/process-inline-templates",
        "plugin:@typescript-eslint/recommended",
        "plugin:@typescript-eslint/recommended-requiring-type-checking",
        "plugin:eslint-plugin-rxjs/recommended"
      ],
      "plugins": [
        "eslint-plugin-unicorn",
        "eslint-plugin-rxjs"
      ],
      "rules": {
        "@angular-eslint/component-max-inline-declarations": "error",
        "@angular-eslint/component-selector": [
          "error",
          {
            "type": "element",
            "prefix": "tt",
            "style": "kebab-case"
          }
        ],
        "@angular-eslint/directive-selector": [
          "error",
          {
            "type": "attribute",
            "prefix": "tt",
            "style": "camelCase"
          }
        ],
        "@angular-eslint/no-attribute-decorator": "error",
        "@angular-eslint/no-forward-ref": "error",
        "@angular-eslint/no-input-rename": "error",
        "@angular-eslint/no-lifecycle-call": "error",
        "@angular-eslint/no-pipe-impure": "error",
        "@angular-eslint/pipe-prefix": [
          "error",
          {
            "prefixes": [
              "tt"
            ]
          }
        ],
        "@angular-eslint/prefer-output-readonly": "error",
        "@angular-eslint/use-component-selector": "error",
        "@angular-eslint/use-injectable-provided-in": "error",
        "@typescript-eslint/array-type": [
          "error",
          {
            "default": "array"
          }
        ],
        "@typescript-eslint/ban-ts-comment": "warn",
        "@typescript-eslint/consistent-type-definitions": "error",
        "@typescript-eslint/dot-notation": "warn",
        // Just a style preference
        "@typescript-eslint/explicit-member-accessibility": [
          "error",
          {
            "accessibility": "explicit"
          }
        ],
        "@typescript-eslint/member-ordering": "warn",
        "@typescript-eslint/naming-convention": [
          "error",
          {
            "selector": "parameter",
            "format": [
              "camelCase",
              "PascalCase"
            ],
            "leadingUnderscore": "allow",
            "trailingUnderscore": "allow"
          },
          {
            "selector": "enumMember",
            "format": [
              "camelCase",
              "PascalCase"
            ]
          }
        ],
        // DTO interfaces use type transformations on classes without adding properties
        "@typescript-eslint/no-empty-interface": "off",
        // @ToDo: Convert to unknown or proper typing & remove
        "@typescript-eslint/no-explicit-any": "warn",
        // Angular Modules are often decorated empty classes
        "@typescript-eslint/no-extraneous-class": "off",
        "@typescript-eslint/no-floating-promises": "warn",
        // Just a style preference
        "@typescript-eslint/no-inferrable-types": "off",
        "@typescript-eslint/no-shadow": [
          "error",
          {
            "hoist": "never"
          }
        ],
        // @ToDo: Properly type `any` and remove `no-unsafe-*`
        "@typescript-eslint/no-unsafe-argument": "warn",
        "@typescript-eslint/no-unsafe-assignment": "warn",
        "@typescript-eslint/no-unsafe-call": "warn",
        "@typescript-eslint/no-unsafe-member-access": "warn",
        "@typescript-eslint/no-unsafe-return": "warn",
        "@typescript-eslint/no-unused-expressions": [
          "error",
          {
            "allowShortCircuit": true,
            "allowTernary": true
          }
        ],
        "@typescript-eslint/quotes": [
          "error",
          "single",
          {
            "avoidEscape": true
          }
        ],
        // @ToDo: Properly type `any` and remove
        "@typescript-eslint/restrict-template-expressions": "warn",
        "@typescript-eslint/unbound-method": [
          "error",
          {
            "ignoreStatic": true
          }
        ],
        // Just a style preference to override [default](https://eslint.org/docs/rules/arrow-body-style),
        "arrow-body-style": "off",
        "arrow-parens": [
          "error",
          "always"
        ],
        "brace-style": [
          "error",
          "1tbs"
        ],
        "id-blacklist": "off",
        "id-match": "off",
        "import/no-default-export": "error",
        "import/no-deprecated": "error",
        "import/no-extraneous-dependencies": "off",
        "max-len": [
          "error",
          {
            "code": 188,
            "ignoreComments": true,
            "ignoreUrls": true,
            "ignoreStrings": true,
            "ignoreTemplateLiterals": true,
            "ignoreRegExpLiterals": true
          }
        ],
        "no-case-declarations": "warn",
        // https://github.com/eslint/eslint/issues/14008#issuecomment-781099293
        "no-console": [
          "error",
          {
            "allow": [
              ""
            ]
          }
        ],
        "no-duplicate-case": "error",
        "no-duplicate-imports": "error",
        "no-extra-bind": "error",
        "no-irregular-whitespace": "error",
        "no-new-func": "error",
        "no-redeclare": "error",
        "no-restricted-syntax": [
          "error",
          "ForInStatement"
        ],
        "no-return-await": "error",
        "no-sequences": "error",
        "no-template-curly-in-string": "error",
        "no-underscore-dangle": "off",
        // Dependency Injection requires constructor
        "no-useless-constructor": "off",
        // https://eslint.org/docs/rules/object-shorthand#require-object-literal-shorthand-syntax-object-shorthand
        "object-shorthand": [
          "error",
          "consistent"
        ],
        "prefer-template": "error",
        "rxjs/no-ignored-notifier": "warn",
        "rxjs/no-ignored-takewhile-value": "warn",
        "space-in-parens": [
          "off",
          "never"
        ],
        "unicorn/filename-case": "error"
      }
    },
    {
      "files": [
        "*.html"
      ],
      "extends": [
        "plugin:@angular-eslint/template/recommended"
      ],
      "rules": {
        "@angular-eslint/template/conditional-complexity": "error",
        "@angular-eslint/template/cyclomatic-complexity": [
          "error",
          {
            "maxComplexity": 5
          }
        ]
      }
    }
  ]
}

ESLint sample

/*** Oops that's too many asterisks by accident **/

Environment

  • Node version: 14.18.3
  • ESLint version: 8.11.0
  • eslint-plugin-jsdoc version: 38.0.5
@brettz9
Copy link
Collaborator

brettz9 commented Mar 19, 2022

Release should be posted here shortly. That should at least fix things for no-types, but let us know if you see errors from any other rules.

@gajus
Copy link
Owner

gajus commented Mar 19, 2022

🎉 This issue has been resolved in version 38.0.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gajus gajus added the released label Mar 19, 2022
crapStone pushed a commit to Calciumdibromid/CaBr2 that referenced this issue Mar 23, 2022
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) | devDependencies | patch | [`38.0.4` -> `38.0.6`](https://renovatebot.com/diffs/npm/eslint-plugin-jsdoc/38.0.4/38.0.6) |

---

### Release Notes

<details>
<summary>gajus/eslint-plugin-jsdoc</summary>

### [`v38.0.6`](https://github.com/gajus/eslint-plugin-jsdoc/releases/v38.0.6)

[Compare Source](gajus/eslint-plugin-jsdoc@v38.0.5...v38.0.6)

##### Bug Fixes

-   ensure bad JSDoc blocks do not cause errors (outside of `no-bad-blocks`); fixes [#&#8203;853](gajus/eslint-plugin-jsdoc#853) ([17fe2ca](gajus/eslint-plugin-jsdoc@17fe2ca))

### [`v38.0.5`](https://github.com/gajus/eslint-plugin-jsdoc/releases/v38.0.5)

[Compare Source](gajus/eslint-plugin-jsdoc@v38.0.4...v38.0.5)

##### Bug Fixes

-   update jsdoccomment, comment-parser, debug ([63d18d2](gajus/eslint-plugin-jsdoc@63d18d2))

</details>

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).

Co-authored-by: cabr2-bot <cabr2.help@gmail.com>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1233
Reviewed-by: Epsilon_02 <epsilon_02@noreply.codeberg.org>
Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants