Skip to content

enable jsdoc/valid-types on ESLint #43019

Description

@himself65

What is the problem this feature will solve?

improve the type resolution and project robustness

What is the feature you are proposing to solve the problem?

remove this line

'jsdoc/valid-types': 'off',

What alternatives have you considered?

This might cause lint error because of many incorrect doc typing in the project.

But still have some workaround, for example, #43006 (comment)

Activity

  1. added
    feature requestIssues requesting new Node.js features.
    typingsIssues and PRs related to internal TypeScript declarations.
    on May 9, 2022
  2. himself65 commented on May 9, 2022

    @himself65
    MemberAuthor
    ➜  node git:(20220508-fix-jsdoc) ✗ make lint-js-fix         
    
    /Users/himself65/Code/node/lib/internal/async_hooks.js
      450:1  warning  Syntax error in type: (...T: args) => R  jsdoc/valid-types
    
    /Users/himself65/Code/node/lib/internal/errors.js
      385:1  warning  Syntax error in type: (...args: any[]) => any  jsdoc/valid-types
    
    /Users/himself65/Code/node/lib/internal/readline/interface.js
      1339:1  warning  Syntax error in type: {
      [Symbol.asyncIterator]: () => InterfaceAsyncIterator,
      next: () => Promise<string>
    }  jsdoc/valid-types
    
    /Users/himself65/Code/node/lib/querystring.js
      312:1  warning  Syntax error in type: {
      maxKeys?: number,
      decodeURIComponent?(v: string): string,
      }  jsdoc/valid-types
    
    /Users/himself65/Code/node/lib/util.js
      209:1  warning  Syntax error in type: (...args: any[]) => void                                                                                                                          jsdoc/valid-types
      259:1  warning  Syntax error in type: S extends null ? T : (T & S)                                                                                                                      jsdoc/valid-types
      285:1  warning  Syntax error in type: (...args: any[]) => Promise<any>                                                                                                                  jsdoc/valid-types
      287:1  warning  Syntax error in type: T extends (...args: infer TArgs) => Promise<infer TReturn> ?
      ((...params: [...TArgs, ((err: Error, ret: TReturn) => any)]) => void) :
      never
      jsdoc/valid-types
    
    /Users/himself65/Code/node/test/pummel/test-policy-integrity-dep.js
      217:1  warning  Syntax error in type: Array<{[key: keyof T]: T[keyof configurations]}>  jsdoc/valid-types
    
    /Users/himself65/Code/node/test/pummel/test-policy-integrity-parent-commonjs.js
      217:1  warning  Syntax error in type: Array<{[key: keyof T]: T[keyof configurations]}>  jsdoc/valid-types
    
    /Users/himself65/Code/node/test/pummel/test-policy-integrity-parent-module.js
      217:1  warning  Syntax error in type: Array<{[key: keyof T]: T[keyof configurations]}>  jsdoc/valid-types
    
    /Users/himself65/Code/node/test/pummel/test-policy-integrity-parent-no-package-json.js
      217:1  warning  Syntax error in type: Array<{[key: keyof T]: T[keyof configurations]}>  jsdoc/valid-types
    
    /Users/himself65/Code/node/test/pummel/test-policy-integrity-worker-commonjs.js
      234:1  warning  Syntax error in type: Array<{[key: keyof T]: T[keyof configurations]}>  jsdoc/valid-types
    
    /Users/himself65/Code/node/test/pummel/test-policy-integrity-worker-module.js
      234:1  warning  Syntax error in type: Array<{[key: keyof T]: T[keyof configurations]}>  jsdoc/valid-types
    
    /Users/himself65/Code/node/test/pummel/test-policy-integrity-worker-no-package-json.js
      234:1  warning  Syntax error in type: Array<{[key: keyof T]: T[keyof configurations]}>  jsdoc/valid-types
    
    ✖ 15 problems (0 errors, 15 warnings)
    
    ESLint found too many warnings (maximum: 0).
    make: *** [lint-js-fix] Error 1
    Index: lib/internal/modules/esm/resolve.js
    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    ===================================================================
    diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js
    --- a/lib/internal/modules/esm/resolve.js	(revision 77d5f62cf9c9dac6ae1f20866503d7a6a6488e0d)
    +++ b/lib/internal/modules/esm/resolve.js	(date 1652028424765)
    @@ -849,7 +849,7 @@
      * @param {string} specifier
      * @param {string | URL | undefined} base
      * @param {Set<string>} conditions
    - * @returns {resolved: URL, format? : string}
    + * @returns {URL}
      */
     function packageResolve(specifier, base, conditions) {
       if (NativeModule.canBeRequiredByUsers(specifier) &&
    @@ -939,7 +939,7 @@
      * @param {string | URL | undefined} base
      * @param {Set<string>} conditions
      * @param {boolean} preserveSymlinks
    - * @returns {url: URL, format?: string}
    + * @returns {URL}
      */
     function moduleResolve(specifier, base, conditions, preserveSymlinks) {
       const isRemote = base.protocol === 'http:' ||
    Index: lib/internal/blob.js
    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    ===================================================================
    diff --git a/lib/internal/blob.js b/lib/internal/blob.js
    --- a/lib/internal/blob.js	(revision 77d5f62cf9c9dac6ae1f20866503d7a6a6488e0d)
    +++ b/lib/internal/blob.js	(date 1652028192327)
    @@ -132,7 +132,7 @@
        *   endings? : string,
        *   type? : string,
        * }} [options]
    -   * @constructs {Blob}
    +   * @constructs
        */
       constructor(sources = [], options = {}) {
         if (sources === null ||
    Index: lib/internal/webstreams/transformstream.js
    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    ===================================================================
    diff --git a/lib/internal/webstreams/transformstream.js b/lib/internal/webstreams/transformstream.js
    --- a/lib/internal/webstreams/transformstream.js	(revision 77d5f62cf9c9dac6ae1f20866503d7a6a6488e0d)
    +++ b/lib/internal/webstreams/transformstream.js	(date 1652028453461)
    @@ -74,12 +74,12 @@
     
     /**
      * @callback TransformerStartCallback
    - * @param {TransformStreamDefaultController} controller;
    + * @param {TransformStreamDefaultController} controller
      */
     
     /**
      * @callback TransformerFlushCallback
    - * @param {TransformStreamDefaultController} controller;
    + * @param {TransformStreamDefaultController} controller
      * @returns {Promise<void>}
      */
     
    Index: lib/internal/async_hooks.js
    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    ===================================================================
    diff --git a/lib/internal/async_hooks.js b/lib/internal/async_hooks.js
    --- a/lib/internal/async_hooks.js	(revision 77d5f62cf9c9dac6ae1f20866503d7a6a6488e0d)
    +++ b/lib/internal/async_hooks.js	(date 1652028181771)
    @@ -447,7 +447,7 @@
      * @template {Array<unknown>} T
      * @template {unknown} R
      * @param {number} triggerAsyncId
    - * @param { (...T: args) => R } block
    + * @param {(...T: args) => R} block
      * @param  {T} args
      * @returns {R}
      */
    Index: .eslintrc.js
    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    ===================================================================
    diff --git a/.eslintrc.js b/.eslintrc.js
    --- a/.eslintrc.js	(revision 77d5f62cf9c9dac6ae1f20866503d7a6a6488e0d)
    +++ b/.eslintrc.js	(date 1652112856862)
    @@ -38,6 +38,11 @@
       env: {
         es2022: true,
       },
    +  settings: {
    +    jsdoc: {
    +      mode: 'typescript'
    +    }
    +  },
       extends: ['eslint:recommended', 'plugin:jsdoc/recommended'],
       plugins: ['jsdoc', 'markdown', 'node-core'],
       parser: '@babel/eslint-parser',
    @@ -306,7 +311,6 @@
         'jsdoc/require-param-description': 'off',
         'jsdoc/newline-after-description': 'off',
         'jsdoc/require-returns-description': 'off',
    -    'jsdoc/valid-types': 'off',
         'jsdoc/no-undefined-types': 'off',
         'jsdoc/require-param': 'off',
         'jsdoc/check-tag-names': 'off',
    Index: lib/internal/per_context/primordials.js
    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    ===================================================================
    diff --git a/lib/internal/per_context/primordials.js b/lib/internal/per_context/primordials.js
    --- a/lib/internal/per_context/primordials.js	(revision 77d5f62cf9c9dac6ae1f20866503d7a6a6488e0d)
    +++ b/lib/internal/per_context/primordials.js	(date 1652028435041)
    @@ -411,7 +411,7 @@
      * rejected). The resolved value cannot be modified from the callback.
      * Prefer using async functions when possible.
      * @param {Promise<any>} thisPromise
    - * @param {() => void) | undefined | null} onFinally The callback to execute
    + * @param {(() => void) | undefined | null} onFinally The callback to execute
      *        when the Promise is settled (fulfilled or rejected).
      * @returns {Promise} A Promise for the completion of the callback.
      */
    Index: lib/fs.js
    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    ===================================================================
    diff --git a/lib/fs.js b/lib/fs.js
    --- a/lib/fs.js	(revision 77d5f62cf9c9dac6ae1f20866503d7a6a6488e0d)
    +++ b/lib/fs.js	(date 1652028722022)
    @@ -742,7 +742,7 @@
      * @param {(
      *   err?: Error,
      *   bytesRead?: number,
    - *   buffers?: ArrayBufferView[];
    + *   buffers?: ArrayBufferView[]
      *   ) => any} callback
      * @returns {void}
      */
    @@ -799,7 +799,7 @@
      * @param {number} [position]
      * @param {(
      *   err?: Error,
    - *   bytesWritten?: number;
    + *   bytesWritten?: number,
      *   buffer?: Buffer | TypedArray | DataView
      *   ) => any} callback
      * @returns {void}
    @@ -1369,7 +1369,7 @@
      *   }} [options]
      * @param {(
      *   err?: Error,
    - *   files?: string[] | Buffer[] | Direct[];
    + *   files?: string[] | Buffer[] | Direct[]
      *   ) => any} callback
      * @returns {void}
      */
    Index: lib/querystring.js
    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    ===================================================================
    diff --git a/lib/querystring.js b/lib/querystring.js
    --- a/lib/querystring.js	(revision 77d5f62cf9c9dac6ae1f20866503d7a6a6488e0d)
    +++ b/lib/querystring.js	(date 1652028458634)
    @@ -310,8 +310,8 @@
      * @param {string} sep
      * @param {string} eq
      * @param {{
    - *   maxKeys?: number;
    - *   decodeURIComponent?(v: string): string;
    + *   maxKeys?: number,
    + *   decodeURIComponent?(v: string): string,
      *   }} [options]
      * @returns {Record<string, string | string[]>}
      */
    Index: lib/events.js
    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    ===================================================================
    diff --git a/lib/events.js b/lib/events.js
    --- a/lib/events.js	(revision 77d5f62cf9c9dac6ae1f20866503d7a6a6488e0d)
    +++ b/lib/events.js	(date 1652028152308)
    @@ -147,7 +147,7 @@
             }
     
             /**
    -         * @param {symbol,string} event
    +         * @param {symbol|string} event
              * @param  {...any} args
              * @returns {boolean}
              */
    @@ -203,7 +203,7 @@
     /**
      * Creates a new `EventEmitter` instance.
      * @param {{ captureRejections?: boolean; }} [opts]
    - * @constructs {EventEmitter}
    + * @constructs
      */
     function EventEmitter(opts) {
       EventEmitter.init.call(this, opts);
  3. himself65 commented on May 11, 2022

    @himself65
    MemberAuthor

    the upstream package can not handle object parsing correctly

    I would block this until these are fixed.

    Refs:
    jsdoc-type-pratt-parser/jsdoc-type-pratt-parser#101
    jsdoc-type-pratt-parser/jsdoc-type-pratt-parser#131

  4. added
    blockedPRs that are blocked by other issues or PRs.
    on May 11, 2022
  5. moved this to Pending Triage in Node.js feature requestson Oct 22, 2022
  6. github-actions commented on Nov 8, 2022

    @github-actions
    Contributor

    There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.

    For more information on how the project manages feature requests, please consult the feature request management document.

  7. added
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Nov 8, 2022
  8. github-actions commented on Dec 9, 2022

    @github-actions
    Contributor

    There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment.

    For more information on how the project manages feature requests, please consult the feature request management document.

  9. moved this from Pending Triage to Stale in Node.js feature requestson Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockedPRs that are blocked by other issues or PRs.feature requestIssues requesting new Node.js features.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.typingsIssues and PRs related to internal TypeScript declarations.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions