eslint-plugin-jsdoc 64.5.3 → 64.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -163,5 +163,5 @@
163
163
  "test-cov": "TIMING=1 c8 --reporter text pnpm run test-no-cov",
164
164
  "test-index": "pnpm run test-no-cov test/rules/index.js"
165
165
  },
166
- "version": "64.5.3"
166
+ "version": "64.5.4"
167
167
  }
@@ -10,24 +10,11 @@ let warned = false;
10
10
  /** @type {any} */
11
11
  let ts;
12
12
 
13
+ let tsAttempted = false;
14
+
13
15
  // 1. Create a require function bound to the current file's URL
14
16
  const require = createRequire(import.meta.url);
15
17
 
16
- try {
17
- // 2. Attempt to import the package synchronously
18
- ts = require('typescript');
19
- /* c8 ignore next 10 -- Guard */
20
- } catch (error) {
21
- // 3. Fall back gracefully if it is not installed
22
- if (/** @type {{code?: string}} */ (error).code !== 'MODULE_NOT_FOUND') {
23
- // Re-throw if it's a different error (e.g., syntax error inside the package)
24
- throw error;
25
- }
26
-
27
- // eslint-disable-next-line no-console -- Warning user
28
- console.warn('⚠️ typescript is not installed. `jsdoc/no-unnecessary-type-assertion` will not work. To disable this warning, you must disable the rule.');
29
- }
30
-
31
18
  // Helper to check for standard literals and boolean/enum/template literals
32
19
  /**
33
20
  * @param {any} type The type is `ts.Type`
@@ -70,9 +57,30 @@ export default iterateJsdoc(({
70
57
  utils,
71
58
  // eslint-disable-next-line complexity -- Numerous type/option permutations
72
59
  }) => {
73
- /* c8 ignore next 4 -- Guard */
74
60
  // Already handled
75
61
  if (!ts) {
62
+ /* c8 ignore next 3 -- Guard (only reachable if `typescript` failed to load on a prior call) */
63
+ if (tsAttempted) {
64
+ return;
65
+ }
66
+
67
+ try {
68
+ // 2. Attempt to import the package synchronously
69
+ ts = require('typescript');
70
+ /* c8 ignore next 10 -- Guard */
71
+ } catch (error) {
72
+ // 3. Fall back gracefully if it is not installed
73
+ if (/** @type {{code?: string}} */ (error).code !== 'MODULE_NOT_FOUND') {
74
+ // Re-throw if it's a different error (e.g., syntax error inside the package)
75
+ throw error;
76
+ }
77
+
78
+ // eslint-disable-next-line no-console -- Warning user
79
+ console.warn('⚠️ typescript is not installed. `jsdoc/no-unnecessary-type-assertion` will not work. To disable this warning, you must disable the rule.');
80
+ } finally {
81
+ tsAttempted = true;
82
+ }
83
+
76
84
  return;
77
85
  }
78
86