eslint-plugin-jsdoc 39.3.5 → 39.3.12

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 (124) hide show
  1. package/README.md +273 -52
  2. package/dist/WarnSettings.js +0 -5
  3. package/dist/WarnSettings.js.map +1 -1
  4. package/dist/alignTransform.js +69 -61
  5. package/dist/alignTransform.js.map +1 -1
  6. package/dist/bin/generateRule.js +7 -26
  7. package/dist/bin/generateRule.js.map +1 -1
  8. package/dist/defaultTagOrder.js +30 -14
  9. package/dist/defaultTagOrder.js.map +1 -1
  10. package/dist/exportParser.js +34 -143
  11. package/dist/exportParser.js.map +1 -1
  12. package/dist/generateRule.js +7 -26
  13. package/dist/generateRule.js.map +1 -1
  14. package/dist/getDefaultTagStructureForMode.js +189 -93
  15. package/dist/getDefaultTagStructureForMode.js.map +1 -1
  16. package/dist/index.js +0 -51
  17. package/dist/index.js.map +1 -1
  18. package/dist/iterateJsdoc.js +44 -207
  19. package/dist/iterateJsdoc.js.map +1 -1
  20. package/dist/jsdocUtils.js +72 -221
  21. package/dist/jsdocUtils.js.map +1 -1
  22. package/dist/rules/checkAccess.js +0 -8
  23. package/dist/rules/checkAccess.js.map +1 -1
  24. package/dist/rules/checkAlignment.js +0 -8
  25. package/dist/rules/checkAlignment.js.map +1 -1
  26. package/dist/rules/checkExamples.js +25 -63
  27. package/dist/rules/checkExamples.js.map +1 -1
  28. package/dist/rules/checkIndentation.js +0 -7
  29. package/dist/rules/checkIndentation.js.map +1 -1
  30. package/dist/rules/checkLineAlignment.js +9 -30
  31. package/dist/rules/checkLineAlignment.js.map +1 -1
  32. package/dist/rules/checkParamNames.js +9 -47
  33. package/dist/rules/checkParamNames.js.map +1 -1
  34. package/dist/rules/checkPropertyNames.js +1 -18
  35. package/dist/rules/checkPropertyNames.js.map +1 -1
  36. package/dist/rules/checkSyntax.js +2 -5
  37. package/dist/rules/checkSyntax.js.map +1 -1
  38. package/dist/rules/checkTagNames.js +0 -18
  39. package/dist/rules/checkTagNames.js.map +1 -1
  40. package/dist/rules/checkTypes.js +17 -46
  41. package/dist/rules/checkTypes.js.map +1 -1
  42. package/dist/rules/checkValues.js +0 -18
  43. package/dist/rules/checkValues.js.map +1 -1
  44. package/dist/rules/emptyTags.js +6 -11
  45. package/dist/rules/emptyTags.js.map +1 -1
  46. package/dist/rules/implementsOnClasses.js +0 -6
  47. package/dist/rules/implementsOnClasses.js.map +1 -1
  48. package/dist/rules/matchDescription.js +0 -20
  49. package/dist/rules/matchDescription.js.map +1 -1
  50. package/dist/rules/matchName.js +2 -17
  51. package/dist/rules/matchName.js.map +1 -1
  52. package/dist/rules/multilineBlocks.js +10 -34
  53. package/dist/rules/multilineBlocks.js.map +1 -1
  54. package/dist/rules/newlineAfterDescription.js +0 -8
  55. package/dist/rules/newlineAfterDescription.js.map +1 -1
  56. package/dist/rules/noBadBlocks.js +2 -16
  57. package/dist/rules/noBadBlocks.js.map +1 -1
  58. package/dist/rules/noDefaults.js +0 -7
  59. package/dist/rules/noDefaults.js.map +1 -1
  60. package/dist/rules/noMissingSyntax.js +2 -16
  61. package/dist/rules/noMissingSyntax.js.map +1 -1
  62. package/dist/rules/noMultiAsterisks.js +2 -16
  63. package/dist/rules/noMultiAsterisks.js.map +1 -1
  64. package/dist/rules/noRestrictedSyntax.js +3 -9
  65. package/dist/rules/noRestrictedSyntax.js.map +1 -1
  66. package/dist/rules/noTypes.js +0 -7
  67. package/dist/rules/noTypes.js.map +1 -1
  68. package/dist/rules/noUndefinedTypes.js +13 -34
  69. package/dist/rules/noUndefinedTypes.js.map +1 -1
  70. package/dist/rules/requireAsteriskPrefix.js +2 -26
  71. package/dist/rules/requireAsteriskPrefix.js.map +1 -1
  72. package/dist/rules/requireDescription.js +0 -17
  73. package/dist/rules/requireDescription.js.map +1 -1
  74. package/dist/rules/requireDescriptionCompleteSentence.js +13 -34
  75. package/dist/rules/requireDescriptionCompleteSentence.js.map +1 -1
  76. package/dist/rules/requireExample.js +0 -9
  77. package/dist/rules/requireExample.js.map +1 -1
  78. package/dist/rules/requireFileOverview.js +0 -16
  79. package/dist/rules/requireFileOverview.js.map +1 -1
  80. package/dist/rules/requireHyphenBeforeParamDescription.js +2 -16
  81. package/dist/rules/requireHyphenBeforeParamDescription.js.map +1 -1
  82. package/dist/rules/requireJsdoc.js +13 -58
  83. package/dist/rules/requireJsdoc.js.map +1 -1
  84. package/dist/rules/requireParam.js +6 -53
  85. package/dist/rules/requireParam.js.map +1 -1
  86. package/dist/rules/requireParamDescription.js +0 -4
  87. package/dist/rules/requireParamDescription.js.map +1 -1
  88. package/dist/rules/requireParamName.js +0 -4
  89. package/dist/rules/requireParamName.js.map +1 -1
  90. package/dist/rules/requireParamType.js +0 -4
  91. package/dist/rules/requireParamType.js.map +1 -1
  92. package/dist/rules/requireProperty.js +0 -9
  93. package/dist/rules/requireProperty.js.map +1 -1
  94. package/dist/rules/requirePropertyDescription.js +0 -4
  95. package/dist/rules/requirePropertyDescription.js.map +1 -1
  96. package/dist/rules/requirePropertyName.js +0 -4
  97. package/dist/rules/requirePropertyName.js.map +1 -1
  98. package/dist/rules/requirePropertyType.js +0 -4
  99. package/dist/rules/requirePropertyType.js.map +1 -1
  100. package/dist/rules/requireReturns.js +13 -23
  101. package/dist/rules/requireReturns.js.map +1 -1
  102. package/dist/rules/requireReturnsCheck.js +12 -20
  103. package/dist/rules/requireReturnsCheck.js.map +1 -1
  104. package/dist/rules/requireReturnsDescription.js +0 -6
  105. package/dist/rules/requireReturnsDescription.js.map +1 -1
  106. package/dist/rules/requireReturnsType.js +0 -4
  107. package/dist/rules/requireReturnsType.js.map +1 -1
  108. package/dist/rules/requireThrows.js +6 -15
  109. package/dist/rules/requireThrows.js.map +1 -1
  110. package/dist/rules/requireYields.js +13 -29
  111. package/dist/rules/requireYields.js.map +1 -1
  112. package/dist/rules/requireYieldsCheck.js +8 -29
  113. package/dist/rules/requireYieldsCheck.js.map +1 -1
  114. package/dist/rules/sortTags.js +17 -30
  115. package/dist/rules/sortTags.js.map +1 -1
  116. package/dist/rules/tagLines.js +0 -26
  117. package/dist/rules/tagLines.js.map +1 -1
  118. package/dist/rules/validTypes.js +22 -53
  119. package/dist/rules/validTypes.js.map +1 -1
  120. package/dist/tagNames.js +7 -4
  121. package/dist/tagNames.js.map +1 -1
  122. package/dist/utils/hasReturnValue.js +22 -66
  123. package/dist/utils/hasReturnValue.js.map +1 -1
  124. package/package.json +16 -16
@@ -4,32 +4,26 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _eslint = require("eslint");
9
-
10
8
  var _semver = _interopRequireDefault(require("semver"));
11
-
12
9
  var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc"));
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
11
  // Todo: When replace `CLIEngine` with `ESLint` when feature set complete per https://github.com/eslint/eslint/issues/14745
17
12
  // https://github.com/eslint/eslint/blob/master/docs/user-guide/migrating-to-7.0.0.md#-the-cliengine-class-has-been-deprecated
13
+
18
14
  const zeroBasedLineIndexAdjust = -1;
19
15
  const likelyNestedJSDocIndentSpace = 1;
20
- const preTagSpaceLength = 1; // If a space is present, we should ignore it
16
+ const preTagSpaceLength = 1;
21
17
 
18
+ // If a space is present, we should ignore it
22
19
  const firstLinePrefixLength = preTagSpaceLength;
23
20
  const hasCaptionRegex = /^\s*<caption>([\s\S]*?)<\/caption>/u;
24
-
25
21
  const escapeStringRegexp = str => {
26
22
  return str.replace(/[.*+?^${}()|[\]\\]/gu, '\\$&');
27
23
  };
28
-
29
24
  const countChars = (str, ch) => {
30
25
  return (str.match(new RegExp(escapeStringRegexp(ch), 'gu')) || []).length;
31
26
  };
32
-
33
27
  const defaultMdRules = {
34
28
  // "always" newline rule at end unlikely in sample code
35
29
  'eol-last': 0,
@@ -55,7 +49,8 @@ const defaultMdRules = {
55
49
  // Can generally look nicer to pad a little even if code imposes more stringency
56
50
  'padded-blocks': 0
57
51
  };
58
- const defaultExpressionRules = { ...defaultMdRules,
52
+ const defaultExpressionRules = {
53
+ ...defaultMdRules,
59
54
  'chai-friendly/no-unused-expressions': 'off',
60
55
  'no-empty-function': 'off',
61
56
  'no-new': 'off',
@@ -64,13 +59,11 @@ const defaultExpressionRules = { ...defaultMdRules,
64
59
  semi: ['error', 'never'],
65
60
  strict: 'off'
66
61
  };
67
-
68
62
  const getLinesCols = text => {
69
63
  const matchLines = countChars(text, '\n');
70
64
  const colDelta = matchLines ? text.slice(text.lastIndexOf('\n') + 1).length : text.length;
71
65
  return [matchLines, colDelta];
72
66
  };
73
-
74
67
  var _default = (0, _iterateJsdoc.default)(({
75
68
  report,
76
69
  utils,
@@ -84,11 +77,9 @@ var _default = (0, _iterateJsdoc.default)(({
84
77
  });
85
78
  return;
86
79
  }
87
-
88
80
  if (!globalState.has('checkExamples-matchingFileName')) {
89
81
  globalState.set('checkExamples-matchingFileName', new Map());
90
82
  }
91
-
92
83
  const matchingFileNameMap = globalState.get('checkExamples-matchingFileName');
93
84
  const options = context.options[0] || {};
94
85
  let {
@@ -111,20 +102,18 @@ var _default = (0, _iterateJsdoc.default)(({
111
102
  allowInlineConfig = true,
112
103
  reportUnusedDisableDirectives = true,
113
104
  captionRequired = false
114
- } = options; // Make this configurable?
105
+ } = options;
115
106
 
107
+ // Make this configurable?
116
108
  const rulePaths = [];
117
109
  const mdRules = noDefaultExampleRules ? undefined : defaultMdRules;
118
110
  const expressionRules = noDefaultExampleRules ? undefined : defaultExpressionRules;
119
-
120
111
  if (exampleCodeRegex) {
121
112
  exampleCodeRegex = utils.getRegexFromString(exampleCodeRegex);
122
113
  }
123
-
124
114
  if (rejectExampleCodeRegex) {
125
115
  rejectExampleCodeRegex = utils.getRegexFromString(rejectExampleCodeRegex);
126
116
  }
127
-
128
117
  const checkSource = ({
129
118
  filename,
130
119
  defaultFileName,
@@ -145,9 +134,9 @@ var _default = (0, _iterateJsdoc.default)(({
145
134
  nonJSPrefacingLines: lines,
146
135
  string: source
147
136
  });
148
- } // Todo: Make fixable
149
-
137
+ }
150
138
 
139
+ // Todo: Make fixable
151
140
  const checkRules = function ({
152
141
  nonJSPrefacingCols,
153
142
  nonJSPrefacingLines,
@@ -163,28 +152,28 @@ var _default = (0, _iterateJsdoc.default)(({
163
152
  useEslintrc: checkEslintrc
164
153
  };
165
154
  const cliConfigStr = JSON.stringify(cliConfig);
166
- const src = paddedIndent ? string.replace(new RegExp(`(^|\n) {${paddedIndent}}(?!$)`, 'gu'), '\n') : string; // Programmatic ESLint API: https://eslint.org/docs/developer-guide/nodejs-api
155
+ const src = paddedIndent ? string.replace(new RegExp(`(^|\n) {${paddedIndent}}(?!$)`, 'gu'), '\n') : string;
167
156
 
157
+ // Programmatic ESLint API: https://eslint.org/docs/developer-guide/nodejs-api
168
158
  const fileNameMapKey = filename ? 'a' + cliConfigStr + filename : 'b' + cliConfigStr + defaultFileName;
169
159
  const file = filename || defaultFileName;
170
160
  let cliFile;
171
-
172
161
  if (matchingFileNameMap.has(fileNameMapKey)) {
173
162
  cliFile = matchingFileNameMap.get(fileNameMapKey);
174
163
  } else {
175
164
  const cli = new _eslint.CLIEngine(cliConfig);
176
165
  let config;
177
-
178
166
  if (filename || checkEslintrc) {
179
167
  config = cli.getConfigForFile(file);
180
- } // We need a new instance to ensure that the rules that may only
168
+ }
169
+
170
+ // We need a new instance to ensure that the rules that may only
181
171
  // be available to `file` (if it has its own `.eslintrc`),
182
172
  // will be defined.
183
-
184
-
185
173
  cliFile = new _eslint.CLIEngine({
186
174
  allowInlineConfig,
187
- baseConfig: { ...baseConfig,
175
+ baseConfig: {
176
+ ...baseConfig,
188
177
  ...config
189
178
  },
190
179
  configFile,
@@ -195,21 +184,18 @@ var _default = (0, _iterateJsdoc.default)(({
195
184
  });
196
185
  matchingFileNameMap.set(fileNameMapKey, cliFile);
197
186
  }
198
-
199
187
  const {
200
188
  results: [{
201
189
  messages
202
190
  }]
203
191
  } = cliFile.executeOnText(src);
204
-
205
192
  if (!('line' in tag)) {
206
193
  tag.line = tag.source[0].number;
207
- } // NOTE: `tag.line` can be 0 if of form `/** @tag ... */`
208
-
194
+ }
209
195
 
196
+ // NOTE: `tag.line` can be 0 if of form `/** @tag ... */`
210
197
  const codeStartLine = tag.line + nonJSPrefacingLines;
211
198
  const codeStartCol = likelyNestedJSDocIndentSpace;
212
-
213
199
  for (const {
214
200
  message,
215
201
  line,
@@ -218,7 +204,8 @@ var _default = (0, _iterateJsdoc.default)(({
218
204
  ruleId
219
205
  } of messages) {
220
206
  const startLine = codeStartLine + line + zeroBasedLineIndexAdjust;
221
- const startCol = codeStartCol + ( // This might not work for line 0, but line 0 is unlikely for examples
207
+ const startCol = codeStartCol + (
208
+ // This might not work for line 0, but line 0 is unlikely for examples
222
209
  line <= 1 ? nonJSPrefacingCols + firstLinePrefixLength : preTagSpaceLength) + column;
223
210
  report('@' + targetTagName + ' ' + (severity === 2 ? 'error' : 'warning') + (ruleId ? ' (' + ruleId + ')' : '') + ': ' + message, null, {
224
211
  column: startCol,
@@ -226,11 +213,11 @@ var _default = (0, _iterateJsdoc.default)(({
226
213
  });
227
214
  }
228
215
  };
229
-
230
216
  for (const targetSource of sources) {
231
217
  checkRules(targetSource);
232
218
  }
233
219
  };
220
+
234
221
  /**
235
222
  *
236
223
  * @param {string} filename
@@ -239,34 +226,27 @@ var _default = (0, _iterateJsdoc.default)(({
239
226
  * Formerly "md" was the default.
240
227
  * @returns {{defaultFileName: string, fileName: string}}
241
228
  */
242
-
243
-
244
229
  const getFilenameInfo = (filename, ext = 'md/*.js') => {
245
230
  let defaultFileName;
246
-
247
231
  if (!filename) {
248
232
  const jsFileName = context.getFilename();
249
-
250
233
  if (typeof jsFileName === 'string' && jsFileName.includes('.')) {
251
234
  defaultFileName = jsFileName.replace(/\..*?$/u, `.${ext}`);
252
235
  } else {
253
236
  defaultFileName = `dummy.${ext}`;
254
237
  }
255
238
  }
256
-
257
239
  return {
258
240
  defaultFileName,
259
241
  filename
260
242
  };
261
243
  };
262
-
263
244
  if (checkDefaults) {
264
245
  const filenameInfo = getFilenameInfo(matchingFileNameDefaults, 'jsdoc-defaults');
265
246
  utils.forEachPreferredTag('default', (tag, targetTagName) => {
266
247
  if (!tag.description.trim()) {
267
248
  return;
268
249
  }
269
-
270
250
  checkSource({
271
251
  source: `(${utils.getTagDescription(tag)})`,
272
252
  targetTagName,
@@ -274,14 +254,12 @@ var _default = (0, _iterateJsdoc.default)(({
274
254
  });
275
255
  });
276
256
  }
277
-
278
257
  if (checkParams) {
279
258
  const filenameInfo = getFilenameInfo(matchingFileNameParams, 'jsdoc-params');
280
259
  utils.forEachPreferredTag('param', (tag, targetTagName) => {
281
260
  if (!tag.default || !tag.default.trim()) {
282
261
  return;
283
262
  }
284
-
285
263
  checkSource({
286
264
  source: `(${tag.default})`,
287
265
  targetTagName,
@@ -289,14 +267,12 @@ var _default = (0, _iterateJsdoc.default)(({
289
267
  });
290
268
  });
291
269
  }
292
-
293
270
  if (checkProperties) {
294
271
  const filenameInfo = getFilenameInfo(matchingFileNameProperties, 'jsdoc-properties');
295
272
  utils.forEachPreferredTag('property', (tag, targetTagName) => {
296
273
  if (!tag.default || !tag.default.trim()) {
297
274
  return;
298
275
  }
299
-
300
276
  checkSource({
301
277
  source: `(${tag.default})`,
302
278
  targetTagName,
@@ -304,34 +280,26 @@ var _default = (0, _iterateJsdoc.default)(({
304
280
  });
305
281
  });
306
282
  }
307
-
308
283
  const tagName = utils.getPreferredTagName({
309
284
  tagName: 'example'
310
285
  });
311
-
312
286
  if (!utils.hasTag(tagName)) {
313
287
  return;
314
288
  }
315
-
316
289
  const matchingFilenameInfo = getFilenameInfo(matchingFileName);
317
290
  utils.forEachPreferredTag('example', (tag, targetTagName) => {
318
291
  let source = utils.getTagDescription(tag);
319
292
  const match = source.match(hasCaptionRegex);
320
-
321
293
  if (captionRequired && (!match || !match[1].trim())) {
322
294
  report('Caption is expected for examples.', null, tag);
323
295
  }
324
-
325
296
  source = source.replace(hasCaptionRegex, '');
326
297
  const [lines, cols] = match ? getLinesCols(match[0]) : [0, 0];
327
-
328
298
  if (exampleCodeRegex && !exampleCodeRegex.test(source) || rejectExampleCodeRegex && rejectExampleCodeRegex.test(source)) {
329
299
  return;
330
300
  }
331
-
332
301
  const sources = [];
333
302
  let skipInit = false;
334
-
335
303
  if (exampleCodeRegex) {
336
304
  let nonJSPrefacingCols = 0;
337
305
  let nonJSPrefacingLines = 0;
@@ -339,19 +307,18 @@ var _default = (0, _iterateJsdoc.default)(({
339
307
  let lastStringCount = 0;
340
308
  let exampleCode;
341
309
  exampleCodeRegex.lastIndex = 0;
342
-
343
310
  while ((exampleCode = exampleCodeRegex.exec(source)) !== null) {
344
311
  const {
345
312
  index,
346
313
  '0': n0,
347
314
  '1': n1
348
- } = exampleCode; // Count anything preceding user regex match (can affect line numbering)
315
+ } = exampleCode;
349
316
 
317
+ // Count anything preceding user regex match (can affect line numbering)
350
318
  const preMatch = source.slice(startingIndex, index);
351
319
  const [preMatchLines, colDelta] = getLinesCols(preMatch);
352
320
  let nonJSPreface;
353
321
  let nonJSPrefaceLineCount;
354
-
355
322
  if (n1) {
356
323
  const idx = n0.indexOf(n1);
357
324
  nonJSPreface = n0.slice(0, idx);
@@ -360,16 +327,15 @@ var _default = (0, _iterateJsdoc.default)(({
360
327
  nonJSPreface = '';
361
328
  nonJSPrefaceLineCount = 0;
362
329
  }
330
+ nonJSPrefacingLines += lastStringCount + preMatchLines + nonJSPrefaceLineCount;
363
331
 
364
- nonJSPrefacingLines += lastStringCount + preMatchLines + nonJSPrefaceLineCount; // Ignore `preMatch` delta if newlines here
365
-
332
+ // Ignore `preMatch` delta if newlines here
366
333
  if (nonJSPrefaceLineCount) {
367
334
  const charsInLastLine = nonJSPreface.slice(nonJSPreface.lastIndexOf('\n') + 1).length;
368
335
  nonJSPrefacingCols += charsInLastLine;
369
336
  } else {
370
337
  nonJSPrefacingCols += colDelta + nonJSPreface.length;
371
338
  }
372
-
373
339
  const string = n1 || n0;
374
340
  sources.push({
375
341
  nonJSPrefacingCols,
@@ -378,15 +344,12 @@ var _default = (0, _iterateJsdoc.default)(({
378
344
  });
379
345
  startingIndex = exampleCodeRegex.lastIndex;
380
346
  lastStringCount = countChars(string, '\n');
381
-
382
347
  if (!exampleCodeRegex.global) {
383
348
  break;
384
349
  }
385
350
  }
386
-
387
351
  skipInit = true;
388
352
  }
389
-
390
353
  checkSource({
391
354
  cols,
392
355
  lines,
@@ -475,7 +438,6 @@ var _default = (0, _iterateJsdoc.default)(({
475
438
  type: 'suggestion'
476
439
  }
477
440
  });
478
-
479
441
  exports.default = _default;
480
442
  module.exports = exports.default;
481
443
  //# sourceMappingURL=checkExamples.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkExamples.js","names":["zeroBasedLineIndexAdjust","likelyNestedJSDocIndentSpace","preTagSpaceLength","firstLinePrefixLength","hasCaptionRegex","escapeStringRegexp","str","replace","countChars","ch","match","RegExp","length","defaultMdRules","defaultExpressionRules","quotes","semi","strict","getLinesCols","text","matchLines","colDelta","slice","lastIndexOf","iterateJsdoc","report","utils","context","globalState","semver","gte","ESLint","version","column","line","has","set","Map","matchingFileNameMap","get","options","exampleCodeRegex","rejectExampleCodeRegex","checkDefaults","checkParams","checkProperties","noDefaultExampleRules","checkEslintrc","matchingFileName","matchingFileNameDefaults","matchingFileNameParams","matchingFileNameProperties","paddedIndent","baseConfig","configFile","allowInlineConfig","reportUnusedDisableDirectives","captionRequired","rulePaths","mdRules","undefined","expressionRules","getRegexFromString","checkSource","filename","defaultFileName","rules","lines","cols","skipInit","source","targetTagName","sources","tag","push","nonJSPrefacingCols","nonJSPrefacingLines","string","checkRules","cliConfig","useEslintrc","cliConfigStr","JSON","stringify","src","fileNameMapKey","file","cliFile","cli","CLIEngine","config","getConfigForFile","results","messages","executeOnText","number","codeStartLine","codeStartCol","message","severity","ruleId","startLine","startCol","targetSource","getFilenameInfo","ext","jsFileName","getFilename","includes","filenameInfo","forEachPreferredTag","description","trim","getTagDescription","default","tagName","getPreferredTagName","hasTag","matchingFilenameInfo","test","startingIndex","lastStringCount","exampleCode","lastIndex","exec","index","n0","n1","preMatch","preMatchLines","nonJSPreface","nonJSPrefaceLineCount","idx","indexOf","charsInLastLine","global","iterateAllJsdocs","meta","docs","url","schema","additionalProperties","properties","type"],"sources":["../../src/rules/checkExamples.js"],"sourcesContent":["// Todo: When replace `CLIEngine` with `ESLint` when feature set complete per https://github.com/eslint/eslint/issues/14745\n// https://github.com/eslint/eslint/blob/master/docs/user-guide/migrating-to-7.0.0.md#-the-cliengine-class-has-been-deprecated\nimport {\n CLIEngine,\n ESLint,\n} from 'eslint';\nimport semver from 'semver';\nimport iterateJsdoc from '../iterateJsdoc';\n\nconst zeroBasedLineIndexAdjust = -1;\nconst likelyNestedJSDocIndentSpace = 1;\nconst preTagSpaceLength = 1;\n\n// If a space is present, we should ignore it\nconst firstLinePrefixLength = preTagSpaceLength;\n\nconst hasCaptionRegex = /^\\s*<caption>([\\s\\S]*?)<\\/caption>/u;\n\nconst escapeStringRegexp = (str) => {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/gu, '\\\\$&');\n};\n\nconst countChars = (str, ch) => {\n return (str.match(new RegExp(escapeStringRegexp(ch), 'gu')) || []).length;\n};\n\nconst defaultMdRules = {\n // \"always\" newline rule at end unlikely in sample code\n 'eol-last': 0,\n\n // Wouldn't generally expect example paths to resolve relative to JS file\n 'import/no-unresolved': 0,\n\n // Snippets likely too short to always include import/export info\n 'import/unambiguous': 0,\n\n 'jsdoc/require-file-overview': 0,\n\n // The end of a multiline comment would end the comment the example is in.\n 'jsdoc/require-jsdoc': 0,\n\n // Unlikely to have inadvertent debugging within examples\n 'no-console': 0,\n\n // Often wish to start `@example` code after newline; also may use\n // empty lines for spacing\n 'no-multiple-empty-lines': 0,\n\n // Many variables in examples will be `undefined`\n 'no-undef': 0,\n\n // Common to define variables for clarity without always using them\n 'no-unused-vars': 0,\n\n // See import/no-unresolved\n 'node/no-missing-import': 0,\n 'node/no-missing-require': 0,\n\n // Can generally look nicer to pad a little even if code imposes more stringency\n 'padded-blocks': 0,\n};\n\nconst defaultExpressionRules = {\n ...defaultMdRules,\n 'chai-friendly/no-unused-expressions': 'off',\n 'no-empty-function': 'off',\n 'no-new': 'off',\n 'no-unused-expressions': 'off',\n quotes: [\n 'error', 'double',\n ],\n semi: [\n 'error', 'never',\n ],\n strict: 'off',\n};\n\nconst getLinesCols = (text) => {\n const matchLines = countChars(text, '\\n');\n\n const colDelta = matchLines ?\n text.slice(text.lastIndexOf('\\n') + 1).length :\n text.length;\n\n return [\n matchLines, colDelta,\n ];\n};\n\nexport default iterateJsdoc(({\n report,\n utils,\n context,\n globalState,\n}) => {\n if (semver.gte(ESLint.version, '8.0.0')) {\n report(\n 'This rule cannot yet be supported for ESLint 8; you ' +\n 'should either downgrade to ESLint 7 or disable this rule. The ' +\n 'possibility for ESLint 8 support is being tracked at https://github.com/eslint/eslint/issues/14745',\n {\n column: 1,\n line: 1,\n },\n );\n\n return;\n }\n\n if (!globalState.has('checkExamples-matchingFileName')) {\n globalState.set('checkExamples-matchingFileName', new Map());\n }\n\n const matchingFileNameMap = globalState.get('checkExamples-matchingFileName');\n\n const options = context.options[0] || {};\n let {\n exampleCodeRegex = null,\n rejectExampleCodeRegex = null,\n } = options;\n const {\n checkDefaults = false,\n checkParams = false,\n checkProperties = false,\n noDefaultExampleRules = false,\n checkEslintrc = true,\n matchingFileName = null,\n matchingFileNameDefaults = null,\n matchingFileNameParams = null,\n matchingFileNameProperties = null,\n paddedIndent = 0,\n baseConfig = {},\n configFile,\n allowInlineConfig = true,\n reportUnusedDisableDirectives = true,\n captionRequired = false,\n } = options;\n\n // Make this configurable?\n const rulePaths = [];\n\n const mdRules = noDefaultExampleRules ? undefined : defaultMdRules;\n\n const expressionRules = noDefaultExampleRules ? undefined : defaultExpressionRules;\n\n if (exampleCodeRegex) {\n exampleCodeRegex = utils.getRegexFromString(exampleCodeRegex);\n }\n\n if (rejectExampleCodeRegex) {\n rejectExampleCodeRegex = utils.getRegexFromString(rejectExampleCodeRegex);\n }\n\n const checkSource = ({\n filename,\n defaultFileName,\n rules = expressionRules,\n lines = 0,\n cols = 0,\n skipInit,\n source,\n targetTagName,\n sources = [],\n tag = {\n line: 0,\n },\n }) => {\n if (!skipInit) {\n sources.push({\n nonJSPrefacingCols: cols,\n nonJSPrefacingLines: lines,\n string: source,\n });\n }\n\n // Todo: Make fixable\n const checkRules = function ({\n nonJSPrefacingCols,\n nonJSPrefacingLines,\n string,\n }) {\n const cliConfig = {\n allowInlineConfig,\n baseConfig,\n configFile,\n reportUnusedDisableDirectives,\n rulePaths,\n rules,\n useEslintrc: checkEslintrc,\n };\n const cliConfigStr = JSON.stringify(cliConfig);\n\n const src = paddedIndent ?\n string.replace(new RegExp(`(^|\\n) {${paddedIndent}}(?!$)`, 'gu'), '\\n') :\n string;\n\n // Programmatic ESLint API: https://eslint.org/docs/developer-guide/nodejs-api\n const fileNameMapKey = filename ?\n 'a' + cliConfigStr + filename :\n 'b' + cliConfigStr + defaultFileName;\n const file = filename || defaultFileName;\n let cliFile;\n if (matchingFileNameMap.has(fileNameMapKey)) {\n cliFile = matchingFileNameMap.get(fileNameMapKey);\n } else {\n const cli = new CLIEngine(cliConfig);\n let config;\n if (filename || checkEslintrc) {\n config = cli.getConfigForFile(file);\n }\n\n // We need a new instance to ensure that the rules that may only\n // be available to `file` (if it has its own `.eslintrc`),\n // will be defined.\n cliFile = new CLIEngine({\n allowInlineConfig,\n baseConfig: {\n ...baseConfig,\n ...config,\n },\n configFile,\n reportUnusedDisableDirectives,\n rulePaths,\n rules,\n useEslintrc: false,\n });\n matchingFileNameMap.set(fileNameMapKey, cliFile);\n }\n\n const {\n results: [\n {\n messages,\n },\n ],\n } = cliFile.executeOnText(src);\n\n if (!('line' in tag)) {\n tag.line = tag.source[0].number;\n }\n\n // NOTE: `tag.line` can be 0 if of form `/** @tag ... */`\n const codeStartLine = tag.line + nonJSPrefacingLines;\n const codeStartCol = likelyNestedJSDocIndentSpace;\n\n for (const {\n message,\n line,\n column,\n severity,\n ruleId,\n } of messages) {\n const startLine = codeStartLine + line + zeroBasedLineIndexAdjust;\n const startCol = codeStartCol + (\n\n // This might not work for line 0, but line 0 is unlikely for examples\n line <= 1 ? nonJSPrefacingCols + firstLinePrefixLength : preTagSpaceLength\n ) + column;\n\n report(\n '@' + targetTagName + ' ' + (severity === 2 ? 'error' : 'warning') +\n (ruleId ? ' (' + ruleId + ')' : '') + ': ' +\n message,\n null,\n {\n column: startCol,\n line: startLine,\n },\n );\n }\n };\n\n for (const targetSource of sources) {\n checkRules(targetSource);\n }\n };\n\n /**\n *\n * @param {string} filename\n * @param {string} [ext] Since `eslint-plugin-markdown` v2, and\n * ESLint 7, this is the default which other JS-fenced rules will used.\n * Formerly \"md\" was the default.\n * @returns {{defaultFileName: string, fileName: string}}\n */\n const getFilenameInfo = (filename, ext = 'md/*.js') => {\n let defaultFileName;\n if (!filename) {\n const jsFileName = context.getFilename();\n if (typeof jsFileName === 'string' && jsFileName.includes('.')) {\n defaultFileName = jsFileName.replace(/\\..*?$/u, `.${ext}`);\n } else {\n defaultFileName = `dummy.${ext}`;\n }\n }\n\n return {\n defaultFileName,\n filename,\n };\n };\n\n if (checkDefaults) {\n const filenameInfo = getFilenameInfo(matchingFileNameDefaults, 'jsdoc-defaults');\n utils.forEachPreferredTag('default', (tag, targetTagName) => {\n if (!tag.description.trim()) {\n return;\n }\n\n checkSource({\n source: `(${utils.getTagDescription(tag)})`,\n targetTagName,\n ...filenameInfo,\n });\n });\n }\n\n if (checkParams) {\n const filenameInfo = getFilenameInfo(matchingFileNameParams, 'jsdoc-params');\n utils.forEachPreferredTag('param', (tag, targetTagName) => {\n if (!tag.default || !tag.default.trim()) {\n return;\n }\n\n checkSource({\n source: `(${tag.default})`,\n targetTagName,\n ...filenameInfo,\n });\n });\n }\n\n if (checkProperties) {\n const filenameInfo = getFilenameInfo(matchingFileNameProperties, 'jsdoc-properties');\n utils.forEachPreferredTag('property', (tag, targetTagName) => {\n if (!tag.default || !tag.default.trim()) {\n return;\n }\n\n checkSource({\n source: `(${tag.default})`,\n targetTagName,\n ...filenameInfo,\n });\n });\n }\n\n const tagName = utils.getPreferredTagName({\n tagName: 'example',\n });\n if (!utils.hasTag(tagName)) {\n return;\n }\n\n const matchingFilenameInfo = getFilenameInfo(matchingFileName);\n\n utils.forEachPreferredTag('example', (tag, targetTagName) => {\n let source = utils.getTagDescription(tag);\n const match = source.match(hasCaptionRegex);\n\n if (captionRequired && (!match || !match[1].trim())) {\n report('Caption is expected for examples.', null, tag);\n }\n\n source = source.replace(hasCaptionRegex, '');\n const [\n lines,\n cols,\n ] = match ? getLinesCols(match[0]) : [\n 0, 0,\n ];\n\n if (exampleCodeRegex && !exampleCodeRegex.test(source) ||\n rejectExampleCodeRegex && rejectExampleCodeRegex.test(source)\n ) {\n return;\n }\n\n const sources = [];\n let skipInit = false;\n if (exampleCodeRegex) {\n let nonJSPrefacingCols = 0;\n let nonJSPrefacingLines = 0;\n\n let startingIndex = 0;\n let lastStringCount = 0;\n\n let exampleCode;\n exampleCodeRegex.lastIndex = 0;\n while ((exampleCode = exampleCodeRegex.exec(source)) !== null) {\n const {\n index,\n '0': n0,\n '1': n1,\n } = exampleCode;\n\n // Count anything preceding user regex match (can affect line numbering)\n const preMatch = source.slice(startingIndex, index);\n\n const [\n preMatchLines,\n colDelta,\n ] = getLinesCols(preMatch);\n\n let nonJSPreface;\n let nonJSPrefaceLineCount;\n if (n1) {\n const idx = n0.indexOf(n1);\n nonJSPreface = n0.slice(0, idx);\n nonJSPrefaceLineCount = countChars(nonJSPreface, '\\n');\n } else {\n nonJSPreface = '';\n nonJSPrefaceLineCount = 0;\n }\n\n nonJSPrefacingLines += lastStringCount + preMatchLines + nonJSPrefaceLineCount;\n\n // Ignore `preMatch` delta if newlines here\n if (nonJSPrefaceLineCount) {\n const charsInLastLine = nonJSPreface.slice(nonJSPreface.lastIndexOf('\\n') + 1).length;\n\n nonJSPrefacingCols += charsInLastLine;\n } else {\n nonJSPrefacingCols += colDelta + nonJSPreface.length;\n }\n\n const string = n1 || n0;\n sources.push({\n nonJSPrefacingCols,\n nonJSPrefacingLines,\n string,\n });\n startingIndex = exampleCodeRegex.lastIndex;\n lastStringCount = countChars(string, '\\n');\n if (!exampleCodeRegex.global) {\n break;\n }\n }\n\n skipInit = true;\n }\n\n checkSource({\n cols,\n lines,\n rules: mdRules,\n skipInit,\n source,\n sources,\n tag,\n targetTagName,\n ...matchingFilenameInfo,\n });\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Ensures that (JavaScript) examples within JSDoc adhere to ESLint rules.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-examples',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n allowInlineConfig: {\n default: true,\n type: 'boolean',\n },\n baseConfig: {\n type: 'object',\n },\n captionRequired: {\n default: false,\n type: 'boolean',\n },\n checkDefaults: {\n default: false,\n type: 'boolean',\n },\n checkEslintrc: {\n default: true,\n type: 'boolean',\n },\n checkParams: {\n default: false,\n type: 'boolean',\n },\n checkProperties: {\n default: false,\n type: 'boolean',\n },\n configFile: {\n type: 'string',\n },\n exampleCodeRegex: {\n type: 'string',\n },\n matchingFileName: {\n type: 'string',\n },\n matchingFileNameDefaults: {\n type: 'string',\n },\n matchingFileNameParams: {\n type: 'string',\n },\n matchingFileNameProperties: {\n type: 'string',\n },\n noDefaultExampleRules: {\n default: false,\n type: 'boolean',\n },\n paddedIndent: {\n default: 0,\n type: 'integer',\n },\n rejectExampleCodeRegex: {\n type: 'string',\n },\n reportUnusedDisableDirectives: {\n default: true,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;;AAEA;;AAIA;;AACA;;;;AAPA;AACA;AAQA,MAAMA,wBAAwB,GAAG,C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E,OAAO,EAAE,KADM;UAEf6B,IAAI,EAAE;QAFS,CAxBP;QA4BVzF,UAAU,EAAE;UACVyF,IAAI,EAAE;QADI,CA5BF;QA+BVtG,gBAAgB,EAAE;UAChBsG,IAAI,EAAE;QADU,CA/BR;QAkCV/F,gBAAgB,EAAE;UAChB+F,IAAI,EAAE;QADU,CAlCR;QAqCV9F,wBAAwB,EAAE;UACxB8F,IAAI,EAAE;QADkB,CArChB;QAwCV7F,sBAAsB,EAAE;UACtB6F,IAAI,EAAE;QADgB,CAxCd;QA2CV5F,0BAA0B,EAAE;UAC1B4F,IAAI,EAAE;QADoB,CA3ClB;QA8CVjG,qBAAqB,EAAE;UACrBoE,OAAO,EAAE,KADY;UAErB6B,IAAI,EAAE;QAFe,CA9Cb;QAkDV3F,YAAY,EAAE;UACZ8D,OAAO,EAAE,CADG;UAEZ6B,IAAI,EAAE;QAFM,CAlDJ;QAsDVrG,sBAAsB,EAAE;UACtBqG,IAAI,EAAE;QADgB,CAtDd;QAyDVvF,6BAA6B,EAAE;UAC7B0D,OAAO,EAAE,IADoB;UAE7B6B,IAAI,EAAE;QAFuB;MAzDrB,CAFd;MAgEEA,IAAI,EAAE;IAhER,CADM,CALJ;IAyEJA,IAAI,EAAE;EAzEF;AAFL,CA7WY,C"}
1
+ {"version":3,"file":"checkExamples.js","names":["zeroBasedLineIndexAdjust","likelyNestedJSDocIndentSpace","preTagSpaceLength","firstLinePrefixLength","hasCaptionRegex","escapeStringRegexp","str","replace","countChars","ch","match","RegExp","length","defaultMdRules","defaultExpressionRules","quotes","semi","strict","getLinesCols","text","matchLines","colDelta","slice","lastIndexOf","iterateJsdoc","report","utils","context","globalState","semver","gte","ESLint","version","column","line","has","set","Map","matchingFileNameMap","get","options","exampleCodeRegex","rejectExampleCodeRegex","checkDefaults","checkParams","checkProperties","noDefaultExampleRules","checkEslintrc","matchingFileName","matchingFileNameDefaults","matchingFileNameParams","matchingFileNameProperties","paddedIndent","baseConfig","configFile","allowInlineConfig","reportUnusedDisableDirectives","captionRequired","rulePaths","mdRules","undefined","expressionRules","getRegexFromString","checkSource","filename","defaultFileName","rules","lines","cols","skipInit","source","targetTagName","sources","tag","push","nonJSPrefacingCols","nonJSPrefacingLines","string","checkRules","cliConfig","useEslintrc","cliConfigStr","JSON","stringify","src","fileNameMapKey","file","cliFile","cli","CLIEngine","config","getConfigForFile","results","messages","executeOnText","number","codeStartLine","codeStartCol","message","severity","ruleId","startLine","startCol","targetSource","getFilenameInfo","ext","jsFileName","getFilename","includes","filenameInfo","forEachPreferredTag","description","trim","getTagDescription","default","tagName","getPreferredTagName","hasTag","matchingFilenameInfo","test","startingIndex","lastStringCount","exampleCode","lastIndex","exec","index","n0","n1","preMatch","preMatchLines","nonJSPreface","nonJSPrefaceLineCount","idx","indexOf","charsInLastLine","global","iterateAllJsdocs","meta","docs","url","schema","additionalProperties","properties","type"],"sources":["../../src/rules/checkExamples.js"],"sourcesContent":["// Todo: When replace `CLIEngine` with `ESLint` when feature set complete per https://github.com/eslint/eslint/issues/14745\n// https://github.com/eslint/eslint/blob/master/docs/user-guide/migrating-to-7.0.0.md#-the-cliengine-class-has-been-deprecated\nimport {\n CLIEngine,\n ESLint,\n} from 'eslint';\nimport semver from 'semver';\nimport iterateJsdoc from '../iterateJsdoc';\n\nconst zeroBasedLineIndexAdjust = -1;\nconst likelyNestedJSDocIndentSpace = 1;\nconst preTagSpaceLength = 1;\n\n// If a space is present, we should ignore it\nconst firstLinePrefixLength = preTagSpaceLength;\n\nconst hasCaptionRegex = /^\\s*<caption>([\\s\\S]*?)<\\/caption>/u;\n\nconst escapeStringRegexp = (str) => {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/gu, '\\\\$&');\n};\n\nconst countChars = (str, ch) => {\n return (str.match(new RegExp(escapeStringRegexp(ch), 'gu')) || []).length;\n};\n\nconst defaultMdRules = {\n // \"always\" newline rule at end unlikely in sample code\n 'eol-last': 0,\n\n // Wouldn't generally expect example paths to resolve relative to JS file\n 'import/no-unresolved': 0,\n\n // Snippets likely too short to always include import/export info\n 'import/unambiguous': 0,\n\n 'jsdoc/require-file-overview': 0,\n\n // The end of a multiline comment would end the comment the example is in.\n 'jsdoc/require-jsdoc': 0,\n\n // Unlikely to have inadvertent debugging within examples\n 'no-console': 0,\n\n // Often wish to start `@example` code after newline; also may use\n // empty lines for spacing\n 'no-multiple-empty-lines': 0,\n\n // Many variables in examples will be `undefined`\n 'no-undef': 0,\n\n // Common to define variables for clarity without always using them\n 'no-unused-vars': 0,\n\n // See import/no-unresolved\n 'node/no-missing-import': 0,\n 'node/no-missing-require': 0,\n\n // Can generally look nicer to pad a little even if code imposes more stringency\n 'padded-blocks': 0,\n};\n\nconst defaultExpressionRules = {\n ...defaultMdRules,\n 'chai-friendly/no-unused-expressions': 'off',\n 'no-empty-function': 'off',\n 'no-new': 'off',\n 'no-unused-expressions': 'off',\n quotes: [\n 'error', 'double',\n ],\n semi: [\n 'error', 'never',\n ],\n strict: 'off',\n};\n\nconst getLinesCols = (text) => {\n const matchLines = countChars(text, '\\n');\n\n const colDelta = matchLines ?\n text.slice(text.lastIndexOf('\\n') + 1).length :\n text.length;\n\n return [\n matchLines, colDelta,\n ];\n};\n\nexport default iterateJsdoc(({\n report,\n utils,\n context,\n globalState,\n}) => {\n if (semver.gte(ESLint.version, '8.0.0')) {\n report(\n 'This rule cannot yet be supported for ESLint 8; you ' +\n 'should either downgrade to ESLint 7 or disable this rule. The ' +\n 'possibility for ESLint 8 support is being tracked at https://github.com/eslint/eslint/issues/14745',\n {\n column: 1,\n line: 1,\n },\n );\n\n return;\n }\n\n if (!globalState.has('checkExamples-matchingFileName')) {\n globalState.set('checkExamples-matchingFileName', new Map());\n }\n\n const matchingFileNameMap = globalState.get('checkExamples-matchingFileName');\n\n const options = context.options[0] || {};\n let {\n exampleCodeRegex = null,\n rejectExampleCodeRegex = null,\n } = options;\n const {\n checkDefaults = false,\n checkParams = false,\n checkProperties = false,\n noDefaultExampleRules = false,\n checkEslintrc = true,\n matchingFileName = null,\n matchingFileNameDefaults = null,\n matchingFileNameParams = null,\n matchingFileNameProperties = null,\n paddedIndent = 0,\n baseConfig = {},\n configFile,\n allowInlineConfig = true,\n reportUnusedDisableDirectives = true,\n captionRequired = false,\n } = options;\n\n // Make this configurable?\n const rulePaths = [];\n\n const mdRules = noDefaultExampleRules ? undefined : defaultMdRules;\n\n const expressionRules = noDefaultExampleRules ? undefined : defaultExpressionRules;\n\n if (exampleCodeRegex) {\n exampleCodeRegex = utils.getRegexFromString(exampleCodeRegex);\n }\n\n if (rejectExampleCodeRegex) {\n rejectExampleCodeRegex = utils.getRegexFromString(rejectExampleCodeRegex);\n }\n\n const checkSource = ({\n filename,\n defaultFileName,\n rules = expressionRules,\n lines = 0,\n cols = 0,\n skipInit,\n source,\n targetTagName,\n sources = [],\n tag = {\n line: 0,\n },\n }) => {\n if (!skipInit) {\n sources.push({\n nonJSPrefacingCols: cols,\n nonJSPrefacingLines: lines,\n string: source,\n });\n }\n\n // Todo: Make fixable\n const checkRules = function ({\n nonJSPrefacingCols,\n nonJSPrefacingLines,\n string,\n }) {\n const cliConfig = {\n allowInlineConfig,\n baseConfig,\n configFile,\n reportUnusedDisableDirectives,\n rulePaths,\n rules,\n useEslintrc: checkEslintrc,\n };\n const cliConfigStr = JSON.stringify(cliConfig);\n\n const src = paddedIndent ?\n string.replace(new RegExp(`(^|\\n) {${paddedIndent}}(?!$)`, 'gu'), '\\n') :\n string;\n\n // Programmatic ESLint API: https://eslint.org/docs/developer-guide/nodejs-api\n const fileNameMapKey = filename ?\n 'a' + cliConfigStr + filename :\n 'b' + cliConfigStr + defaultFileName;\n const file = filename || defaultFileName;\n let cliFile;\n if (matchingFileNameMap.has(fileNameMapKey)) {\n cliFile = matchingFileNameMap.get(fileNameMapKey);\n } else {\n const cli = new CLIEngine(cliConfig);\n let config;\n if (filename || checkEslintrc) {\n config = cli.getConfigForFile(file);\n }\n\n // We need a new instance to ensure that the rules that may only\n // be available to `file` (if it has its own `.eslintrc`),\n // will be defined.\n cliFile = new CLIEngine({\n allowInlineConfig,\n baseConfig: {\n ...baseConfig,\n ...config,\n },\n configFile,\n reportUnusedDisableDirectives,\n rulePaths,\n rules,\n useEslintrc: false,\n });\n matchingFileNameMap.set(fileNameMapKey, cliFile);\n }\n\n const {\n results: [\n {\n messages,\n },\n ],\n } = cliFile.executeOnText(src);\n\n if (!('line' in tag)) {\n tag.line = tag.source[0].number;\n }\n\n // NOTE: `tag.line` can be 0 if of form `/** @tag ... */`\n const codeStartLine = tag.line + nonJSPrefacingLines;\n const codeStartCol = likelyNestedJSDocIndentSpace;\n\n for (const {\n message,\n line,\n column,\n severity,\n ruleId,\n } of messages) {\n const startLine = codeStartLine + line + zeroBasedLineIndexAdjust;\n const startCol = codeStartCol + (\n\n // This might not work for line 0, but line 0 is unlikely for examples\n line <= 1 ? nonJSPrefacingCols + firstLinePrefixLength : preTagSpaceLength\n ) + column;\n\n report(\n '@' + targetTagName + ' ' + (severity === 2 ? 'error' : 'warning') +\n (ruleId ? ' (' + ruleId + ')' : '') + ': ' +\n message,\n null,\n {\n column: startCol,\n line: startLine,\n },\n );\n }\n };\n\n for (const targetSource of sources) {\n checkRules(targetSource);\n }\n };\n\n /**\n *\n * @param {string} filename\n * @param {string} [ext] Since `eslint-plugin-markdown` v2, and\n * ESLint 7, this is the default which other JS-fenced rules will used.\n * Formerly \"md\" was the default.\n * @returns {{defaultFileName: string, fileName: string}}\n */\n const getFilenameInfo = (filename, ext = 'md/*.js') => {\n let defaultFileName;\n if (!filename) {\n const jsFileName = context.getFilename();\n if (typeof jsFileName === 'string' && jsFileName.includes('.')) {\n defaultFileName = jsFileName.replace(/\\..*?$/u, `.${ext}`);\n } else {\n defaultFileName = `dummy.${ext}`;\n }\n }\n\n return {\n defaultFileName,\n filename,\n };\n };\n\n if (checkDefaults) {\n const filenameInfo = getFilenameInfo(matchingFileNameDefaults, 'jsdoc-defaults');\n utils.forEachPreferredTag('default', (tag, targetTagName) => {\n if (!tag.description.trim()) {\n return;\n }\n\n checkSource({\n source: `(${utils.getTagDescription(tag)})`,\n targetTagName,\n ...filenameInfo,\n });\n });\n }\n\n if (checkParams) {\n const filenameInfo = getFilenameInfo(matchingFileNameParams, 'jsdoc-params');\n utils.forEachPreferredTag('param', (tag, targetTagName) => {\n if (!tag.default || !tag.default.trim()) {\n return;\n }\n\n checkSource({\n source: `(${tag.default})`,\n targetTagName,\n ...filenameInfo,\n });\n });\n }\n\n if (checkProperties) {\n const filenameInfo = getFilenameInfo(matchingFileNameProperties, 'jsdoc-properties');\n utils.forEachPreferredTag('property', (tag, targetTagName) => {\n if (!tag.default || !tag.default.trim()) {\n return;\n }\n\n checkSource({\n source: `(${tag.default})`,\n targetTagName,\n ...filenameInfo,\n });\n });\n }\n\n const tagName = utils.getPreferredTagName({\n tagName: 'example',\n });\n if (!utils.hasTag(tagName)) {\n return;\n }\n\n const matchingFilenameInfo = getFilenameInfo(matchingFileName);\n\n utils.forEachPreferredTag('example', (tag, targetTagName) => {\n let source = utils.getTagDescription(tag);\n const match = source.match(hasCaptionRegex);\n\n if (captionRequired && (!match || !match[1].trim())) {\n report('Caption is expected for examples.', null, tag);\n }\n\n source = source.replace(hasCaptionRegex, '');\n const [\n lines,\n cols,\n ] = match ? getLinesCols(match[0]) : [\n 0, 0,\n ];\n\n if (exampleCodeRegex && !exampleCodeRegex.test(source) ||\n rejectExampleCodeRegex && rejectExampleCodeRegex.test(source)\n ) {\n return;\n }\n\n const sources = [];\n let skipInit = false;\n if (exampleCodeRegex) {\n let nonJSPrefacingCols = 0;\n let nonJSPrefacingLines = 0;\n\n let startingIndex = 0;\n let lastStringCount = 0;\n\n let exampleCode;\n exampleCodeRegex.lastIndex = 0;\n while ((exampleCode = exampleCodeRegex.exec(source)) !== null) {\n const {\n index,\n '0': n0,\n '1': n1,\n } = exampleCode;\n\n // Count anything preceding user regex match (can affect line numbering)\n const preMatch = source.slice(startingIndex, index);\n\n const [\n preMatchLines,\n colDelta,\n ] = getLinesCols(preMatch);\n\n let nonJSPreface;\n let nonJSPrefaceLineCount;\n if (n1) {\n const idx = n0.indexOf(n1);\n nonJSPreface = n0.slice(0, idx);\n nonJSPrefaceLineCount = countChars(nonJSPreface, '\\n');\n } else {\n nonJSPreface = '';\n nonJSPrefaceLineCount = 0;\n }\n\n nonJSPrefacingLines += lastStringCount + preMatchLines + nonJSPrefaceLineCount;\n\n // Ignore `preMatch` delta if newlines here\n if (nonJSPrefaceLineCount) {\n const charsInLastLine = nonJSPreface.slice(nonJSPreface.lastIndexOf('\\n') + 1).length;\n\n nonJSPrefacingCols += charsInLastLine;\n } else {\n nonJSPrefacingCols += colDelta + nonJSPreface.length;\n }\n\n const string = n1 || n0;\n sources.push({\n nonJSPrefacingCols,\n nonJSPrefacingLines,\n string,\n });\n startingIndex = exampleCodeRegex.lastIndex;\n lastStringCount = countChars(string, '\\n');\n if (!exampleCodeRegex.global) {\n break;\n }\n }\n\n skipInit = true;\n }\n\n checkSource({\n cols,\n lines,\n rules: mdRules,\n skipInit,\n source,\n sources,\n tag,\n targetTagName,\n ...matchingFilenameInfo,\n });\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Ensures that (JavaScript) examples within JSDoc adhere to ESLint rules.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-examples',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n allowInlineConfig: {\n default: true,\n type: 'boolean',\n },\n baseConfig: {\n type: 'object',\n },\n captionRequired: {\n default: false,\n type: 'boolean',\n },\n checkDefaults: {\n default: false,\n type: 'boolean',\n },\n checkEslintrc: {\n default: true,\n type: 'boolean',\n },\n checkParams: {\n default: false,\n type: 'boolean',\n },\n checkProperties: {\n default: false,\n type: 'boolean',\n },\n configFile: {\n type: 'string',\n },\n exampleCodeRegex: {\n type: 'string',\n },\n matchingFileName: {\n type: 'string',\n },\n matchingFileNameDefaults: {\n type: 'string',\n },\n matchingFileNameParams: {\n type: 'string',\n },\n matchingFileNameProperties: {\n type: 'string',\n },\n noDefaultExampleRules: {\n default: false,\n type: 'boolean',\n },\n paddedIndent: {\n default: 0,\n type: 'integer',\n },\n rejectExampleCodeRegex: {\n type: 'string',\n },\n reportUnusedDisableDirectives: {\n default: true,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAEA;AAIA;AACA;AAA2C;AAP3C;AACA;;AAQA,MAAMA,wBAAwB,GAAG,CAAC,CAAC;AACnC,MAAMC,4BAA4B,GAAG,CAAC;AACtC,MAAMC,iBAAiB,GAAG,CAAC;;AAE3B;AACA,MAAMC,qBAAqB,GAAGD,iBAAiB;AAE/C,MAAME,eAAe,GAAG,qCAAqC;AAE7D,MAAMC,kBAAkB,GAAIC,GAAG,IAAK;EAClC,OAAOA,GAAG,CAACC,OAAO,CAAC,sBAAsB,EAAE,MAAM,CAAC;AACpD,CAAC;AAED,MAAMC,UAAU,GAAG,CAACF,GAAG,EAAEG,EAAE,KAAK;EAC9B,OAAO,CAACH,GAAG,CAACI,KAAK,CAAC,IAAIC,MAAM,CAACN,kBAAkB,CAACI,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE,EAAEG,MAAM;AAC3E,CAAC;AAED,MAAMC,cAAc,GAAG;EACrB;EACA,UAAU,EAAE,CAAC;EAEb;EACA,sBAAsB,EAAE,CAAC;EAEzB;EACA,oBAAoB,EAAE,CAAC;EAEvB,6BAA6B,EAAE,CAAC;EAEhC;EACA,qBAAqB,EAAE,CAAC;EAExB;EACA,YAAY,EAAE,CAAC;EAEf;EACA;EACA,yBAAyB,EAAE,CAAC;EAE5B;EACA,UAAU,EAAE,CAAC;EAEb;EACA,gBAAgB,EAAE,CAAC;EAEnB;EACA,wBAAwB,EAAE,CAAC;EAC3B,yBAAyB,EAAE,CAAC;EAE5B;EACA,eAAe,EAAE;AACnB,CAAC;AAED,MAAMC,sBAAsB,GAAG;EAC7B,GA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B,IAAI,EAAE;QACR,CAAC;QACDhG,aAAa,EAAE;UACbmE,OAAO,EAAE,IAAI;UACb6B,IAAI,EAAE;QACR,CAAC;QACDnG,WAAW,EAAE;UACXsE,OAAO,EAAE,KAAK;UACd6B,IAAI,EAAE;QACR,CAAC;QACDlG,eAAe,EAAE;UACfqE,OAAO,EAAE,KAAK;UACd6B,IAAI,EAAE;QACR,CAAC;QACDzF,UAAU,EAAE;UACVyF,IAAI,EAAE;QACR,CAAC;QACDtG,gBAAgB,EAAE;UAChBsG,IAAI,EAAE;QACR,CAAC;QACD/F,gBAAgB,EAAE;UAChB+F,IAAI,EAAE;QACR,CAAC;QACD9F,wBAAwB,EAAE;UACxB8F,IAAI,EAAE;QACR,CAAC;QACD7F,sBAAsB,EAAE;UACtB6F,IAAI,EAAE;QACR,CAAC;QACD5F,0BAA0B,EAAE;UAC1B4F,IAAI,EAAE;QACR,CAAC;QACDjG,qBAAqB,EAAE;UACrBoE,OAAO,EAAE,KAAK;UACd6B,IAAI,EAAE;QACR,CAAC;QACD3F,YAAY,EAAE;UACZ8D,OAAO,EAAE,CAAC;UACV6B,IAAI,EAAE;QACR,CAAC;QACDrG,sBAAsB,EAAE;UACtBqG,IAAI,EAAE;QACR,CAAC;QACDvF,6BAA6B,EAAE;UAC7B0D,OAAO,EAAE,IAAI;UACb6B,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAA;AAAA"}
@@ -4,25 +4,20 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc"));
9
-
10
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
9
  const maskExcludedContent = (str, excludeTags) => {
13
10
  const regContent = new RegExp(`([ \\t]+\\*)[ \\t]@(?:${excludeTags.join('|')})(?=[ \\n])([\\w|\\W]*?\\n)(?=[ \\t]*\\*(?:[ \\t]*@\\w+\\s|\\/))`, 'gu');
14
11
  return str.replace(regContent, (_match, margin, code) => {
15
12
  return (margin + '\n').repeat(code.match(/\n/gu).length);
16
13
  });
17
14
  };
18
-
19
15
  const maskCodeBlocks = str => {
20
16
  const regContent = /([ \t]+\*)[ \t]```[^\n]*?([\w|\W]*?\n)(?=[ \t]*\*(?:[ \t]*(?:```|@\w+\s)|\/))/gu;
21
17
  return str.replace(regContent, (_match, margin, code) => {
22
18
  return (margin + '\n').repeat(code.match(/\n/gu).length);
23
19
  });
24
20
  };
25
-
26
21
  var _default = (0, _iterateJsdoc.default)(({
27
22
  sourceCode,
28
23
  jsdocNode,
@@ -36,7 +31,6 @@ var _default = (0, _iterateJsdoc.default)(({
36
31
  const reg = /^(?:\/?\**|[ \t]*)\*[ \t]{2}/gmu;
37
32
  const textWithoutCodeBlocks = maskCodeBlocks(sourceCode.getText(jsdocNode));
38
33
  const text = excludeTags.length ? maskExcludedContent(textWithoutCodeBlocks, excludeTags) : textWithoutCodeBlocks;
39
-
40
34
  if (reg.test(text)) {
41
35
  const lineBreaks = text.slice(0, reg.lastIndex).match(/\n/gu) || [];
42
36
  report('There must be no indentation.', null, {
@@ -66,7 +60,6 @@ var _default = (0, _iterateJsdoc.default)(({
66
60
  type: 'layout'
67
61
  }
68
62
  });
69
-
70
63
  exports.default = _default;
71
64
  module.exports = exports.default;
72
65
  //# sourceMappingURL=checkIndentation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkIndentation.js","names":["maskExcludedContent","str","excludeTags","regContent","RegExp","join","replace","_match","margin","code","repeat","match","length","maskCodeBlocks","iterateJsdoc","sourceCode","jsdocNode","report","context","options","reg","textWithoutCodeBlocks","getText","text","test","lineBreaks","slice","lastIndex","line","iterateAllJsdocs","meta","docs","description","url","schema","additionalProperties","properties","items","pattern","type"],"sources":["../../src/rules/checkIndentation.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nconst maskExcludedContent = (str, excludeTags) => {\n const regContent = new RegExp(`([ \\\\t]+\\\\*)[ \\\\t]@(?:${excludeTags.join('|')})(?=[ \\\\n])([\\\\w|\\\\W]*?\\\\n)(?=[ \\\\t]*\\\\*(?:[ \\\\t]*@\\\\w+\\\\s|\\\\/))`, 'gu');\n\n return str.replace(regContent, (_match, margin, code) => {\n return (margin + '\\n').repeat(code.match(/\\n/gu).length);\n });\n};\n\nconst maskCodeBlocks = (str) => {\n const regContent = /([ \\t]+\\*)[ \\t]```[^\\n]*?([\\w|\\W]*?\\n)(?=[ \\t]*\\*(?:[ \\t]*(?:```|@\\w+\\s)|\\/))/gu;\n\n return str.replace(regContent, (_match, margin, code) => {\n return (margin + '\\n').repeat(code.match(/\\n/gu).length);\n });\n};\n\nexport default iterateJsdoc(({\n sourceCode,\n jsdocNode,\n report,\n context,\n}) => {\n const options = context.options[0] || {};\n const {\n excludeTags = [\n 'example',\n ],\n } = options;\n\n const reg = /^(?:\\/?\\**|[ \\t]*)\\*[ \\t]{2}/gmu;\n const textWithoutCodeBlocks = maskCodeBlocks(sourceCode.getText(jsdocNode));\n const text = excludeTags.length ? maskExcludedContent(textWithoutCodeBlocks, excludeTags) : textWithoutCodeBlocks;\n\n if (reg.test(text)) {\n const lineBreaks = text.slice(0, reg.lastIndex).match(/\\n/gu) || [];\n report('There must be no indentation.', null, {\n line: lineBreaks.length,\n });\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Reports invalid padding inside JSDoc blocks.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-indentation',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n excludeTags: {\n items: {\n pattern: '^\\\\S+$',\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'layout',\n },\n});\n"],"mappings":";;;;;;;AAAA;;;;AAEA,MAAMA,mBAAmB,GAAG,CAACC,GAAD,EAA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AAJ,EAAoB;IAClB,MAAME,UAAU,GAAGF,IAAI,CAACG,KAAL,CAAW,CAAX,EAAcN,GAAG,CAACO,SAAlB,EAA6BhB,KAA7B,CAAmC,MAAnC,KAA8C,EAAjE;IACAM,MAAM,CAAC,+BAAD,EAAkC,IAAlC,EAAwC;MAC5CW,IAAI,EAAEH,UAAU,CAACb;IAD2B,CAAxC,CAAN;EAGD;AACF,CAvBc,EAuBZ;EACDiB,gBAAgB,EAAE,IADjB;EAEDC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,8CADT;MAEJC,GAAG,EAAE;IAFD,CADF;IAKJC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KADxB;MAEEC,UAAU,EAAE;QACVlC,WAAW,EAAE;UACXmC,KAAK,EAAE;YACLC,OAAO,EAAE,QADJ;YAELC,IAAI,EAAE;UAFD,CADI;UAKXA,IAAI,EAAE;QALK;MADH,CAFd;MAWEA,IAAI,EAAE;IAXR,CADM,CALJ;IAoBJA,IAAI,EAAE;EApBF;AAFL,CAvBY,C"}
1
+ {"version":3,"file":"checkIndentation.js","names":["maskExcludedContent","str","excludeTags","regContent","RegExp","join","replace","_match","margin","code","repeat","match","length","maskCodeBlocks","iterateJsdoc","sourceCode","jsdocNode","report","context","options","reg","textWithoutCodeBlocks","getText","text","test","lineBreaks","slice","lastIndex","line","iterateAllJsdocs","meta","docs","description","url","schema","additionalProperties","properties","items","pattern","type"],"sources":["../../src/rules/checkIndentation.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nconst maskExcludedContent = (str, excludeTags) => {\n const regContent = new RegExp(`([ \\\\t]+\\\\*)[ \\\\t]@(?:${excludeTags.join('|')})(?=[ \\\\n])([\\\\w|\\\\W]*?\\\\n)(?=[ \\\\t]*\\\\*(?:[ \\\\t]*@\\\\w+\\\\s|\\\\/))`, 'gu');\n\n return str.replace(regContent, (_match, margin, code) => {\n return (margin + '\\n').repeat(code.match(/\\n/gu).length);\n });\n};\n\nconst maskCodeBlocks = (str) => {\n const regContent = /([ \\t]+\\*)[ \\t]```[^\\n]*?([\\w|\\W]*?\\n)(?=[ \\t]*\\*(?:[ \\t]*(?:```|@\\w+\\s)|\\/))/gu;\n\n return str.replace(regContent, (_match, margin, code) => {\n return (margin + '\\n').repeat(code.match(/\\n/gu).length);\n });\n};\n\nexport default iterateJsdoc(({\n sourceCode,\n jsdocNode,\n report,\n context,\n}) => {\n const options = context.options[0] || {};\n const {\n excludeTags = [\n 'example',\n ],\n } = options;\n\n const reg = /^(?:\\/?\\**|[ \\t]*)\\*[ \\t]{2}/gmu;\n const textWithoutCodeBlocks = maskCodeBlocks(sourceCode.getText(jsdocNode));\n const text = excludeTags.length ? maskExcludedContent(textWithoutCodeBlocks, excludeTags) : textWithoutCodeBlocks;\n\n if (reg.test(text)) {\n const lineBreaks = text.slice(0, reg.lastIndex).match(/\\n/gu) || [];\n report('There must be no indentation.', null, {\n line: lineBreaks.length,\n });\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Reports invalid padding inside JSDoc blocks.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-indentation',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n excludeTags: {\n items: {\n pattern: '^\\\\S+$',\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'layout',\n },\n});\n"],"mappings":";;;;;;AAAA;AAA2C;AAE3C,MAAMA,mBAAmB,GAAG,CAACC,GAAG,EAAEC,WAAW,KAAK;EAChD,MAAMC,UAAU,GAAG,IAAIC,MAAM,CAAE,yBAAwBF,WAAW,CAACG,IAAI,CAAC,GAAG,CAAE,kEAAiE,EAAE,IAAI,CAAC;EAErJ,OAAOJ,GAAG,CAACK,OAAO,CAACH,UAAU,EAAE,CAACI,MAAM,EAAEC,MAAM,EAAEC,IAAI,KAAK;IACvD,OAAO,CAACD,MAAM,GAAG,IAAI,EAAEE,MAAM,CA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