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/valid-types Rule Errors when namepath contains readonly (all lowercase) #813

Closed
dhurlburtusa opened this issue Dec 15, 2021 · 4 comments

Comments

@dhurlburtusa
Copy link

Expected behavior

The following should be valid and should not generate an error.

/**
 * @param {object} params
 * @param {boolean} params.readonly
 */

Actual behavior

/**
 * @param {object} params
 * @param {boolean} params.readonly
 */

Errors with: "Syntax error in namepath: params.readonly jsdoc/valid-types".

ESLint Config

module.exports = {
  root: true,
  extends: ["plugin:jsdoc/recommended"],
  rules: {
    "jsdoc/valid-types": "error",
  },
};

ESLint sample

/**
 * @param readonly
 */
/**
 * @param {boolean} readonly
 */
/**
 * @param {object} params
 * @param {boolean} params.readonly
 */

Environment

  • Node version: 16.6.1
  • ESLint version: 8.4.1
  • eslint-plugin-jsdoc version: 37.2.0

Possible Cause

I believe the cause of this is due to the following PR: jsdoc-type-pratt-parser/jsdoc-type-pratt-parser#98

Although the cause may be due to the parser (I filed an issue there too (jsdoc-type-pratt-parser/jsdoc-type-pratt-parser#104)), I'm thinking it would be good to improve the tests here to help catch some of these errors.

@brettz9
Copy link
Collaborator

brettz9 commented Dec 18, 2021

I'd prefer we get any tests added to jsdoc-type-pratt-parser. Don't need to cover every edge case in this project, I think. Closing but feel free to comment further as needed.

@brettz9 brettz9 closed this as completed Dec 18, 2021
@jdatskuid
Copy link

jdatskuid commented Mar 14, 2022

I ran into this error today in a typedef. We have an object with a property named "readonly" and I get this error.

ESLint v7.7.0

Example:

/**
 * An object interface
 * @typedef  {Object} FooBar
 * @property {boolean} readonly
 * @property {boolean} private
 * @property {boolean} public
 * @property {boolean} constant
 */

Error:

32:0  error  Syntax error in namepath: readonly          jsdoc/valid-types

My only workaround was to disable the valid-types rule for the JSDoc comment:

/* eslint-disable jsdoc/valid-types */
/**
 * An object interface
 * @typedef  {Object} FooBar
 * @property {boolean} readonly
 * @property {boolean} private
 * @property {boolean} public
 * @property {boolean} constant
 */
/* eslint-enable */

@brettz9
Copy link
Collaborator

brettz9 commented Mar 14, 2022

The issue is being tracked at jsdoc-type-pratt-parser..

You might try surrounding the item in quotes and see if that provides a temporary resolution.

@jdatskuid
Copy link

Thanks, I noticed that after posting. Quotes do not resolve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants