Skip to content

Why import type syntax marked as invalid? #677

Closed
@krutoo

Description

@krutoo

Hi, i have two files with code:

// event.js
export class CustomEvent {}

// index.js
/**
 * @param {import('./event').CustomEvent} event Event.
 */
export function main (event) {
  console.log(event);
}

and config like:

module.exports = {
  // ...
  rules: {
    // ...
    'jsdoc/check-param-names': 'error',
    'jsdoc/valid-types': 'error',
  },
};

in terminal i have error:

> eslint ./src

/home/petrov_dm/Projects/eslint-plugin-jsdoc-tests/src/index.js
  2:0  error  Syntax error in type: import('./event').CustomEvent  jsdoc/valid-types

✖ 1 problem (1 error, 0 warnings)

there is repo with clean example of code:
https://github.com/krutoo/eslint-plugin-jsdoc-tests

Why this code is marked as with syntax error?
(this worked differently in previous plugin versions)

readme.md tells that is valid type syntax:
https://github.com/gajus/eslint-plugin-jsdoc#why-not-capital-case-everything

The following patterns are not considered problems:

with this code example:

/**
 * @param {import('./foo').bar.baz} foo
 */
function qux(foo) {
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions