eslint-plugin-jsdoc 39.7.3 → 39.7.5

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/README.md CHANGED
@@ -10981,7 +10981,7 @@ The following patterns are considered problems:
10981
10981
  function quux () {
10982
10982
 
10983
10983
  }
10984
- // Message: Sentence should start with an uppercase character.
10984
+ // Message: Sentences should start with an uppercase character.
10985
10985
 
10986
10986
  /**
10987
10987
  * foo?
@@ -10989,7 +10989,7 @@ function quux () {
10989
10989
  function quux () {
10990
10990
 
10991
10991
  }
10992
- // Message: Sentence should start with an uppercase character.
10992
+ // Message: Sentences should start with an uppercase character.
10993
10993
 
10994
10994
  /**
10995
10995
  * @description foo.
@@ -10997,7 +10997,7 @@ function quux () {
10997
10997
  function quux () {
10998
10998
 
10999
10999
  }
11000
- // Message: Sentence should start with an uppercase character.
11000
+ // Message: Sentences should start with an uppercase character.
11001
11001
 
11002
11002
  /**
11003
11003
  * Foo)
@@ -11005,7 +11005,7 @@ function quux () {
11005
11005
  function quux () {
11006
11006
 
11007
11007
  }
11008
- // Message: Sentence must end with a period.
11008
+ // Message: Sentences must end with a period.
11009
11009
 
11010
11010
  /**
11011
11011
  * `foo` is a variable
@@ -11013,7 +11013,7 @@ function quux () {
11013
11013
  function quux () {
11014
11014
 
11015
11015
  }
11016
- // Message: Sentence must end with a period.
11016
+ // Message: Sentences must end with a period.
11017
11017
 
11018
11018
  /**
11019
11019
  * Foo.
@@ -11023,7 +11023,7 @@ function quux () {
11023
11023
  function quux () {
11024
11024
 
11025
11025
  }
11026
- // Message: Sentence should start with an uppercase character.
11026
+ // Message: Sentences should start with an uppercase character.
11027
11027
 
11028
11028
  /**
11029
11029
  * тест.
@@ -11031,7 +11031,7 @@ function quux () {
11031
11031
  function quux () {
11032
11032
 
11033
11033
  }
11034
- // Message: Sentence should start with an uppercase character.
11034
+ // Message: Sentences should start with an uppercase character.
11035
11035
 
11036
11036
  /**
11037
11037
  * Foo
@@ -11039,7 +11039,7 @@ function quux () {
11039
11039
  function quux () {
11040
11040
 
11041
11041
  }
11042
- // Message: Sentence must end with a period.
11042
+ // Message: Sentences must end with a period.
11043
11043
 
11044
11044
  /**
11045
11045
  * Foo
@@ -11049,7 +11049,7 @@ function quux () {
11049
11049
  function quux () {
11050
11050
 
11051
11051
  }
11052
- // Message: Sentence must end with a period.
11052
+ // Message: Sentences must end with a period.
11053
11053
 
11054
11054
  /**
11055
11055
  * Foo
@@ -11059,7 +11059,7 @@ function quux () {
11059
11059
 
11060
11060
  }
11061
11061
  // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"newlineBeforeCapsAssumesBadSentenceEnd":true}]
11062
- // Message: A line of text is started with an uppercase character, but preceding line does not end the sentence.
11062
+ // Message: A line of text is started with an uppercase character, but the preceding line does not end the sentence.
11063
11063
 
11064
11064
  /**
11065
11065
  * Foo.
@@ -11069,7 +11069,7 @@ function quux () {
11069
11069
  function quux (foo) {
11070
11070
 
11071
11071
  }
11072
- // Message: Sentence should start with an uppercase character.
11072
+ // Message: Sentences should start with an uppercase character.
11073
11073
 
11074
11074
  /**
11075
11075
  * Foo.
@@ -11079,7 +11079,7 @@ function quux (foo) {
11079
11079
  function quux (foo) {
11080
11080
 
11081
11081
  }
11082
- // Message: Sentence should start with an uppercase character.
11082
+ // Message: Sentences should start with an uppercase character.
11083
11083
 
11084
11084
  /**
11085
11085
  * {@see Foo.bar} buz
@@ -11087,7 +11087,7 @@ function quux (foo) {
11087
11087
  function quux (foo) {
11088
11088
 
11089
11089
  }
11090
- // Message: Sentence should start with an uppercase character.
11090
+ // Message: Sentences should start with an uppercase character.
11091
11091
 
11092
11092
  /**
11093
11093
  * Foo.
@@ -11097,7 +11097,7 @@ function quux (foo) {
11097
11097
  function quux (foo) {
11098
11098
 
11099
11099
  }
11100
- // Message: Sentence should start with an uppercase character.
11100
+ // Message: Sentences should start with an uppercase character.
11101
11101
 
11102
11102
  /**
11103
11103
  * Foo.
@@ -11107,7 +11107,7 @@ function quux (foo) {
11107
11107
  function quux (foo) {
11108
11108
 
11109
11109
  }
11110
- // Message: Sentence should start with an uppercase character.
11110
+ // Message: Sentences should start with an uppercase character.
11111
11111
 
11112
11112
  /**
11113
11113
  * lorem ipsum dolor sit amet, consectetur adipiscing elit. pellentesque elit diam,
@@ -11120,7 +11120,7 @@ function quux (foo) {
11120
11120
  function longDescription (foo) {
11121
11121
 
11122
11122
  }
11123
- // Message: Sentence should start with an uppercase character.
11123
+ // Message: Sentences should start with an uppercase character.
11124
11124
 
11125
11125
  /**
11126
11126
  * @arg {number} foo - Foo
@@ -11128,7 +11128,7 @@ function longDescription (foo) {
11128
11128
  function quux (foo) {
11129
11129
 
11130
11130
  }
11131
- // Message: Sentence must end with a period.
11131
+ // Message: Sentences must end with a period.
11132
11132
 
11133
11133
  /**
11134
11134
  * @argument {number} foo - Foo
@@ -11136,7 +11136,7 @@ function quux (foo) {
11136
11136
  function quux (foo) {
11137
11137
 
11138
11138
  }
11139
- // Message: Sentence must end with a period.
11139
+ // Message: Sentences must end with a period.
11140
11140
 
11141
11141
  /**
11142
11142
  * @return {number} foo
@@ -11144,7 +11144,7 @@ function quux (foo) {
11144
11144
  function quux (foo) {
11145
11145
 
11146
11146
  }
11147
- // Message: Sentence should start with an uppercase character.
11147
+ // Message: Sentences should start with an uppercase character.
11148
11148
 
11149
11149
  /**
11150
11150
  * Returns bar.
@@ -11154,13 +11154,13 @@ function quux (foo) {
11154
11154
  function quux (foo) {
11155
11155
 
11156
11156
  }
11157
- // Message: Sentence should start with an uppercase character.
11157
+ // Message: Sentences should start with an uppercase character.
11158
11158
 
11159
11159
  /**
11160
11160
  * @throws {object} Hello World
11161
11161
  * hello world
11162
11162
  */
11163
- // Message: Sentence must end with a period.
11163
+ // Message: Sentences must end with a period.
11164
11164
 
11165
11165
  /**
11166
11166
  * @summary Foo
@@ -11168,7 +11168,7 @@ function quux (foo) {
11168
11168
  function quux () {
11169
11169
 
11170
11170
  }
11171
- // Message: Sentence must end with a period.
11171
+ // Message: Sentences must end with a period.
11172
11172
 
11173
11173
  /**
11174
11174
  * @throws {SomeType} Foo
@@ -11176,7 +11176,7 @@ function quux () {
11176
11176
  function quux () {
11177
11177
 
11178
11178
  }
11179
- // Message: Sentence must end with a period.
11179
+ // Message: Sentences must end with a period.
11180
11180
 
11181
11181
  /**
11182
11182
  * @see Foo
@@ -11185,7 +11185,7 @@ function quux () {
11185
11185
 
11186
11186
  }
11187
11187
  // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"tags":["see"]}]
11188
- // Message: Sentence must end with a period.
11188
+ // Message: Sentences must end with a period.
11189
11189
 
11190
11190
  /**
11191
11191
  * @param foo Foo bar
@@ -11195,7 +11195,7 @@ function quux (foo) {
11195
11195
  }
11196
11196
  // Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
11197
11197
  // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"tags":["param"]}]
11198
- // Message: Sentence must end with a period.
11198
+ // Message: Sentences must end with a period.
11199
11199
 
11200
11200
  /**
11201
11201
  * Sorry, but this isn't a complete sentence, Mr.
@@ -11204,7 +11204,7 @@ function quux () {
11204
11204
 
11205
11205
  }
11206
11206
  // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"abbreviations":["Mr"]}]
11207
- // Message: Sentence must end with a period.
11207
+ // Message: Sentences must end with a period.
11208
11208
 
11209
11209
  /**
11210
11210
  * Sorry, but this isn't a complete sentence Mr.
@@ -11213,7 +11213,7 @@ function quux () {
11213
11213
 
11214
11214
  }
11215
11215
  // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"abbreviations":["Mr."]}]
11216
- // Message: Sentence must end with a period.
11216
+ // Message: Sentences must end with a period.
11217
11217
 
11218
11218
  /**
11219
11219
  * Sorry, but this isn't a complete sentence Mr.
@@ -11222,7 +11222,7 @@ function quux () {
11222
11222
 
11223
11223
  }
11224
11224
  // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"abbreviations":["Mr"]}]
11225
- // Message: Sentence must end with a period.
11225
+ // Message: Sentences must end with a period.
11226
11226
 
11227
11227
  /**
11228
11228
  * Sorry, but this isn't a complete sentence Mr. and Mrs.
@@ -11231,7 +11231,7 @@ function quux () {
11231
11231
 
11232
11232
  }
11233
11233
  // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"abbreviations":["Mr","Mrs"]}]
11234
- // Message: Sentence must end with a period.
11234
+ // Message: Sentences must end with a period.
11235
11235
 
11236
11236
  /**
11237
11237
  * This is a complete sentence. But this isn't, Mr.
@@ -11240,7 +11240,7 @@ function quux () {
11240
11240
 
11241
11241
  }
11242
11242
  // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"abbreviations":["Mr"]}]
11243
- // Message: Sentence must end with a period.
11243
+ // Message: Sentences must end with a period.
11244
11244
 
11245
11245
  /**
11246
11246
  * This is a complete Mr. sentence. But this isn't, Mr.
@@ -11249,7 +11249,7 @@ function quux () {
11249
11249
 
11250
11250
  }
11251
11251
  // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"abbreviations":["Mr"]}]
11252
- // Message: Sentence must end with a period.
11252
+ // Message: Sentences must end with a period.
11253
11253
 
11254
11254
  /**
11255
11255
  * This is a complete Mr. sentence.
@@ -11257,7 +11257,7 @@ function quux () {
11257
11257
  function quux () {
11258
11258
 
11259
11259
  }
11260
- // Message: Sentence should start with an uppercase character.
11260
+ // Message: Sentences should start with an uppercase character.
11261
11261
 
11262
11262
  /**
11263
11263
  * This is fun, i.e. enjoyable, but not superlatively so, e.g. not
@@ -11266,7 +11266,7 @@ function quux () {
11266
11266
  function quux () {
11267
11267
 
11268
11268
  }
11269
- // Message: Sentence should start with an uppercase character.
11269
+ // Message: Sentences should start with an uppercase character.
11270
11270
 
11271
11271
  /**
11272
11272
  * Do not have dynamic content; e.g. homepage. Here a simple unique id
@@ -11275,7 +11275,7 @@ function quux () {
11275
11275
  function quux () {
11276
11276
 
11277
11277
  }
11278
- // Message: Sentence should start with an uppercase character.
11278
+ // Message: Sentences should start with an uppercase character.
11279
11279
 
11280
11280
  /**
11281
11281
  * Implements support for the
@@ -11284,7 +11284,7 @@ function quux () {
11284
11284
  function speak() {
11285
11285
  }
11286
11286
  // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"newlineBeforeCapsAssumesBadSentenceEnd":true}]
11287
- // Message: A line of text is started with an uppercase character, but preceding line does not end the sentence.
11287
+ // Message: A line of text is started with an uppercase character, but the preceding line does not end the sentence.
11288
11288
 
11289
11289
  /**
11290
11290
  * Foo.
@@ -11295,7 +11295,7 @@ function quux (foo) {
11295
11295
 
11296
11296
  }
11297
11297
  // "jsdoc/require-description-complete-sentence": ["error"|"warn", {"tags":["template"]}]
11298
- // Message: Sentence should start with an uppercase character.
11298
+ // Message: Sentences should start with an uppercase character.
11299
11299
 
11300
11300
  /**
11301
11301
  * Just a component.
@@ -11303,7 +11303,7 @@ function quux (foo) {
11303
11303
  * @return {ReactElement}.
11304
11304
  */
11305
11305
  function quux () {}
11306
- // Message: Sentence must be more than punctuation.
11306
+ // Message: Sentences must be more than punctuation.
11307
11307
  ````
11308
11308
 
11309
11309
  The following patterns are not considered problems:
@@ -11641,6 +11641,47 @@ export default (foo) => {
11641
11641
  */
11642
11642
  function quux () {
11643
11643
 
11644
+ }
11645
+
11646
+ /**
11647
+ * He wanted a few items: a jacket and shirt...
11648
+ */
11649
+ function quux () {
11650
+
11651
+ }
11652
+
11653
+ /**
11654
+ * The code in question was...
11655
+ * ```
11656
+ * alert('hello');
11657
+ * ```
11658
+ */
11659
+ function quux () {
11660
+
11661
+ }
11662
+
11663
+ /**
11664
+ * @param {number|string|Date|Object|OverType|WhateverElse} multiType -
11665
+ * Nice long explanation...
11666
+ */
11667
+ function test (multiType) {
11668
+ }
11669
+
11670
+ /**
11671
+ * Any kind of fowl (e.g., a duck).
11672
+ */
11673
+ function quux () {}
11674
+
11675
+ /**
11676
+ * The code in question was...
11677
+ * ```
11678
+ * do something
11679
+ *
11680
+ * interesting
11681
+ * ```
11682
+ */
11683
+ function quux () {
11684
+
11644
11685
  }
11645
11686
  ````
11646
11687
 
@@ -17,7 +17,6 @@ const extractParagraphs = text => {
17
17
  };
18
18
  const extractSentences = (text, abbreviationsRegex) => {
19
19
  const txt = text
20
-
21
20
  // Remove all {} tags.
22
21
  .replace(/\{[\s\S]*?\}\s*/gu, '')
23
22
 
@@ -77,7 +76,7 @@ const validateDescription = (description, reportOrig, jsdocNode, abbreviationsRe
77
76
  return $1 + capitalize(beginning);
78
77
  });
79
78
  } else {
80
- text = text.replace(new RegExp('((?:[.!?]|\\*|\\})\\s*)' + (0, _escapeStringRegexp.default)(beginning), 'u'), '$1' + capitalize(beginning));
79
+ text = text.replace(new RegExp('((?:[.?!]|\\*|\\})\\s*)' + (0, _escapeStringRegexp.default)(beginning), 'u'), '$1' + capitalize(beginning));
81
80
  }
82
81
  }
83
82
  return fixer.replaceText(jsdocNode, text);
@@ -96,20 +95,20 @@ const validateDescription = (description, reportOrig, jsdocNode, abbreviationsRe
96
95
  if (sentences.some(sentence => {
97
96
  return /^[.?!]$/u.test(sentence);
98
97
  })) {
99
- report('Sentence must be more than punctuation.', null, tag);
98
+ report('Sentences must be more than punctuation.', null, tag);
100
99
  }
101
100
  if (sentences.some(sentence => {
102
101
  return !/^\s*$/u.test(sentence) && !isCapitalized(sentence) && !isTable(sentence);
103
102
  })) {
104
- report('Sentence should start with an uppercase character.', fix, tag);
103
+ report('Sentences should start with an uppercase character.', fix, tag);
105
104
  }
106
105
  const paragraphNoAbbreviations = paragraph.replace(abbreviationsRegex, '');
107
- if (!/[.!?|]\s*$/u.test(paragraphNoAbbreviations)) {
108
- report('Sentence must end with a period.', fix, tag);
106
+ if (!/(?:[.?!|]|```)\s*$/u.test(paragraphNoAbbreviations)) {
107
+ report('Sentences must end with a period.', fix, tag);
109
108
  return true;
110
109
  }
111
110
  if (newlineBeforeCapsAssumesBadSentenceEnd && !isNewLinePrecededByAPeriod(paragraphNoAbbreviations)) {
112
- report('A line of text is started with an uppercase character, but preceding line does not end the sentence.', null, tag);
111
+ report('A line of text is started with an uppercase character, but the preceding line does not end the sentence.', null, tag);
113
112
  return true;
114
113
  }
115
114
  return false;
@@ -131,9 +130,27 @@ var _default = (0, _iterateJsdoc.default)(({
131
130
  const abbreviationsRegex = abbreviations.length ? new RegExp('\\b' + abbreviations.map(abbreviation => {
132
131
  return (0, _escapeStringRegexp.default)(abbreviation.replace(/\.$/ug, '') + '.');
133
132
  }).join('|') + '(?:$|\\s)', 'gu') : '';
134
- const {
133
+ let {
135
134
  description
136
135
  } = utils.getDescription();
136
+ const indices = [...description.matchAll(/```[\s\S]*```/gu)].map(match => {
137
+ const {
138
+ index
139
+ } = match;
140
+ const [{
141
+ length
142
+ }] = match;
143
+ return {
144
+ index,
145
+ length
146
+ };
147
+ }).reverse();
148
+ for (const {
149
+ index,
150
+ length
151
+ } of indices) {
152
+ description = description.slice(0, index) + description.slice(index + length);
153
+ }
137
154
  if (validateDescription(description, report, jsdocNode, abbreviationsRegex, sourceCode, {
138
155
  line: jsdoc.source[0].number + 1
139
156
  }, newlineBeforeCapsAssumesBadSentenceEnd)) {
@@ -1 +1 @@
1
- {"version":3,"file":"requireDescriptionCompleteSentence.js","names":["otherDescriptiveTags","Set","extractParagraphs","text","split","extractSentences","abbreviationsRegex","txt","replace","sentenceEndGrouping","puncts","matchAll","map","sentEnd","sentence","idx","test","isNewLinePrecededByAPeriod","lastLineEndsSentence","lines","some","line","isCapitalized","str","toUpperCase","isTable","charAt","capitalize","slice","validateDescription","description","reportOrig","jsdocNode","sourceCode","tag","newlineBeforeCapsAssumesBadSentenceEnd","paragraphs","filter","Boolean","paragraph","parIdx","sentences","fix","fixer","getText","pop","RegExp","escapeStringRegexp","sentence_","beginning","reg","_$0","$1","replaceText","report","msg","tagObj","source","number","column","paragraphNoAbbreviations","iterateJsdoc","context","jsdoc","utils","options","abbreviations","length","abbreviation","join","getDescription","forEachPreferredTag","matchingJsdocTag","desc","name","getTagDescription","trim","tagsWithNames","getTagsByType","tags","tagsWithoutNames","filterTags","tagName","has","hasOptionTag","trimEnd","iterateAllJsdocs","meta","docs","url","fixable","schema","additionalProperties","properties","items","type"],"sources":["../../src/rules/requireDescriptionCompleteSentence.js"],"sourcesContent":["import escapeStringRegexp from 'escape-string-regexp';\nimport iterateJsdoc from '../iterateJsdoc';\n\nconst otherDescriptiveTags = new Set([\n // 'copyright' and 'see' might be good addition, but as the former may be\n // sensitive text, and the latter may have just a link, they are not\n // included by default\n 'summary', 'file', 'fileoverview', 'overview', 'classdesc', 'todo',\n 'deprecated', 'throws', 'exception', 'yields', 'yield',\n]);\n\nconst extractParagraphs = (text) => {\n return text.split(/(?<![;:])\\n\\n/u);\n};\n\nconst extractSentences = (text, abbreviationsRegex) => {\n const txt = text\n\n // Remove all {} tags.\n .replace(/\\{[\\s\\S]*?\\}\\s*/gu, '')\n\n // Remove custom abbreviations\n .replace(abbreviationsRegex, '');\n\n const sentenceEndGrouping = /([.?!])(?:\\s+|$)/ug;\n\n const puncts = [\n ...txt.matchAll(sentenceEndGrouping),\n ].map((sentEnd) => {\n return sentEnd[0];\n });\n\n return txt\n .split(/[.?!](?:\\s+|$)/u)\n\n // Re-add the dot.\n .map((sentence, idx) => {\n return !puncts[idx] && /^\\s*$/u.test(sentence) ? sentence : `${sentence}${puncts[idx] || ''}`;\n });\n};\n\nconst isNewLinePrecededByAPeriod = (text) => {\n let lastLineEndsSentence;\n\n const lines = text.split('\\n');\n\n return !lines.some((line) => {\n if (lastLineEndsSentence === false && /^[A-Z][a-z]/u.test(line)) {\n return true;\n }\n\n lastLineEndsSentence = /[.:?!|]$/u.test(line);\n\n return false;\n });\n};\n\nconst isCapitalized = (str) => {\n return str[0] === str[0].toUpperCase();\n};\n\nconst isTable = (str) => {\n return str.charAt() === '|';\n};\n\nconst capitalize = (str) => {\n return str.charAt(0).toUpperCase() + str.slice(1);\n};\n\nconst validateDescription = (\n description, reportOrig, jsdocNode, abbreviationsRegex,\n sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd,\n) => {\n if (!description || (/^\\n+$/u).test(description)) {\n return false;\n }\n\n const paragraphs = extractParagraphs(description).filter(Boolean);\n\n return paragraphs.some((paragraph, parIdx) => {\n const sentences = extractSentences(paragraph, abbreviationsRegex);\n\n const fix = (fixer) => {\n let text = sourceCode.getText(jsdocNode);\n\n if (!/[.:?!]$/u.test(paragraph)) {\n const line = paragraph.split('\\n').filter(Boolean).pop();\n\n text = text.replace(new RegExp(`${escapeStringRegexp(line)}$`, 'mu'), `${line}.`);\n }\n\n for (const sentence of sentences.filter((sentence_) => {\n return !(/^\\s*$/u).test(sentence_) && !isCapitalized(sentence_) &&\n !isTable(sentence_);\n })) {\n const beginning = sentence.split('\\n')[0];\n\n if (tag.tag) {\n const reg = new RegExp(`(@${escapeStringRegexp(tag.tag)}.*)${escapeStringRegexp(beginning)}`, 'u');\n\n text = text.replace(reg, (_$0, $1) => {\n return $1 + capitalize(beginning);\n });\n } else {\n text = text.replace(new RegExp('((?:[.!?]|\\\\*|\\\\})\\\\s*)' + escapeStringRegexp(beginning), 'u'), '$1' + capitalize(beginning));\n }\n }\n\n return fixer.replaceText(jsdocNode, text);\n };\n\n const report = (msg, fixer, tagObj) => {\n if ('line' in tagObj) {\n tagObj.line += parIdx * 2;\n } else {\n tagObj.source[0].number += parIdx * 2;\n }\n\n // Avoid errors if old column doesn't exist here\n tagObj.column = 0;\n reportOrig(msg, fixer, tagObj);\n };\n\n if (sentences.some((sentence) => {\n return (/^[.?!]$/u).test(sentence);\n })) {\n report('Sentence must be more than punctuation.', null, tag);\n }\n\n if (sentences.some((sentence) => {\n return !(/^\\s*$/u).test(sentence) && !isCapitalized(sentence) && !isTable(sentence);\n })) {\n report('Sentence should start with an uppercase character.', fix, tag);\n }\n\n const paragraphNoAbbreviations = paragraph.replace(abbreviationsRegex, '');\n\n if (!/[.!?|]\\s*$/u.test(paragraphNoAbbreviations)) {\n report('Sentence must end with a period.', fix, tag);\n\n return true;\n }\n\n if (newlineBeforeCapsAssumesBadSentenceEnd && !isNewLinePrecededByAPeriod(paragraphNoAbbreviations)) {\n report('A line of text is started with an uppercase character, but preceding line does not end the sentence.', null, tag);\n\n return true;\n }\n\n return false;\n });\n};\n\nexport default iterateJsdoc(({\n sourceCode,\n context,\n jsdoc,\n report,\n jsdocNode,\n utils,\n}) => {\n const options = context.options[0] || {};\n const {\n abbreviations = [],\n newlineBeforeCapsAssumesBadSentenceEnd = false,\n } = options;\n\n const abbreviationsRegex = abbreviations.length ?\n new RegExp('\\\\b' + abbreviations.map((abbreviation) => {\n return escapeStringRegexp(abbreviation.replace(/\\.$/ug, '') + '.');\n }).join('|') + '(?:$|\\\\s)', 'gu') :\n '';\n\n const {\n description,\n } = utils.getDescription();\n\n if (validateDescription(description, report, jsdocNode, abbreviationsRegex, sourceCode, {\n line: jsdoc.source[0].number + 1,\n }, newlineBeforeCapsAssumesBadSentenceEnd)) {\n return;\n }\n\n utils.forEachPreferredTag('description', (matchingJsdocTag) => {\n const desc = `${matchingJsdocTag.name} ${utils.getTagDescription(matchingJsdocTag)}`.trim();\n validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, matchingJsdocTag, newlineBeforeCapsAssumesBadSentenceEnd);\n }, true);\n\n const {\n tagsWithNames,\n } = utils.getTagsByType(jsdoc.tags);\n const tagsWithoutNames = utils.filterTags(({\n tag: tagName,\n }) => {\n return otherDescriptiveTags.has(tagName) ||\n utils.hasOptionTag(tagName) && !tagsWithNames.some(({\n tag,\n }) => {\n // If user accidentally adds tags with names (or like `returns`\n // get parsed as having names), do not add to this list\n return tag === tagName;\n });\n });\n\n tagsWithNames.some((tag) => {\n const desc = utils.getTagDescription(tag).replace(/^- /u, '').trimEnd();\n\n return validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd);\n });\n\n tagsWithoutNames.some((tag) => {\n const desc = `${tag.name} ${utils.getTagDescription(tag)}`.trim();\n\n return validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd);\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Requires that block description, explicit `@description`, and `@param`/`@returns` tag descriptions are written in complete sentences.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-description-complete-sentence',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n abbreviations: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n newlineBeforeCapsAssumesBadSentenceEnd: {\n type: 'boolean',\n },\n tags: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA;AACA;AAA2C;AAE3C,MAAMA,oBAAoB,GAAG,IAAIC,GAAG,CAAC;AACnC;AACA;AACA;AACA,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAClE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,CACvD,CAAC;AAEF,MAAMC,iBAAiB,GAAIC,IAAI,IAAK;EAClC,OAAOA,IAAI,CAACC,KAAK,CAAC,gBAAgB,CAAC;AACrC,CAAC;AAED,MAAMC,gBAAgB,GAAG,CAACF,IAAI,EAAEG,kBAAkB,KAAK;EACrD,MAAMC,GAAG,GAAGJ;;EAEV;EAAA,CACCK,OAAO,CAAC,mBAAmB,EAAE,EAAE;;EAEhC;EAAA,CACCA,OAAO,CAACF,kBAAkB,EAAE,EAAE,CAAC;EAElC,MAAMG,mBAAmB,GAAG,oBAAoB;EAEhD,MAAMC,MAAM,GAAG,CACb,GAAGH,GAAG,CAACI,QAAQ,CAACF,mBAAmB,CAAC,CACrC,CAACG,GAAG,CAAEC,OAAO,IAAK;IACjB,OAAOA,OAAO,CAAC,CAAC,CAAC;EACnB,CAAC,CAAC;EAEF,OAAON,GAAG,CACPH,KAAK,CA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B,CAAC4C,IAAI,EAAEnB,MAAM,EAAEtB,SAAS,EAAE1B,kBAAkB,EAAE2B,UAAU,EAAEC,GAAG,EAAEC,sCAAsC,CAAC;EAClI,CAAC,CAAC;EAEF6C,gBAAgB,CAAC5D,IAAI,CAAEc,GAAG,IAAK;IAC7B,MAAMuC,IAAI,GAAI,GAAEvC,GAAG,CAACwC,IAAK,IAAGV,KAAK,CAACW,iBAAiB,CAACzC,GAAG,CAAE,EAAC,CAAC0C,IAAI,EAAE;IAEjE,OAAO/C,mBAAmB,CAAC4C,IAAI,EAAEnB,MAAM,EAAEtB,SAAS,EAAE1B,kBAAkB,EAAE2B,UAAU,EAAEC,GAAG,EAAEC,sCAAsC,CAAC;EAClI,CAAC,CAAC;AACJ,CAAC,EAAE;EACDmD,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJ1D,WAAW,EAAE,uIAAuI;MACpJ2D,GAAG,EAAE;IACP,CAAC;IACDC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACV3B,aAAa,EAAE;UACb4B,KAAK,EAAE;YACLC,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACD5D,sCAAsC,EAAE;UACtC4D,IAAI,EAAE;QACR,CAAC;QACDhB,IAAI,EAAE;UACJe,KAAK,EAAE;YACLC,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAA;AAAA"}
1
+ {"version":3,"file":"requireDescriptionCompleteSentence.js","names":["otherDescriptiveTags","Set","extractParagraphs","text","split","extractSentences","abbreviationsRegex","txt","replace","sentenceEndGrouping","puncts","matchAll","map","sentEnd","sentence","idx","test","isNewLinePrecededByAPeriod","lastLineEndsSentence","lines","some","line","isCapitalized","str","toUpperCase","isTable","charAt","capitalize","slice","validateDescription","description","reportOrig","jsdocNode","sourceCode","tag","newlineBeforeCapsAssumesBadSentenceEnd","paragraphs","filter","Boolean","paragraph","parIdx","sentences","fix","fixer","getText","pop","RegExp","escapeStringRegexp","sentence_","beginning","reg","_$0","$1","replaceText","report","msg","tagObj","source","number","column","paragraphNoAbbreviations","iterateJsdoc","context","jsdoc","utils","options","abbreviations","length","abbreviation","join","getDescription","indices","match","index","reverse","forEachPreferredTag","matchingJsdocTag","desc","name","getTagDescription","trim","tagsWithNames","getTagsByType","tags","tagsWithoutNames","filterTags","tagName","has","hasOptionTag","trimEnd","iterateAllJsdocs","meta","docs","url","fixable","schema","additionalProperties","properties","items","type"],"sources":["../../src/rules/requireDescriptionCompleteSentence.js"],"sourcesContent":["import escapeStringRegexp from 'escape-string-regexp';\nimport iterateJsdoc from '../iterateJsdoc';\n\nconst otherDescriptiveTags = new Set([\n // 'copyright' and 'see' might be good addition, but as the former may be\n // sensitive text, and the latter may have just a link, they are not\n // included by default\n 'summary', 'file', 'fileoverview', 'overview', 'classdesc', 'todo',\n 'deprecated', 'throws', 'exception', 'yields', 'yield',\n]);\n\nconst extractParagraphs = (text) => {\n return text.split(/(?<![;:])\\n\\n/u);\n};\n\nconst extractSentences = (text, abbreviationsRegex) => {\n const txt = text\n // Remove all {} tags.\n .replace(/\\{[\\s\\S]*?\\}\\s*/gu, '')\n\n // Remove custom abbreviations\n .replace(abbreviationsRegex, '');\n\n const sentenceEndGrouping = /([.?!])(?:\\s+|$)/ug;\n\n const puncts = [\n ...txt.matchAll(sentenceEndGrouping),\n ].map((sentEnd) => {\n return sentEnd[0];\n });\n\n return txt\n .split(/[.?!](?:\\s+|$)/u)\n\n // Re-add the dot.\n .map((sentence, idx) => {\n return !puncts[idx] && /^\\s*$/u.test(sentence) ? sentence : `${sentence}${puncts[idx] || ''}`;\n });\n};\n\nconst isNewLinePrecededByAPeriod = (text) => {\n let lastLineEndsSentence;\n\n const lines = text.split('\\n');\n\n return !lines.some((line) => {\n if (lastLineEndsSentence === false && /^[A-Z][a-z]/u.test(line)) {\n return true;\n }\n\n lastLineEndsSentence = /[.:?!|]$/u.test(line);\n\n return false;\n });\n};\n\nconst isCapitalized = (str) => {\n return str[0] === str[0].toUpperCase();\n};\n\nconst isTable = (str) => {\n return str.charAt() === '|';\n};\n\nconst capitalize = (str) => {\n return str.charAt(0).toUpperCase() + str.slice(1);\n};\n\nconst validateDescription = (\n description, reportOrig, jsdocNode, abbreviationsRegex,\n sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd,\n) => {\n if (!description || (/^\\n+$/u).test(description)) {\n return false;\n }\n\n const paragraphs = extractParagraphs(description).filter(Boolean);\n\n return paragraphs.some((paragraph, parIdx) => {\n const sentences = extractSentences(paragraph, abbreviationsRegex);\n\n const fix = (fixer) => {\n let text = sourceCode.getText(jsdocNode);\n\n if (!/[.:?!]$/u.test(paragraph)) {\n const line = paragraph.split('\\n').filter(Boolean).pop();\n\n text = text.replace(new RegExp(`${escapeStringRegexp(line)}$`, 'mu'), `${line}.`);\n }\n\n for (const sentence of sentences.filter((sentence_) => {\n return !(/^\\s*$/u).test(sentence_) && !isCapitalized(sentence_) &&\n !isTable(sentence_);\n })) {\n const beginning = sentence.split('\\n')[0];\n\n if (tag.tag) {\n const reg = new RegExp(`(@${escapeStringRegexp(tag.tag)}.*)${escapeStringRegexp(beginning)}`, 'u');\n\n text = text.replace(reg, (_$0, $1) => {\n return $1 + capitalize(beginning);\n });\n } else {\n text = text.replace(new RegExp('((?:[.?!]|\\\\*|\\\\})\\\\s*)' + escapeStringRegexp(beginning), 'u'), '$1' + capitalize(beginning));\n }\n }\n\n return fixer.replaceText(jsdocNode, text);\n };\n\n const report = (msg, fixer, tagObj) => {\n if ('line' in tagObj) {\n tagObj.line += parIdx * 2;\n } else {\n tagObj.source[0].number += parIdx * 2;\n }\n\n // Avoid errors if old column doesn't exist here\n tagObj.column = 0;\n reportOrig(msg, fixer, tagObj);\n };\n\n if (sentences.some((sentence) => {\n return (/^[.?!]$/u).test(sentence);\n })) {\n report('Sentences must be more than punctuation.', null, tag);\n }\n\n if (sentences.some((sentence) => {\n return !(/^\\s*$/u).test(sentence) && !isCapitalized(sentence) && !isTable(sentence);\n })) {\n report('Sentences should start with an uppercase character.', fix, tag);\n }\n\n const paragraphNoAbbreviations = paragraph.replace(abbreviationsRegex, '');\n\n if (!/(?:[.?!|]|```)\\s*$/u.test(paragraphNoAbbreviations)) {\n report('Sentences must end with a period.', fix, tag);\n\n return true;\n }\n\n if (newlineBeforeCapsAssumesBadSentenceEnd && !isNewLinePrecededByAPeriod(paragraphNoAbbreviations)) {\n report('A line of text is started with an uppercase character, but the preceding line does not end the sentence.', null, tag);\n\n return true;\n }\n\n return false;\n });\n};\n\nexport default iterateJsdoc(({\n sourceCode,\n context,\n jsdoc,\n report,\n jsdocNode,\n utils,\n}) => {\n const options = context.options[0] || {};\n const {\n abbreviations = [],\n newlineBeforeCapsAssumesBadSentenceEnd = false,\n } = options;\n\n const abbreviationsRegex = abbreviations.length ?\n new RegExp('\\\\b' + abbreviations.map((abbreviation) => {\n return escapeStringRegexp(abbreviation.replace(/\\.$/ug, '') + '.');\n }).join('|') + '(?:$|\\\\s)', 'gu') :\n '';\n\n let {\n description,\n } = utils.getDescription();\n\n const indices = [\n ...description.matchAll(/```[\\s\\S]*```/gu),\n ].map((match) => {\n const {\n index,\n } = match;\n const [\n {\n length,\n },\n ] = match;\n return {\n index,\n length,\n };\n }).reverse();\n\n for (const {\n index,\n length,\n } of indices) {\n description = description.slice(0, index) + description.slice(index + length);\n }\n\n if (validateDescription(description, report, jsdocNode, abbreviationsRegex, sourceCode, {\n line: jsdoc.source[0].number + 1,\n }, newlineBeforeCapsAssumesBadSentenceEnd)) {\n return;\n }\n\n utils.forEachPreferredTag('description', (matchingJsdocTag) => {\n const desc = `${matchingJsdocTag.name} ${utils.getTagDescription(matchingJsdocTag)}`.trim();\n validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, matchingJsdocTag, newlineBeforeCapsAssumesBadSentenceEnd);\n }, true);\n\n const {\n tagsWithNames,\n } = utils.getTagsByType(jsdoc.tags);\n const tagsWithoutNames = utils.filterTags(({\n tag: tagName,\n }) => {\n return otherDescriptiveTags.has(tagName) ||\n utils.hasOptionTag(tagName) && !tagsWithNames.some(({\n tag,\n }) => {\n // If user accidentally adds tags with names (or like `returns`\n // get parsed as having names), do not add to this list\n return tag === tagName;\n });\n });\n\n tagsWithNames.some((tag) => {\n const desc = utils.getTagDescription(tag).replace(/^- /u, '').trimEnd();\n\n return validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd);\n });\n\n tagsWithoutNames.some((tag) => {\n const desc = `${tag.name} ${utils.getTagDescription(tag)}`.trim();\n\n return validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd);\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Requires that block description, explicit `@description`, and `@param`/`@returns` tag descriptions are written in complete sentences.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-description-complete-sentence',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n abbreviations: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n newlineBeforeCapsAssumesBadSentenceEnd: {\n type: 'boolean',\n },\n tags: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA;AACA;AAA2C;AAE3C,MAAMA,oBAAoB,GAAG,IAAIC,GAAG,CAAC;AACnC;AACA;AACA;AACA,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAClE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,CACvD,CAAC;AAEF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,GAAI,GAAE3C,GAAG,CAAC4C,IAAK,IAAGd,KAAK,CAACe,iBAAiB,CAAC7C,GAAG,CAAE,EAAC,CAAC8C,IAAI,EAAE;IAEjE,OAAOnD,mBAAmB,CAACgD,IAAI,EAAEvB,MAAM,EAAEtB,SAAS,EAAE1B,kBAAkB,EAAE2B,UAAU,EAAEC,GAAG,EAAEC,sCAAsC,CAAC;EAClI,CAAC,CAAC;AACJ,CAAC,EAAE;EACDuD,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJ9D,WAAW,EAAE,uIAAuI;MACpJ+D,GAAG,EAAE;IACP,CAAC;IACDC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACV/B,aAAa,EAAE;UACbgC,KAAK,EAAE;YACLC,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDhE,sCAAsC,EAAE;UACtCgE,IAAI,EAAE;QACR,CAAC;QACDhB,IAAI,EAAE;UACJe,KAAK,EAAE;YACLC,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAA;AAAA"}
package/package.json CHANGED
@@ -120,5 +120,5 @@
120
120
  "test-cov": "cross-env TIMING=1 nyc --reporter text npm run test-no-cov",
121
121
  "test-index": "npm run test-no-cov -- test/rules/index.js"
122
122
  },
123
- "version": "39.7.3"
123
+ "version": "39.7.5"
124
124
  }