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

enable jsdoc/valid-types on ESLint #43019

Closed
himself65 opened this issue May 9, 2022 · 4 comments
Closed

enable jsdoc/valid-types on ESLint #43019

himself65 opened this issue May 9, 2022 · 4 comments
Labels
blocked PRs that are blocked by other issues or PRs. feature request Issues that request new features to be added to Node.js. stale typings

Comments

@himself65
Copy link
Member

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)

@himself65 himself65 added feature request Issues that request new features to be added to Node.js. typings labels May 9, 2022
@himself65
Copy link
Member Author

➜  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);

@himself65
Copy link
Member Author

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

@RaisinTen RaisinTen added the blocked PRs that are blocked by other issues or PRs. label May 11, 2022
@targos targos moved this to Pending Triage in Node.js feature requests Oct 22, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Nov 8, 2022

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.

@github-actions github-actions bot added the stale label Nov 8, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Dec 9, 2022

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.

@github-actions github-actions bot closed this as completed Dec 9, 2022
@targos targos moved this from Pending Triage to Stale in Node.js feature requests Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked PRs that are blocked by other issues or PRs. feature request Issues that request new features to be added to Node.js. stale typings
Projects
None yet
Development

No branches or pull requests

2 participants