eslint-plugin-jsdoc 50.0.0 → 50.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,6 +24,12 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
24
24
  let extraAsterisks = false;
25
25
  const nonJsdocNodes = /** @type {import('estree').Node[]} */allComments.filter(comment => {
26
26
  const commentText = sourceCode.getText(comment);
27
+ const initialText = commentText.replace(commentRegexp, '').trimStart();
28
+ if (['eslint'].some(directive => {
29
+ return initialText.startsWith(directive);
30
+ })) {
31
+ return false;
32
+ }
27
33
  let sliceIndex = 2;
28
34
  if (!commentRegexp.test(commentText)) {
29
35
  var _extraAsteriskComment;
@@ -1 +1 @@
1
- {"version":3,"file":"noBadBlocks.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","_commentParser","e","__esModule","default","commentRegexp","extraAsteriskCommentRegexp","_default","exports","iterateJsdoc","context","sourceCode","allComments","makeReport","ignore","preventAllMultiAsteriskBlocks","options","extraAsterisks","nonJsdocNodes","filter","comment","commentText","getText","sliceIndex","test","_extraAsteriskComment","multiline","exec","length","tags","commentParser","slice","some","tag","includes","node","report","fix","fixer","text","replaceText","replace","checkFile","meta","docs","description","url","fixable","schema","additionalProperties","properties","items","type","module"],"sources":["../../src/rules/noBadBlocks.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\nimport {\n parse as commentParser,\n} from 'comment-parser';\n\n// Neither a single nor 3+ asterisks are valid jsdoc per\n// https://jsdoc.app/about-getting-started.html#adding-documentation-comments-to-your-code\nconst commentRegexp = /^\\/\\*(?!\\*)/u;\nconst extraAsteriskCommentRegexp = /^\\/\\*{3,}/u;\n\nexport default iterateJsdoc(({\n context,\n sourceCode,\n allComments,\n makeReport,\n}) => {\n const [\n {\n ignore = [\n 'ts-check',\n 'ts-expect-error',\n 'ts-ignore',\n 'ts-nocheck',\n ],\n preventAllMultiAsteriskBlocks = false,\n } = {},\n ] = context.options;\n\n let extraAsterisks = false;\n const nonJsdocNodes = /** @type {import('estree').Node[]} */ (\n allComments\n ).filter((comment) => {\n const commentText = sourceCode.getText(comment);\n let sliceIndex = 2;\n if (!commentRegexp.test(commentText)) {\n const multiline = extraAsteriskCommentRegexp.exec(commentText)?.[0];\n if (!multiline) {\n return false;\n }\n\n sliceIndex = multiline.length;\n extraAsterisks = true;\n if (preventAllMultiAsteriskBlocks) {\n return true;\n }\n }\n\n const tags = (commentParser(\n `${commentText.slice(0, 2)}*${commentText.slice(sliceIndex)}`,\n )[0] || {}).tags ?? [];\n\n return tags.length && !tags.some(({\n tag,\n }) => {\n return ignore.includes(tag);\n });\n });\n\n if (!nonJsdocNodes.length) {\n return;\n }\n\n for (const node of nonJsdocNodes) {\n const report = /** @type {import('../iterateJsdoc.js').MakeReport} */ (\n makeReport\n )(context, node);\n\n // eslint-disable-next-line no-loop-func\n const fix = /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {\n const text = sourceCode.getText(node);\n\n return fixer.replaceText(\n node,\n extraAsterisks ?\n text.replace(extraAsteriskCommentRegexp, '/**') :\n text.replace('/*', '/**'),\n );\n };\n\n report('Expected JSDoc-like comment to begin with two asterisks.', fix);\n }\n}, {\n checkFile: true,\n meta: {\n docs: {\n description: 'This rule checks for multi-line-style comments which fail to meet the criteria of a jsdoc block.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-bad-blocks.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n ignore: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n preventAllMultiAsteriskBlocks: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'layout',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAEwB,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA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J,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"noBadBlocks.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","_commentParser","e","__esModule","default","commentRegexp","extraAsteriskCommentRegexp","_default","exports","iterateJsdoc","context","sourceCode","allComments","makeReport","ignore","preventAllMultiAsteriskBlocks","options","extraAsterisks","nonJsdocNodes","filter","comment","commentText","getText","initialText","replace","trimStart","some","directive","startsWith","sliceIndex","test","_extraAsteriskComment","multiline","exec","length","tags","commentParser","slice","tag","includes","node","report","fix","fixer","text","replaceText","checkFile","meta","docs","description","url","fixable","schema","additionalProperties","properties","items","type","module"],"sources":["../../src/rules/noBadBlocks.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\nimport {\n parse as commentParser,\n} from 'comment-parser';\n\n// Neither a single nor 3+ asterisks are valid jsdoc per\n// https://jsdoc.app/about-getting-started.html#adding-documentation-comments-to-your-code\nconst commentRegexp = /^\\/\\*(?!\\*)/u;\nconst extraAsteriskCommentRegexp = /^\\/\\*{3,}/u;\n\nexport default iterateJsdoc(({\n context,\n sourceCode,\n allComments,\n makeReport,\n}) => {\n const [\n {\n ignore = [\n 'ts-check',\n 'ts-expect-error',\n 'ts-ignore',\n 'ts-nocheck',\n ],\n preventAllMultiAsteriskBlocks = false,\n } = {},\n ] = context.options;\n\n let extraAsterisks = false;\n const nonJsdocNodes = /** @type {import('estree').Node[]} */ (\n allComments\n ).filter((comment) => {\n const commentText = sourceCode.getText(comment);\n\n const initialText = commentText.replace(commentRegexp, '').trimStart();\n if ([\n 'eslint'\n ].some((directive) => {\n return initialText.startsWith(directive);\n })) {\n return false;\n }\n\n let sliceIndex = 2;\n if (!commentRegexp.test(commentText)) {\n const multiline = extraAsteriskCommentRegexp.exec(commentText)?.[0];\n if (!multiline) {\n return false;\n }\n\n sliceIndex = multiline.length;\n extraAsterisks = true;\n if (preventAllMultiAsteriskBlocks) {\n return true;\n }\n }\n\n const tags = (commentParser(\n `${commentText.slice(0, 2)}*${commentText.slice(sliceIndex)}`,\n )[0] || {}).tags ?? [];\n\n return tags.length && !tags.some(({\n tag,\n }) => {\n return ignore.includes(tag);\n });\n });\n\n if (!nonJsdocNodes.length) {\n return;\n }\n\n for (const node of nonJsdocNodes) {\n const report = /** @type {import('../iterateJsdoc.js').MakeReport} */ (\n makeReport\n )(context, node);\n\n // eslint-disable-next-line no-loop-func\n const fix = /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {\n const text = sourceCode.getText(node);\n\n return fixer.replaceText(\n node,\n extraAsterisks ?\n text.replace(extraAsteriskCommentRegexp, '/**') :\n text.replace('/*', '/**'),\n );\n };\n\n report('Expected JSDoc-like comment to begin with two asterisks.', fix);\n }\n}, {\n checkFile: true,\n meta: {\n docs: {\n description: 'This rule checks for multi-line-style comments which fail to meet the criteria of a jsdoc block.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-bad-blocks.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n ignore: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n preventAllMultiAsteriskBlocks: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'layout',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAEwB,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAExB;AACA;AACA,MAAMG,aAAa,GAAG,cAAc;AACpC,MAAMC,0BAA0B,GAAG,YAAY;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAJ,OAAA,GAEjC,IAAAK,qBAAY,EAAC,CAAC;EAC3BC,OAAO;EACPC,UAAU;EACVC,WAAW;EACXC;AACF,CAAC,KAAK;EACJ,MAAM,CACJ;IACEC,MAAM,GAAG,CACP,UAAU,EACV,iBAAiB,E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+152,5 @@
152
152
  "test-cov": "cross-env TIMING=1 c8 --reporter text npm run test-no-cov",
153
153
  "test-index": "npm run test-no-cov -- test/rules/index.js"
154
154
  },
155
- "version": "50.0.0"
155
+ "version": "50.0.1"
156
156
  }
@@ -31,6 +31,16 @@ export default iterateJsdoc(({
31
31
  allComments
32
32
  ).filter((comment) => {
33
33
  const commentText = sourceCode.getText(comment);
34
+
35
+ const initialText = commentText.replace(commentRegexp, '').trimStart();
36
+ if ([
37
+ 'eslint'
38
+ ].some((directive) => {
39
+ return initialText.startsWith(directive);
40
+ })) {
41
+ return false;
42
+ }
43
+
34
44
  let sliceIndex = 2;
35
45
  if (!commentRegexp.test(commentText)) {
36
46
  const multiline = extraAsteriskCommentRegexp.exec(commentText)?.[0];