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

valid-types doesn't allow users to specify the properties of array items #596

Closed
gurpreetatwal opened this issue Jun 30, 2020 · 3 comments
Closed

Comments

@gurpreetatwal
Copy link

gurpreetatwal commented Jun 30, 2020

Expected behavior

valid-types should allow users to specify the properties of values in an array as documented on the JSDoc website: https://jsdoc.app/tags-param.html#parameters-with-properties

Actual behavior

  6:0  error  Syntax error in namepath: employees[].name        jsdoc/valid-types
  7:0  error  Syntax error in namepath: employees[].department  jsdoc/valid-types

ESLint Config

'use strict';

module.exports = {
  env: {
    node: true,
  },
  plugins: ['jsdoc'],
  rules: {
    'jsdoc/valid-types': [
      'error',
      { allowEmptyNamepaths: true, checkSeesForNamepaths: false },
    ],
  },
};

ESLint sample

'use strict';

/**
 * Assign the project to a list of employees.
 * @param {Object[]} employees - The employees who are responsible for the project.
 * @param {string} employees[].name - The name of an employee.
 * @param {string} employees[].department - The employee's department.
 */
function assign(employees) {
  // ...
}

Environment

  • Node version: v12.18.1
  • ESLint version: v7.3.1
  • eslint-plugin-jsdoc version: v28.5.1

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@brettz9
Copy link
Collaborator

brettz9 commented Jun 30, 2020

This is actually due to a jsdoctypeparser issue. We need to have such catharsis parser rules (as used by jsdoc) moved over to jsdoctypeparser to allow for these form of namepaths (though excluding this from typescript mode, I believe, and possibly also "closure" mode). (The reason check-param-names handles this format is because we do our own (incomplete) name parsing in that rule, but this really needs to be fixed in jsdoctypeparser.)

This is blocked by jsdoctypeparser/jsdoctypeparser#117 so feel free to subscribe there. It may require some tweaking in eslint-plugin-jsdoc as well (at least if we separate name from namepath parsing as per jsdoctypeparser/jsdoctypeparser#117 ) so keeping this issue open for now.

Edit: This is also blocked by jsdoctypeparser/jsdoctypeparser#134

@brettz9
Copy link
Collaborator

brettz9 commented Oct 23, 2022

This is no longer reporting errors, so added a test and closing.

I've just pushed a fix to catch some errors along these lines (e.g., employees[.name with a missing bracket now errs out). However, #374 is being used to track a potentially more proper namepath (or name) parsing.

@gajus
Copy link
Owner

gajus commented Oct 23, 2022

🎉 This issue has been resolved in version 39.3.22 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gajus gajus added the released label Oct 23, 2022
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