eslint-plugin-jsdoc 51.4.1 → 52.0.1

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.
Files changed (99) hide show
  1. package/dist/alignTransform.cjs +1 -1
  2. package/dist/alignTransform.cjs.map +1 -1
  3. package/dist/generateRule.cjs +5 -5
  4. package/dist/generateRule.cjs.map +1 -1
  5. package/dist/getJsdocProcessorPlugin.cjs +8 -8
  6. package/dist/getJsdocProcessorPlugin.cjs.map +1 -1
  7. package/dist/getJsdocProcessorPlugin.d.ts +92 -0
  8. package/dist/getJsdocProcessorPlugin.d.ts.map +1 -0
  9. package/dist/iterateJsdoc.cjs +3 -3
  10. package/dist/iterateJsdoc.cjs.map +1 -1
  11. package/dist/iterateJsdoc.d.ts +462 -0
  12. package/dist/iterateJsdoc.d.ts.map +1 -0
  13. package/dist/jsdocUtils.cjs +9 -9
  14. package/dist/jsdocUtils.cjs.map +1 -1
  15. package/dist/rules/checkAlignment.cjs +1 -1
  16. package/dist/rules/checkAlignment.cjs.map +1 -1
  17. package/dist/rules/checkExamples.cjs +5 -5
  18. package/dist/rules/checkExamples.cjs.map +1 -1
  19. package/dist/rules/checkIndentation.cjs +6 -6
  20. package/dist/rules/checkIndentation.cjs.map +1 -1
  21. package/dist/rules/checkLineAlignment.cjs +3 -3
  22. package/dist/rules/checkLineAlignment.cjs.map +1 -1
  23. package/dist/rules/checkTagNames.cjs +1 -1
  24. package/dist/rules/checkTagNames.cjs.map +1 -1
  25. package/dist/rules/checkTemplateNames.cjs +1 -1
  26. package/dist/rules/checkTemplateNames.cjs.map +1 -1
  27. package/dist/rules/checkTypes.cjs +2 -2
  28. package/dist/rules/checkTypes.cjs.map +1 -1
  29. package/dist/rules/checkValues.cjs +1 -1
  30. package/dist/rules/checkValues.cjs.map +1 -1
  31. package/dist/rules/emptyTags.cjs +1 -1
  32. package/dist/rules/emptyTags.cjs.map +1 -1
  33. package/dist/rules/importsAsDependencies.cjs +2 -2
  34. package/dist/rules/importsAsDependencies.cjs.map +1 -1
  35. package/dist/rules/linesBeforeBlock.cjs +1 -1
  36. package/dist/rules/linesBeforeBlock.cjs.map +1 -1
  37. package/dist/rules/matchDescription.cjs +4 -4
  38. package/dist/rules/matchDescription.cjs.map +1 -1
  39. package/dist/rules/matchName.cjs +1 -1
  40. package/dist/rules/matchName.cjs.map +1 -1
  41. package/dist/rules/noBadBlocks.cjs +2 -2
  42. package/dist/rules/noBadBlocks.cjs.map +1 -1
  43. package/dist/rules/noBlankBlockDescriptions.cjs +2 -2
  44. package/dist/rules/noBlankBlockDescriptions.cjs.map +1 -1
  45. package/dist/rules/noDefaults.cjs +2 -2
  46. package/dist/rules/noDefaults.cjs.map +1 -1
  47. package/dist/rules/noMultiAsterisks.cjs +6 -6
  48. package/dist/rules/noMultiAsterisks.cjs.map +1 -1
  49. package/dist/rules/noUndefinedTypes.cjs +4 -4
  50. package/dist/rules/noUndefinedTypes.cjs.map +1 -1
  51. package/dist/rules/requireDescriptionCompleteSentence.cjs +21 -21
  52. package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -1
  53. package/dist/rules/requireHyphenBeforeParamDescription.cjs +3 -3
  54. package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -1
  55. package/dist/rules/requireJsdoc.cjs +1 -1
  56. package/dist/rules/requireJsdoc.cjs.map +1 -1
  57. package/dist/rules/requireReturnsCheck.cjs +1 -1
  58. package/dist/rules/requireReturnsCheck.cjs.map +1 -1
  59. package/dist/rules/requireTemplate.cjs +2 -2
  60. package/dist/rules/requireTemplate.cjs.map +1 -1
  61. package/dist/rules/tagLines.cjs +2 -2
  62. package/dist/rules/tagLines.cjs.map +1 -1
  63. package/dist/rules/textEscaping.cjs +4 -4
  64. package/dist/rules/textEscaping.cjs.map +1 -1
  65. package/dist/rules/validTypes.cjs +1 -1
  66. package/dist/rules/validTypes.cjs.map +1 -1
  67. package/package.json +1 -1
  68. package/src/alignTransform.js +1 -1
  69. package/src/getJsdocProcessorPlugin.js +8 -8
  70. package/src/iterateJsdoc.js +3 -3
  71. package/src/jsdocUtils.js +9 -9
  72. package/src/rules/checkAlignment.js +1 -1
  73. package/src/rules/checkExamples.js +5 -5
  74. package/src/rules/checkIndentation.js +6 -6
  75. package/src/rules/checkLineAlignment.js +3 -3
  76. package/src/rules/checkTagNames.js +1 -1
  77. package/src/rules/checkTemplateNames.js +1 -1
  78. package/src/rules/checkTypes.js +2 -2
  79. package/src/rules/checkValues.js +1 -1
  80. package/src/rules/emptyTags.js +1 -1
  81. package/src/rules/importsAsDependencies.js +2 -2
  82. package/src/rules/linesBeforeBlock.js +1 -1
  83. package/src/rules/matchDescription.js +4 -4
  84. package/src/rules/matchName.js +1 -1
  85. package/src/rules/noBadBlocks.js +2 -2
  86. package/src/rules/noBlankBlockDescriptions.js +2 -2
  87. package/src/rules/noDefaults.js +2 -2
  88. package/src/rules/noMultiAsterisks.js +6 -6
  89. package/src/rules/noUndefinedTypes.js +4 -4
  90. package/src/rules/requireDescriptionCompleteSentence.js +21 -21
  91. package/src/rules/requireHyphenBeforeParamDescription.js +3 -3
  92. package/src/rules/requireJsdoc.js +1 -1
  93. package/src/rules/requireReturnsCheck.js +1 -1
  94. package/src/rules/requireTemplate.js +2 -2
  95. package/src/rules/tagLines.js +2 -2
  96. package/src/rules/textEscaping.js +4 -4
  97. package/src/rules/validTypes.js +1 -1
  98. package/eslint.config.js +0 -86
  99. package/pnpm-workspace.yaml +0 -3
@@ -14,7 +14,7 @@ const otherDescriptiveTags = new Set([
14
14
  * @returns {string[]}
15
15
  */
16
16
  const extractParagraphs = (text) => {
17
- return text.split(/(?<![;:])\n\n+/u);
17
+ return text.split(/(?<![;:])\n\n+/v);
18
18
  };
19
19
 
20
20
  /**
@@ -25,12 +25,12 @@ const extractParagraphs = (text) => {
25
25
  const extractSentences = (text, abbreviationsRegex) => {
26
26
  const txt = text
27
27
  // Remove all {} tags.
28
- .replaceAll(/(?<!^)\{[\s\S]*?\}\s*/gu, '')
28
+ .replaceAll(/(?<!^)\{[\s\S]*?\}\s*/gv, '')
29
29
 
30
30
  // Remove custom abbreviations
31
31
  .replace(abbreviationsRegex, '');
32
32
 
33
- const sentenceEndGrouping = /([.?!])(?:\s+|$)/ug;
33
+ const sentenceEndGrouping = /([.?!])(?:\s+|$)/gv;
34
34
 
35
35
  const puncts = [
36
36
  ...txt.matchAll(sentenceEndGrouping),
@@ -39,11 +39,11 @@ const extractSentences = (text, abbreviationsRegex) => {
39
39
  });
40
40
 
41
41
  return txt
42
- .split(/[.?!](?:\s+|$)/u)
42
+ .split(/[.?!](?:\s+|$)/v)
43
43
 
44
44
  // Re-add the dot.
45
45
  .map((sentence, idx) => {
46
- return !puncts[idx] && /^\s*$/u.test(sentence) ? sentence : `${sentence}${puncts[idx] || ''}`;
46
+ return !puncts[idx] && /^\s*$/v.test(sentence) ? sentence : `${sentence}${puncts[idx] || ''}`;
47
47
  });
48
48
  };
49
49
 
@@ -58,11 +58,11 @@ const isNewLinePrecededByAPeriod = (text) => {
58
58
  const lines = text.split('\n');
59
59
 
60
60
  return !lines.some((line) => {
61
- if (lastLineEndsSentence === false && /^[A-Z][a-z]/u.test(line)) {
61
+ if (lastLineEndsSentence === false && /^[A-Z][a-z]/v.test(line)) {
62
62
  return true;
63
63
  }
64
64
 
65
- lastLineEndsSentence = /[.:?!|]$/u.test(line);
65
+ lastLineEndsSentence = /[.:?!\|]$/v.test(line);
66
66
 
67
67
  return false;
68
68
  });
@@ -108,11 +108,11 @@ const validateDescription = (
108
108
  description, reportOrig, jsdocNode, abbreviationsRegex,
109
109
  sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd,
110
110
  ) => {
111
- if (!description || (/^\n+$/u).test(description)) {
111
+ if (!description || (/^\n+$/v).test(description)) {
112
112
  return false;
113
113
  }
114
114
 
115
- const descriptionNoHeadings = description.replaceAll(/^\s*#[^\n]*(\n|$)/gmu, '');
115
+ const descriptionNoHeadings = description.replaceAll(/^\s*#[^\n]*(\n|$)/gmv, '');
116
116
 
117
117
  const paragraphs = extractParagraphs(descriptionNoHeadings).filter(Boolean);
118
118
 
@@ -122,28 +122,28 @@ const validateDescription = (
122
122
  const fix = /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {
123
123
  let text = sourceCode.getText(jsdocNode);
124
124
 
125
- if (!/[.:?!]$/u.test(paragraph)) {
125
+ if (!/[.:?!]$/v.test(paragraph)) {
126
126
  const line = paragraph.split('\n').findLast(Boolean);
127
127
  text = text.replace(new RegExp(`${escapeStringRegexp(
128
128
  /** @type {string} */
129
129
  (line),
130
- )}$`, 'mu'), `${line}.`);
130
+ )}$`, 'mv'), `${line}.`);
131
131
  }
132
132
 
133
133
  for (const sentence of sentences.filter((sentence_) => {
134
- return !(/^\s*$/u).test(sentence_) && !isCapitalized(sentence_) &&
134
+ return !(/^\s*$/v).test(sentence_) && !isCapitalized(sentence_) &&
135
135
  !isTable(sentence_);
136
136
  })) {
137
137
  const beginning = sentence.split('\n')[0];
138
138
 
139
139
  if ('tag' in tag && tag.tag) {
140
- const reg = new RegExp(`(@${escapeStringRegexp(tag.tag)}.*)${escapeStringRegexp(beginning)}`, 'u');
140
+ const reg = new RegExp(`(@${escapeStringRegexp(tag.tag)}.*)${escapeStringRegexp(beginning)}`, 'v');
141
141
 
142
142
  text = text.replace(reg, (_$0, $1) => {
143
143
  return $1 + capitalize(beginning);
144
144
  });
145
145
  } else {
146
- text = text.replace(new RegExp('((?:[.?!]|\\*|\\})\\s*)' + escapeStringRegexp(beginning), 'u'), '$1' + capitalize(beginning));
146
+ text = text.replace(new RegExp('((?:[.?!]|\\*|\\})\\s*)' + escapeStringRegexp(beginning), 'v'), '$1' + capitalize(beginning));
147
147
  }
148
148
  }
149
149
 
@@ -181,20 +181,20 @@ const validateDescription = (
181
181
  };
182
182
 
183
183
  if (sentences.some((sentence) => {
184
- return (/^[.?!]$/u).test(sentence);
184
+ return (/^[.?!]$/v).test(sentence);
185
185
  })) {
186
186
  report('Sentences must be more than punctuation.', null, tag);
187
187
  }
188
188
 
189
189
  if (sentences.some((sentence) => {
190
- return !(/^\s*$/u).test(sentence) && !isCapitalized(sentence) && !isTable(sentence);
190
+ return !(/^\s*$/v).test(sentence) && !isCapitalized(sentence) && !isTable(sentence);
191
191
  })) {
192
192
  report('Sentences should start with an uppercase character.', fix, tag);
193
193
  }
194
194
 
195
195
  const paragraphNoAbbreviations = paragraph.replace(abbreviationsRegex, '');
196
196
 
197
- if (!/(?:[.?!|]|```)\s*$/u.test(paragraphNoAbbreviations)) {
197
+ if (!/(?:[.?!\|]|```)\s*$/v.test(paragraphNoAbbreviations)) {
198
198
  report('Sentences must end with a period.', fix, tag);
199
199
  return true;
200
200
  }
@@ -224,8 +224,8 @@ export default iterateJsdoc(({
224
224
 
225
225
  const abbreviationsRegex = abbreviations.length ?
226
226
  new RegExp('\\b' + abbreviations.map((abbreviation) => {
227
- return escapeStringRegexp(abbreviation.replaceAll(/\.$/ug, '') + '.');
228
- }).join('|') + '(?:$|\\s)', 'gu') :
227
+ return escapeStringRegexp(abbreviation.replaceAll(/\.$/gv, '') + '.');
228
+ }).join('|') + '(?:$|\\s)', 'gv') :
229
229
  '';
230
230
 
231
231
  let {
@@ -233,7 +233,7 @@ export default iterateJsdoc(({
233
233
  } = utils.getDescription();
234
234
 
235
235
  const indices = [
236
- ...description.matchAll(/```[\s\S]*```/gu),
236
+ ...description.matchAll(/```[\s\S]*```/gv),
237
237
  ].map((match) => {
238
238
  const {
239
239
  index,
@@ -289,7 +289,7 @@ export default iterateJsdoc(({
289
289
  tagsWithNames.some((tag) => {
290
290
  const desc = /** @type {string} */ (
291
291
  utils.getTagDescription(tag)
292
- ).replace(/^- /u, '').trimEnd();
292
+ ).replace(/^- /v, '').trimEnd();
293
293
 
294
294
  return validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd);
295
295
  });
@@ -29,7 +29,7 @@ export default iterateJsdoc(({
29
29
  return;
30
30
  }
31
31
 
32
- const startsWithHyphen = (/^\s*-/u).test(desc);
32
+ const startsWithHyphen = (/^\s*-/v).test(desc);
33
33
  let lines = 0;
34
34
  for (const {
35
35
  tokens,
@@ -54,7 +54,7 @@ export default iterateJsdoc(({
54
54
  } of jsdocTag.source) {
55
55
  if (tokens.description) {
56
56
  tokens.description = tokens.description.replace(
57
- /^(\s*)/u, '$1- ',
57
+ /^(\s*)/v, '$1- ',
58
58
  );
59
59
  break;
60
60
  }
@@ -74,7 +74,7 @@ export default iterateJsdoc(({
74
74
  } of jsdocTag.source) {
75
75
  if (tokens.description) {
76
76
  tokens.description = tokens.description.replace(
77
- /^\s*-\s*/u, '',
77
+ /^\s*-\s*/v, '',
78
78
  );
79
79
  break;
80
80
  }
@@ -444,7 +444,7 @@ export default {
444
444
  */
445
445
  const underMinLine = (count) => {
446
446
  return count !== undefined && count >
447
- (sourceCode.getText(node).match(/\n/gu)?.length ?? 0) + 1;
447
+ (sourceCode.getText(node).match(/\n/gv)?.length ?? 0) + 1;
448
448
  };
449
449
 
450
450
  if (underMinLine(minLineCount)) {
@@ -81,7 +81,7 @@ export default iterateJsdoc(({
81
81
  const type = tag.type.trim();
82
82
 
83
83
  // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions
84
- if (/asserts\s/u.test(type)) {
84
+ if (/asserts\s/v.test(type)) {
85
85
  return;
86
86
  }
87
87
 
@@ -31,7 +31,7 @@ export default iterateJsdoc(({
31
31
  const {
32
32
  name,
33
33
  } = tag;
34
- const names = name.split(/,\s*/u);
34
+ const names = name.split(/,\s*/v);
35
35
  if (names.length > 1) {
36
36
  report(`Missing separate @template for ${names[1]}`, null, tag);
37
37
  }
@@ -126,7 +126,7 @@ export default iterateJsdoc(({
126
126
  type,
127
127
  value,
128
128
  } = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde);
129
- if (type === 'JsdocTypeName' && (/^[A-Z]$/u).test(value)) {
129
+ if (type === 'JsdocTypeName' && (/^[A-Z]$/v).test(value)) {
130
130
  usedNames.add(value);
131
131
  if (!usedNameToTag.has(value)) {
132
132
  usedNameToTag.set(value, potentialTag);
@@ -228,11 +228,11 @@ export default iterateJsdoc(({
228
228
  description,
229
229
  lastDescriptionLine,
230
230
  } = utils.getDescription();
231
- if (!(/\S/u).test(description)) {
231
+ if (!(/\S/v).test(description)) {
232
232
  return;
233
233
  }
234
234
 
235
- const trailingLines = description.match(/\n+$/u)?.[0]?.length;
235
+ const trailingLines = description.match(/\n+$/v)?.[0]?.length;
236
236
  const trailingDiff = (trailingLines ?? 0) - startLines;
237
237
  if (trailingDiff > 0) {
238
238
  utils.reportJSDoc(
@@ -2,15 +2,15 @@ import iterateJsdoc from '../iterateJsdoc.js';
2
2
 
3
3
  // We could disallow raw gt, quot, and apos, but allow for parity; but we do
4
4
  // not allow hex or decimal character references
5
- const htmlRegex = /(<|&(?!(?:amp|lt|gt|quot|apos);))(?=\S)/u;
6
- const markdownRegex = /(?<!\\)(`+)([^`]+)\1(?!`)/u;
5
+ const htmlRegex = /(<|&(?!(?:amp|lt|gt|quot|apos);))(?=\S)/v;
6
+ const markdownRegex = /(?<!\\)(`+)([^`]+)\1(?!`)/v;
7
7
 
8
8
  /**
9
9
  * @param {string} desc
10
10
  * @returns {string}
11
11
  */
12
12
  const htmlReplacer = (desc) => {
13
- return desc.replaceAll(new RegExp(htmlRegex, 'gu'), (_) => {
13
+ return desc.replaceAll(new RegExp(htmlRegex, 'gv'), (_) => {
14
14
  if (_ === '<') {
15
15
  return '&lt;';
16
16
  }
@@ -24,7 +24,7 @@ const htmlReplacer = (desc) => {
24
24
  * @returns {string}
25
25
  */
26
26
  const markdownReplacer = (desc) => {
27
- return desc.replaceAll(new RegExp(markdownRegex, 'gu'), (_, backticks, encapsed) => {
27
+ return desc.replaceAll(new RegExp(markdownRegex, 'gv'), (_, backticks, encapsed) => {
28
28
  const bookend = '`'.repeat(backticks.length);
29
29
  return `\\${bookend}${encapsed}${bookend}`;
30
30
  });
@@ -17,7 +17,7 @@ const jsdocTypePrattKeywords = new Set([
17
17
  'typeof',
18
18
  ]);
19
19
 
20
- const asExpression = /as\s+/u;
20
+ const asExpression = /as\s+/v;
21
21
 
22
22
  const suppressTypes = new Set([
23
23
  // https://github.com/google/closure-compiler/wiki/@suppress-annotations
package/eslint.config.js DELETED
@@ -1,86 +0,0 @@
1
- import jsdoc from './src/index.js';
2
- import {
3
- recommended as canonical,
4
- } from 'eslint-config-canonical/canonical';
5
- import {
6
- recommended as canonicalJsdoc,
7
- } from 'eslint-config-canonical/jsdoc';
8
- import globals from 'globals';
9
-
10
- const common = {
11
- linterOptions: {
12
- reportUnusedDisableDirectives: 'off',
13
- },
14
- };
15
-
16
- export default [
17
- ...canonical,
18
- ...canonicalJsdoc,
19
- ...jsdoc.configs['examples-and-default-expressions'],
20
- {
21
- // Must be by itself
22
- ignores: [
23
- 'dist/**', '.ignore/**', '**/*.d.ts',
24
- ],
25
- },
26
- {
27
- ...common,
28
- languageOptions: {
29
- ecmaVersion: 'latest',
30
- globals: globals.node,
31
- sourceType: 'module',
32
- },
33
- rules: {
34
- '@stylistic/array-element-newline': 0,
35
- '@stylistic/no-extra-parens': 0,
36
- 'filenames/match-regex': 0,
37
- 'import/extensions': 0,
38
- 'import/no-useless-path-segments': 0,
39
- 'linebreak-style': 0,
40
- 'no-inline-comments': 0,
41
- 'prefer-named-capture-group': 0,
42
- 'unicorn/import-index': 0,
43
- 'unicorn/no-array-reduce': 0,
44
- 'unicorn/no-unsafe-regex': 0,
45
- 'unicorn/prefer-array-some': 0,
46
- 'unicorn/prevent-abbreviations': 0,
47
- },
48
- },
49
- {
50
- ...common,
51
- files: [
52
- '.ncurc.cjs',
53
- ],
54
- languageOptions: {
55
- parserOptions: {
56
- ecmaFeatures: {
57
- impliedStrict: false,
58
- },
59
- },
60
- sourceType: 'script',
61
- },
62
- rules: {
63
- 'canonical/filename-match-regex': 0,
64
- 'import/no-commonjs': 0,
65
- strict: [
66
- 'error',
67
- 'global',
68
- ],
69
- },
70
- },
71
- {
72
- ...common,
73
- files: [
74
- 'test/**/*.js',
75
- ],
76
- languageOptions: {
77
- ecmaVersion: 'latest',
78
- globals: globals.mocha,
79
- sourceType: 'module',
80
- },
81
- rules: {
82
- 'no-restricted-syntax': 0,
83
- 'unicorn/prevent-abbreviations': 0,
84
- },
85
- },
86
- ];
@@ -1,3 +0,0 @@
1
- ignoredBuiltDependencies:
2
- - core-js
3
- - core-js-pure