eslint-plugin-jsdoc 37.9.6 → 38.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.
- package/README.md +70 -13
- package/dist/rules/matchDescription.js +2 -2
- package/dist/rules/matchDescription.js.map +1 -1
- package/dist/rules/matchName.js +6 -1
- package/dist/rules/matchName.js.map +1 -1
- package/dist/rules/noUndefinedTypes.js +1 -1
- package/dist/rules/noUndefinedTypes.js.map +1 -1
- package/dist/rules/tagLines.js +23 -1
- package/dist/rules/tagLines.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -6608,7 +6608,7 @@ The default is this basic expression to match English sentences (Support
|
|
|
6608
6608
|
for Unicode upper case may be added in a future version when it can be handled
|
|
6609
6609
|
by our supported Node versions):
|
|
6610
6610
|
|
|
6611
|
-
``^([A-Z]|[`\\d_])[\\s\\S]*[.?!`]
|
|
6611
|
+
``^([A-Z]|[`\\d_])[\\s\\S]*[.?!`]\\s*$``
|
|
6612
6612
|
|
|
6613
6613
|
Applies to the jsdoc block description and `@description` (or `@desc`)
|
|
6614
6614
|
by default but the `tags` option (see below) may be used to match other tags.
|
|
@@ -6960,7 +6960,7 @@ function quux (foo) {
|
|
|
6960
6960
|
function quux (foo) {
|
|
6961
6961
|
|
|
6962
6962
|
}
|
|
6963
|
-
// "jsdoc/match-description": ["error"|"warn", {"mainDescription":"^[a-zA-Z]*$","tags":{"param":true}}]
|
|
6963
|
+
// "jsdoc/match-description": ["error"|"warn", {"mainDescription":"^[a-zA-Z]*\\s*$","tags":{"param":true}}]
|
|
6964
6964
|
// Message: JSDoc description does not satisfy the regex pattern.
|
|
6965
6965
|
|
|
6966
6966
|
/**
|
|
@@ -6971,7 +6971,7 @@ function quux (foo) {
|
|
|
6971
6971
|
function quux (foo) {
|
|
6972
6972
|
|
|
6973
6973
|
}
|
|
6974
|
-
// "jsdoc/match-description": ["error"|"warn", {"mainDescription":{"match":"^[a-zA-Z]*$","message":"Letters only"},"tags":{"param":{"match":true,"message":"Needs to begin with a capital letter and end with a period."}}}]
|
|
6974
|
+
// "jsdoc/match-description": ["error"|"warn", {"mainDescription":{"match":"^[a-zA-Z]*\\s*$","message":"Letters only"},"tags":{"param":{"match":true,"message":"Needs to begin with a capital letter and end with a period."}}}]
|
|
6975
6975
|
// Message: Needs to begin with a capital letter and end with a period.
|
|
6976
6976
|
|
|
6977
6977
|
/**
|
|
@@ -7151,6 +7151,26 @@ function quux (foo) {
|
|
|
7151
7151
|
}
|
|
7152
7152
|
// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
|
|
7153
7153
|
// Message: JSDoc description does not satisfy the regex pattern.
|
|
7154
|
+
|
|
7155
|
+
/**
|
|
7156
|
+
* Description with extra new line
|
|
7157
|
+
*
|
|
7158
|
+
*/
|
|
7159
|
+
function quux () {
|
|
7160
|
+
|
|
7161
|
+
}
|
|
7162
|
+
// "jsdoc/match-description": ["error"|"warn", {"matchDescription":"[\\s\\S]*\\S$"}]
|
|
7163
|
+
// Message: JSDoc description does not satisfy the regex pattern.
|
|
7164
|
+
|
|
7165
|
+
/**
|
|
7166
|
+
*
|
|
7167
|
+
* This function does lots of things.
|
|
7168
|
+
*/
|
|
7169
|
+
function quux () {
|
|
7170
|
+
|
|
7171
|
+
}
|
|
7172
|
+
// "jsdoc/match-description": ["error"|"warn", {"matchDescription":"^\\S[\\s\\S]*\\S$"}]
|
|
7173
|
+
// Message: JSDoc description does not satisfy the regex pattern.
|
|
7154
7174
|
````
|
|
7155
7175
|
|
|
7156
7176
|
The following patterns are not considered problems:
|
|
@@ -7665,6 +7685,14 @@ function quux () {
|
|
|
7665
7685
|
function quux () {}
|
|
7666
7686
|
// "jsdoc/match-name": ["error"|"warn", ]
|
|
7667
7687
|
// Message: Rule `no-restricted-syntax` is missing a `match` option.
|
|
7688
|
+
|
|
7689
|
+
/**
|
|
7690
|
+
* @param {
|
|
7691
|
+
* someType
|
|
7692
|
+
* } opt_a
|
|
7693
|
+
*/
|
|
7694
|
+
// "jsdoc/match-name": ["error"|"warn", {"match":[{"disallowName":"/^opt_/i","replacement":""}]}]
|
|
7695
|
+
// Message: Only allowing names not matching `/^opt_/i` but found "opt_a".
|
|
7668
7696
|
````
|
|
7669
7697
|
|
|
7670
7698
|
The following patterns are not considered problems:
|
|
@@ -9549,7 +9577,7 @@ The following types are always considered defined.
|
|
|
9549
9577
|
- `null`, `undefined`, `void`, `string`, `boolean`, `object`,
|
|
9550
9578
|
`function`, `symbol`
|
|
9551
9579
|
- `number`, `bigint`, `NaN`, `Infinity`
|
|
9552
|
-
- `any`,
|
|
9580
|
+
- `any`, `*`, `never`, `unknown`, `const`
|
|
9553
9581
|
- `this`, `true`, `false`
|
|
9554
9582
|
- `Array`, `Object`, `RegExp`, `Date`, `Function`
|
|
9555
9583
|
|
|
@@ -9897,14 +9925,6 @@ function foo () {
|
|
|
9897
9925
|
|
|
9898
9926
|
}
|
|
9899
9927
|
|
|
9900
|
-
/**
|
|
9901
|
-
*
|
|
9902
|
-
*
|
|
9903
|
-
*/
|
|
9904
|
-
function foo () {
|
|
9905
|
-
|
|
9906
|
-
}
|
|
9907
|
-
|
|
9908
9928
|
/**
|
|
9909
9929
|
* @param {MyType} foo - Bar.
|
|
9910
9930
|
* @param {HisType} bar - Foo.
|
|
@@ -10189,6 +10209,11 @@ export class Foo {
|
|
|
10189
10209
|
}
|
|
10190
10210
|
}
|
|
10191
10211
|
// Settings: {"jsdoc":{"mode":"typescript"}}
|
|
10212
|
+
|
|
10213
|
+
/**
|
|
10214
|
+
* @type {const}
|
|
10215
|
+
*/
|
|
10216
|
+
const a = 'string';
|
|
10192
10217
|
````
|
|
10193
10218
|
|
|
10194
10219
|
|
|
@@ -20698,7 +20723,7 @@ The first option is a single string set to "always", "never", or "any"
|
|
|
20698
20723
|
(defaults to "never").
|
|
20699
20724
|
|
|
20700
20725
|
"any" is only useful with `tags` (allowing non-enforcement of lines except
|
|
20701
|
-
for particular tags)
|
|
20726
|
+
for particular tags) or with `dropEndLines`.
|
|
20702
20727
|
|
|
20703
20728
|
The second option is an object with the following optional properties.
|
|
20704
20729
|
|
|
@@ -20715,6 +20740,12 @@ Use with "always" to indicate the number of lines to require be present.
|
|
|
20715
20740
|
Use with "always" to indicate the normal lines to be added after tags should
|
|
20716
20741
|
not be added after the final tag.
|
|
20717
20742
|
|
|
20743
|
+
<a name="user-content-eslint-plugin-jsdoc-rules-tag-lines-options-41-dropendlines-defaults-to-false"></a>
|
|
20744
|
+
<a name="eslint-plugin-jsdoc-rules-tag-lines-options-41-dropendlines-defaults-to-false"></a>
|
|
20745
|
+
##### <code>dropEndLines</code> (defaults to <code>false</code>)
|
|
20746
|
+
|
|
20747
|
+
If defined, will drop end lines for the final tag only.
|
|
20748
|
+
|
|
20718
20749
|
<a name="user-content-eslint-plugin-jsdoc-rules-tag-lines-options-41-tags-default-to-empty-object"></a>
|
|
20719
20750
|
<a name="eslint-plugin-jsdoc-rules-tag-lines-options-41-tags-default-to-empty-object"></a>
|
|
20720
20751
|
##### <code>tags</code> (default to empty object)
|
|
@@ -20872,6 +20903,20 @@ The following patterns are considered problems:
|
|
|
20872
20903
|
*/
|
|
20873
20904
|
// "jsdoc/tag-lines": ["error"|"warn", "always"]
|
|
20874
20905
|
// Message: Expected 1 line between tags but found 0
|
|
20906
|
+
|
|
20907
|
+
/**
|
|
20908
|
+
* Some description
|
|
20909
|
+
* @param {string} a
|
|
20910
|
+
* @param {string} b
|
|
20911
|
+
*
|
|
20912
|
+
* @returns {SomeType} An extended
|
|
20913
|
+
* description.
|
|
20914
|
+
*
|
|
20915
|
+
* This is still part of `@returns`.
|
|
20916
|
+
*
|
|
20917
|
+
*/
|
|
20918
|
+
// "jsdoc/tag-lines": ["error"|"warn", "any",{"dropEndLines":true}]
|
|
20919
|
+
// Message: Expected no trailing lines
|
|
20875
20920
|
````
|
|
20876
20921
|
|
|
20877
20922
|
The following patterns are not considered problems:
|
|
@@ -21029,6 +21074,18 @@ The following patterns are not considered problems:
|
|
|
21029
21074
|
*
|
|
21030
21075
|
*/
|
|
21031
21076
|
// "jsdoc/tag-lines": ["error"|"warn", "always"]
|
|
21077
|
+
|
|
21078
|
+
/**
|
|
21079
|
+
* Some description
|
|
21080
|
+
* @param {string} a
|
|
21081
|
+
* @param {string} b
|
|
21082
|
+
*
|
|
21083
|
+
* @returns {SomeType} An extended
|
|
21084
|
+
* description.
|
|
21085
|
+
*
|
|
21086
|
+
* This is still part of `@returns`.
|
|
21087
|
+
*/
|
|
21088
|
+
// "jsdoc/tag-lines": ["error"|"warn", "any",{"dropEndLines":true}]
|
|
21032
21089
|
````
|
|
21033
21090
|
|
|
21034
21091
|
|
|
@@ -11,7 +11,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
11
11
|
|
|
12
12
|
// If supporting Node >= 10, we could loosen the default to this for the
|
|
13
13
|
// initial letter: \\p{Upper}
|
|
14
|
-
const matchDescriptionDefault = '^[A-Z`\\d_][\\s\\S]*[.?!`]
|
|
14
|
+
const matchDescriptionDefault = '^[A-Z`\\d_][\\s\\S]*[.?!`]\\s*$';
|
|
15
15
|
|
|
16
16
|
const stringOrDefault = (value, userDefault) => {
|
|
17
17
|
return typeof value === 'string' ? value : userDefault || matchDescriptionDefault;
|
|
@@ -70,7 +70,7 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
70
70
|
const {
|
|
71
71
|
description
|
|
72
72
|
} = utils.getDescription();
|
|
73
|
-
validateDescription(description
|
|
73
|
+
validateDescription(description);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
if (!tags || !Object.keys(tags).length) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/rules/matchDescription.js"],"names":["matchDescriptionDefault","stringOrDefault","value","userDefault","jsdoc","report","context","utils","mainDescription","matchDescription","message","tags","options","validateDescription","description","tag","mainDescriptionMatch","errorMessage","match","Object","prototype","hasOwnProperty","call","tagValue","tagName","regex","getRegexFromString","test","line","source","number","getDescription","replace","keys","length","hasOptionTag","Boolean","forEachPreferredTag","matchingJsdocTag","targetTagName","name","getTagDescription","trim","whitelistedTags","filterTags","tagsWithNames","tagsWithoutNames","getTagsByType","some","contextDefaults","meta","docs","url","schema","additionalProperties","properties","contexts","items","anyOf","type","comment","oneOf","format","patternProperties","enum"],"mappings":";;;;;;;AAAA;;;;AAEA;AACA;AACA,MAAMA,uBAAuB,GAAG,6BAAhC;;AAEA,MAAMC,eAAe,GAAG,CAACC,KAAD,EAAQC,WAAR,KAAwB;AAC9C,SAAO,OAAOD,KAAP,KAAiB,QAAjB,GACLA,KADK,GAELC,WAAW,IAAIH,uBAFjB;AAGD,CAJD;;eAMe,2BAAa,CAAC;AAC3BI,EAAAA,KAD2B;AAE3BC,EAAAA,MAF2B;AAG3BC,EAAAA,OAH2B;AAI3BC,EAAAA;AAJ2B,CAAD,KAKtB;AACJ,QAAM;AACJC,IAAAA,eADI;AAEJC,IAAAA,gBAFI;AAGJC,IAAAA,OAHI;AAIJC,IAAAA;AAJI,MAKFL,OAAO,CAACM,OAAR,CAAgB,CAAhB,KAAsB,EAL1B;;AAOA,QAAMC,mBAAmB,GAAG,CAACC,WAAD,EAAcC,GAAd,KAAsB;AAChD,QAAIC,oBAAoB,GAAGR,eAA3B;AACA,QAAIS,YAAY,GAAGP,OAAnB;;AACA,QAAI,OAAOF,eAAP,KAA2B,QAA/B,EAAyC;AACvCQ,MAAAA,oBAAoB,GAAGR,eAAe,CAACU,KAAvC;AACAD,MAAAA,YAAY,GAAGT,eAAe,CAACE,OAA/B;AACD;;AAED,QAAIM,oBAAoB,KAAK,KAAzB,KACF,CAACD,GAAD,IAAQ,CAACI,MAAM,CAACC,SAAP,CAAiBC,cAAjB,CAAgCC,IAAhC,CAAqCX,IAArC,EAA2CI,GAAG,CAACA,GAA/C,CADP,CAAJ,EAEE;AACA;AACD;;AAED,QAAIQ,QAAQ,GAAGP,oBAAf;;AACA,QAAID,GAAJ,EAAS;AACP,YAA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B,EAAE;AACjB,kBAAM;AACJF,cAAAA,KAAK,EAAE,CACL;AACEC,gBAAAA,MAAM,EAAE,OADV;AAEEH,gBAAAA,IAAI,EAAE;AAFR,eADK,EAKL;AACEK,gBAAAA,IAAI,EAAE,CACJ,IADI,CADR;AAIEL,gBAAAA,IAAI,EAAE;AAJR,eALK,EAWL;AACEL,gBAAAA,oBAAoB,EAAE,KADxB;AAEEC,gBAAAA,UAAU,EAAE;AACVrC,kBAAAA,KAAK,EAAE;AACL2C,oBAAAA,KAAK,EAAE,CACL;AACEC,sBAAAA,MAAM,EAAE,OADV;AAEEH,sBAAAA,IAAI,EAAE;AAFR,qBADK,EAKL;AACEK,sBAAAA,IAAI,EAAE,CACJ,IADI,CADR;AAIEL,sBAAAA,IAAI,EAAE;AAJR,qBALK;AADF,mBADG;AAeVjD,kBAAAA,OAAO,EAAE;AACPiD,oBAAAA,IAAI,EAAE;AADC;AAfC,iBAFd;AAqBEA,gBAAAA,IAAI,EAAE;AArBR,eAXK;AADH;AADW,WADf;AAwCJA,UAAAA,IAAI,EAAE;AAxCF;AA7DI,OAFd;AA0GEA,MAAAA,IAAI,EAAE;AA1GR,KADM,CALJ;AAmHJA,IAAAA,IAAI,EAAE;AAnHF;AAFL,CApGY,C","sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\n// If supporting Node >= 10, we could loosen the default to this for the\n// initial letter: \\\\p{Upper}\nconst matchDescriptionDefault = '^[A-Z`\\\\d_][\\\\s\\\\S]*[.?!`]$';\n\nconst stringOrDefault = (value, userDefault) => {\n return typeof value === 'string' ?\n value :\n userDefault || matchDescriptionDefault;\n};\n\nexport default iterateJsdoc(({\n jsdoc,\n report,\n context,\n utils,\n}) => {\n const {\n mainDescription,\n matchDescription,\n message,\n tags,\n } = context.options[0] || {};\n\n const validateDescription = (description, tag) => {\n let mainDescriptionMatch = mainDescription;\n let errorMessage = message;\n if (typeof mainDescription === 'object') {\n mainDescriptionMatch = mainDescription.match;\n errorMessage = mainDescription.message;\n }\n\n if (mainDescriptionMatch === false && (\n !tag || !Object.prototype.hasOwnProperty.call(tags, tag.tag))\n ) {\n return;\n }\n\n let tagValue = mainDescriptionMatch;\n if (tag) {\n const tagName = tag.tag;\n if (typeof tags[tagName] === 'object') {\n tagValue = tags[tagName].match;\n errorMessage = tags[tagName].message;\n } else {\n tagValue = tags[tagName];\n }\n }\n\n const regex = utils.getRegexFromString(\n stringOrDefault(tagValue, matchDescription),\n );\n\n if (!regex.test(description)) {\n report(\n errorMessage || 'JSDoc description does not satisfy the regex pattern.',\n null,\n tag || {\n // Add one as description would typically be into block\n line: jsdoc.source[0].number + 1,\n },\n );\n }\n };\n\n if (jsdoc.description) {\n const {\n description,\n } = utils.getDescription();\n validateDescription(\n description.replace(/\\s+$/u, ''),\n );\n }\n\n if (!tags || !Object.keys(tags).length) {\n return;\n }\n\n const hasOptionTag = (tagName) => {\n return Boolean(tags[tagName]);\n };\n\n utils.forEachPreferredTag('description', (matchingJsdocTag, targetTagName) => {\n const description = (matchingJsdocTag.name + ' ' + utils.getTagDescription(matchingJsdocTag)).trim();\n if (hasOptionTag(targetTagName)) {\n validateDescription(description, matchingJsdocTag);\n }\n }, true);\n\n const whitelistedTags = utils.filterTags(({\n tag: tagName,\n }) => {\n return hasOptionTag(tagName);\n });\n const {\n tagsWithNames,\n tagsWithoutNames,\n } = utils.getTagsByType(whitelistedTags);\n\n tagsWithNames.some((tag) => {\n const description = utils.getTagDescription(tag).replace(/^[- ]*/u, '')\n .trim();\n\n return validateDescription(description, tag);\n });\n\n tagsWithoutNames.some((tag) => {\n const description = (tag.name + ' ' + utils.getTagDescription(tag)).trim();\n\n return validateDescription(description, tag);\n });\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Enforces a regular expression pattern on descriptions.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-match-description',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n mainDescription: {\n oneOf: [\n {\n format: 'regex',\n type: 'string',\n },\n {\n type: 'boolean',\n },\n {\n additionalProperties: false,\n properties: {\n match: {\n oneOf: [\n {\n format: 'regex',\n type: 'string',\n },\n {\n type: 'boolean',\n },\n ],\n },\n message: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n matchDescription: {\n format: 'regex',\n type: 'string',\n },\n message: {\n type: 'string',\n },\n tags: {\n patternProperties: {\n '.*': {\n oneOf: [\n {\n format: 'regex',\n type: 'string',\n },\n {\n enum: [\n true,\n ],\n type: 'boolean',\n },\n {\n additionalProperties: false,\n properties: {\n match: {\n oneOf: [\n {\n format: 'regex',\n type: 'string',\n },\n {\n enum: [\n true,\n ],\n type: 'boolean',\n },\n ],\n },\n message: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n },\n type: 'object',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"matchDescription.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/rules/matchDescription.js"],"names":["matchDescriptionDefault","stringOrDefault","value","userDefault","jsdoc","report","context","utils","mainDescription","matchDescription","message","tags","options","validateDescription","description","tag","mainDescriptionMatch","errorMessage","match","Object","prototype","hasOwnProperty","call","tagValue","tagName","regex","getRegexFromString","test","line","source","number","getDescription","keys","length","hasOptionTag","Boolean","forEachPreferredTag","matchingJsdocTag","targetTagName","name","getTagDescription","trim","whitelistedTags","filterTags","tagsWithNames","tagsWithoutNames","getTagsByType","some","replace","contextDefaults","meta","docs","url","schema","additionalProperties","properties","contexts","items","anyOf","type","comment","oneOf","format","patternProperties","enum"],"mappings":";;;;;;;AAAA;;;;AAEA;AACA;AACA,MAAMA,uBAAuB,GAAG,iCAAhC;;AAEA,MAAMC,eAAe,GAAG,CAACC,KAAD,EAAQC,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H,sBAAAA,IAAI,EAAE;AAFR,qBADK,EAKL;AACEK,sBAAAA,IAAI,EAAE,CACJ,IADI,CADR;AAIEL,sBAAAA,IAAI,EAAE;AAJR,qBALK;AADF,mBADG;AAeVjD,kBAAAA,OAAO,EAAE;AACPiD,oBAAAA,IAAI,EAAE;AADC;AAfC,iBAFd;AAqBEA,gBAAAA,IAAI,EAAE;AArBR,eAXK;AADH;AADW,WADf;AAwCJA,UAAAA,IAAI,EAAE;AAxCF;AA7DI,OAFd;AA0GEA,MAAAA,IAAI,EAAE;AA1GR,KADM,CALJ;AAmHJA,IAAAA,IAAI,EAAE;AAnHF;AAFL,CAlGY,C","sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\n// If supporting Node >= 10, we could loosen the default to this for the\n// initial letter: \\\\p{Upper}\nconst matchDescriptionDefault = '^[A-Z`\\\\d_][\\\\s\\\\S]*[.?!`]\\\\s*$';\n\nconst stringOrDefault = (value, userDefault) => {\n return typeof value === 'string' ?\n value :\n userDefault || matchDescriptionDefault;\n};\n\nexport default iterateJsdoc(({\n jsdoc,\n report,\n context,\n utils,\n}) => {\n const {\n mainDescription,\n matchDescription,\n message,\n tags,\n } = context.options[0] || {};\n\n const validateDescription = (description, tag) => {\n let mainDescriptionMatch = mainDescription;\n let errorMessage = message;\n if (typeof mainDescription === 'object') {\n mainDescriptionMatch = mainDescription.match;\n errorMessage = mainDescription.message;\n }\n\n if (mainDescriptionMatch === false && (\n !tag || !Object.prototype.hasOwnProperty.call(tags, tag.tag))\n ) {\n return;\n }\n\n let tagValue = mainDescriptionMatch;\n if (tag) {\n const tagName = tag.tag;\n if (typeof tags[tagName] === 'object') {\n tagValue = tags[tagName].match;\n errorMessage = tags[tagName].message;\n } else {\n tagValue = tags[tagName];\n }\n }\n\n const regex = utils.getRegexFromString(\n stringOrDefault(tagValue, matchDescription),\n );\n\n if (!regex.test(description)) {\n report(\n errorMessage || 'JSDoc description does not satisfy the regex pattern.',\n null,\n tag || {\n // Add one as description would typically be into block\n line: jsdoc.source[0].number + 1,\n },\n );\n }\n };\n\n if (jsdoc.description) {\n const {\n description,\n } = utils.getDescription();\n validateDescription(description);\n }\n\n if (!tags || !Object.keys(tags).length) {\n return;\n }\n\n const hasOptionTag = (tagName) => {\n return Boolean(tags[tagName]);\n };\n\n utils.forEachPreferredTag('description', (matchingJsdocTag, targetTagName) => {\n const description = (matchingJsdocTag.name + ' ' + utils.getTagDescription(matchingJsdocTag)).trim();\n if (hasOptionTag(targetTagName)) {\n validateDescription(description, matchingJsdocTag);\n }\n }, true);\n\n const whitelistedTags = utils.filterTags(({\n tag: tagName,\n }) => {\n return hasOptionTag(tagName);\n });\n const {\n tagsWithNames,\n tagsWithoutNames,\n } = utils.getTagsByType(whitelistedTags);\n\n tagsWithNames.some((tag) => {\n const description = utils.getTagDescription(tag).replace(/^[- ]*/u, '')\n .trim();\n\n return validateDescription(description, tag);\n });\n\n tagsWithoutNames.some((tag) => {\n const description = (tag.name + ' ' + utils.getTagDescription(tag)).trim();\n\n return validateDescription(description, tag);\n });\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Enforces a regular expression pattern on descriptions.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-match-description',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n mainDescription: {\n oneOf: [\n {\n format: 'regex',\n type: 'string',\n },\n {\n type: 'boolean',\n },\n {\n additionalProperties: false,\n properties: {\n match: {\n oneOf: [\n {\n format: 'regex',\n type: 'string',\n },\n {\n type: 'boolean',\n },\n ],\n },\n message: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n matchDescription: {\n format: 'regex',\n type: 'string',\n },\n message: {\n type: 'string',\n },\n tags: {\n patternProperties: {\n '.*': {\n oneOf: [\n {\n format: 'regex',\n type: 'string',\n },\n {\n enum: [\n true,\n ],\n type: 'boolean',\n },\n {\n additionalProperties: false,\n properties: {\n match: {\n oneOf: [\n {\n format: 'regex',\n type: 'string',\n },\n {\n enum: [\n true,\n ],\n type: 'boolean',\n },\n ],\n },\n message: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n },\n type: 'object',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"matchDescription.js"}
|
package/dist/rules/matchName.js
CHANGED
|
@@ -58,7 +58,12 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
const fixer = () => {
|
|
61
|
-
|
|
61
|
+
for (const src of tag.source) {
|
|
62
|
+
if (src.tokens.name) {
|
|
63
|
+
src.tokens.name = src.tokens.name.replace(disallowNameRegex, replacement);
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
62
67
|
};
|
|
63
68
|
|
|
64
69
|
let {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/rules/matchName.js"],"names":["context","jsdoc","report","info","lastIndex","utils","match","options","allowName","disallowName","replacement","tags","allowNameRegex","getRegexFromString","disallowNameRegex","applicableTags","includes","getPresentTags","reported","tag","allowed","test","name","disallowed","hasRegex","fixer","source","tokens","replace","message","reportJSDoc","undefined","matchContext","meta","docs","description","url","fixable","schema","additionalProperies","properties","items","type","comment","required"],"mappings":";;;;;;;AAAA;;;;AAEA;eACe,2BAAa,CAAC;AAC3BA,EAAAA,OAD2B;AAE3BC,EAAAA,KAF2B;AAG3BC,EAAAA,MAH2B;AAI3BC,EAAAA,IAAI,EAAE;AACJC,IAAAA;AADI,GAJqB;AAO3BC,EAAAA;AAP2B,CAAD,KAQtB;AACJ,QAAM;AACJC,IAAAA;AADI,MAEFN,OAAO,CAACO,OAAR,CAAgB,CAAhB,KAAsB,EAF1B;;AAGA,MAAI,CAACD,KAAL,EAAY;AACVJ,IAAAA,MAAM,CAAC,0DAAD,CAAN;AAEA;AACD;;AAED,QAAM;AACJM,IAAAA,SADI;AAEJC,IAAAA,YAFI;AAGJC,IAAAA,WAHI;AAIJC,IAAAA,IAAI,GAAG,CACL,GADK;AAJH,MAOFL,KAAK,CAACF,SAAD,CAPT;AASA,QAAMQ,cAAc,GAAGJ,SAAS,IAAIH,KAAK,CAACQ,kBAAN,CAAyBL,SAAzB,CAApC;AACA,QAAMM,iBAAiB,GAAGL,YAAY,IAAIJ,KAAK,CAACQ,kBAAN,CAAyBJ,YAAzB,CAA1C;AAEA,MAAIM,cAAc,GAAGd,KAAK,CAACU,IAA3B;;AACA,MAAI,CAACA,IAAI,CAACK,QAAL,CAAc,GAAd,CAAL,EAAyB;AACvBD,IAAAA,cAAc,GAAGV,KAAK,CAACY,cAAN,CAAqBN,IAArB,CAAjB;AACD;;AAED,MAAIO,QAAQ,GAAG,KAAf;;AACA,OAAK,MAAMC,GAAX,IAAkBJ,cAAlB,EAAkC;AAChC,UAAMK,OAAO,GAAG,CAACR,cAAD,IAAmBA,cAAc,CAACS,IAAf,CAAoBF,GAAG,CAACG,IAAxB,CAAnC;AACA,UAAMC,UAAU,GAAGT,iBAAiB,IAAIA,iBAAiB,CAACO,IAAlB,CAAuBF,GAAG,CAACG,IAA3B,CAAxC;AACA,UAAME,QAAQ,GAAGZ,cAAc,IAAIE,iBAAnC;;AACA,QAAIU,QAAQ,IAAIJ,OAAZ,IAAuB,CAACG,UAA5B,EAAwC;AACtC;AACD;;AAED,QAAI,CAACC,QAAD,IAAaN,QAAjB,EAA2B;AACzB;AACD;;AAED,UAAMO,KAAK,GAAG,MAAM;
|
|
1
|
+
{"version":3,"sources":["../../src/rules/matchName.js"],"names":["context","jsdoc","report","info","lastIndex","utils","match","options","allowName","disallowName","replacement","tags","allowNameRegex","getRegexFromString","disallowNameRegex","applicableTags","includes","getPresentTags","reported","tag","allowed","test","name","disallowed","hasRegex","fixer","src","source","tokens","replace","message","reportJSDoc","undefined","matchContext","meta","docs","description","url","fixable","schema","additionalProperies","properties","items","type","comment","required"],"mappings":";;;;;;;AAAA;;;;AAEA;eACe,2BAAa,CAAC;AAC3BA,EAAAA,OAD2B;AAE3BC,EAAAA,KAF2B;AAG3BC,EAAAA,MAH2B;AAI3BC,EAAAA,IAAI,EAAE;AACJC,IAAAA;AADI,GAJqB;AAO3BC,EAAAA;AAP2B,CAAD,KAQtB;AACJ,QAAM;AACJC,IAAAA;AADI,MAEFN,OAAO,CAACO,OAAR,CAAgB,CAAhB,KAAsB,EAF1B;;AAGA,MAAI,CAACD,KAAL,EAAY;AACVJ,IAAAA,MAAM,CAAC,0DAAD,CAAN;AAEA;AACD;;AAED,QAAM;AACJM,IAAAA,SADI;AAEJC,IAAAA,YAFI;AAGJC,IAAAA,WAHI;AAIJC,IAAAA,IAAI,GAAG,CACL,GADK;AAJH,MAOFL,KAAK,CAACF,SAAD,CAPT;AASA,QAAMQ,cAAc,GAAGJ,SAAS,IAAIH,KAAK,CAACQ,kBAAN,CAAyBL,SAAzB,CAApC;AACA,QAAMM,iBAAiB,GAAGL,YAAY,IAAIJ,KAAK,CAACQ,kBAAN,CAAyBJ,YAAzB,CAA1C;AAEA,MAAIM,cAAc,GAAGd,KAAK,CAACU,IAA3B;;AACA,MAAI,CAACA,IAAI,CAACK,QAAL,CAAc,GAAd,CAAL,EAAyB;AACvBD,IAAAA,cAAc,GAAGV,KAAK,CAACY,cAAN,CAAqBN,IAArB,CAAjB;AACD;;AAED,MAAIO,QAAQ,GAAG,KAAf;;AACA,OAAK,MAAMC,GAAX,IAAkBJ,cAAlB,EAAkC;AAChC,UAAMK,OAAO,GAAG,CAACR,cAAD,IAAmBA,cAAc,CAACS,IAAf,CAAoBF,GAAG,CAACG,IAAxB,CAAnC;AACA,UAAMC,UAAU,GAAGT,iBAAiB,IAAIA,iBAAiB,CAACO,IAAlB,CAAuBF,GAAG,CAACG,IAA3B,CAAxC;AACA,UAA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,YAAY,EAAE,IADb;AAEDC,EAAAA,IAAI,EAAE;AACJC,IAAAA,IAAI,EAAE;AACJC,MAAAA,WAAW,EAAE,iGADT;AAEJC,MAAAA,GAAG,EAAE;AAFD,KADF;AAKJC,IAAAA,OAAO,EAAE,MALL;AAMJC,IAAAA,MAAM,EAAE,CACN;AACEC,MAAAA,mBAAmB,EAAE,KADvB;AAEEC,MAAAA,UAAU,EAAE;AACVnC,QAAAA,KAAK,EAAE;AACLkC,UAAAA,mBAAmB,EAAE,KADhB;AAELE,UAAAA,KAAK,EAAE;AACLD,YAAAA,UAAU,EAAE;AACVjC,cAAAA,SAAS,EAAE;AACTmC,gBAAAA,IAAI,EAAE;AADG,eADD;AAIVC,cAAAA,OAAO,EAAE;AACPD,gBAAAA,IAAI,EAAE;AADC,eAJC;AAOV3C,cAAAA,OAAO,EAAE;AACP2C,gBAAAA,IAAI,EAAE;AADC,eAPC;AAUVlC,cAAAA,YAAY,EAAE;AACZkC,gBAAAA,IAAI,EAAE;AADM,eAVJ;AAaVb,cAAAA,OAAO,EAAE;AACPa,gBAAAA,IAAI,EAAE;AADC,eAbC;AAgBVhC,cAAAA,IAAI,EAAE;AACJ+B,gBAAAA,KAAK,EAAE;AACLC,kBAAAA,IAAI,EAAE;AADD,iBADH;AAIJA,gBAAAA,IAAI,EAAE;AAJF;AAhBI,aADP;AAwBLA,YAAAA,IAAI,EAAE;AAxBD,WAFF;AA4BLA,UAAAA,IAAI,EAAE;AA5BD;AADG,OAFd;AAkCEE,MAAAA,QAAQ,EAAE,CACR,OADQ,CAlCZ;AAqCEF,MAAAA,IAAI,EAAE;AArCR,KADM,CANJ;AA+CJA,IAAAA,IAAI,EAAE;AA/CF;AAFL,CA5FY,C","sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\n// eslint-disable-next-line complexity\nexport default iterateJsdoc(({\n context,\n jsdoc,\n report,\n info: {\n lastIndex,\n },\n utils,\n}) => {\n const {\n match,\n } = context.options[0] || {};\n if (!match) {\n report('Rule `no-restricted-syntax` is missing a `match` option.');\n\n return;\n }\n\n const {\n allowName,\n disallowName,\n replacement,\n tags = [\n '*',\n ],\n } = match[lastIndex];\n\n const allowNameRegex = allowName && utils.getRegexFromString(allowName);\n const disallowNameRegex = disallowName && utils.getRegexFromString(disallowName);\n\n let applicableTags = jsdoc.tags;\n if (!tags.includes('*')) {\n applicableTags = utils.getPresentTags(tags);\n }\n\n let reported = false;\n for (const tag of applicableTags) {\n const allowed = !allowNameRegex || allowNameRegex.test(tag.name);\n const disallowed = disallowNameRegex && disallowNameRegex.test(tag.name);\n const hasRegex = allowNameRegex || disallowNameRegex;\n if (hasRegex && allowed && !disallowed) {\n continue;\n }\n\n if (!hasRegex && reported) {\n continue;\n }\n\n const fixer = () => {\n for (const src of tag.source) {\n if (src.tokens.name) {\n src.tokens.name = src.tokens.name.replace(\n disallowNameRegex, replacement,\n );\n break;\n }\n }\n };\n\n let {\n message,\n } = match[lastIndex];\n if (!message) {\n if (hasRegex) {\n message = disallowed ?\n `Only allowing names not matching \\`${disallowNameRegex}\\` but found \"${tag.name}\".` :\n `Only allowing names matching \\`${allowNameRegex}\\` but found \"${tag.name}\".`;\n } else {\n message = `Prohibited context for \"${tag.name}\".`;\n }\n }\n\n utils.reportJSDoc(\n message,\n hasRegex ? tag : null,\n\n // We could match up\n disallowNameRegex && replacement !== undefined ?\n fixer :\n null,\n false,\n {\n // Could also supply `context`, `comment`, `tags`\n allowName,\n disallowName,\n name: tag.name,\n },\n );\n if (!hasRegex) {\n reported = true;\n }\n }\n}, {\n matchContext: true,\n meta: {\n docs: {\n description: 'Reports the name portion of a JSDoc tag if matching or not matching a given regular expression.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-match-name',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperies: false,\n properties: {\n match: {\n additionalProperies: false,\n items: {\n properties: {\n allowName: {\n type: 'string',\n },\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n disallowName: {\n type: 'string',\n },\n message: {\n type: 'string',\n },\n tags: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n type: 'array',\n },\n },\n required: [\n 'match',\n ],\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"matchName.js"}
|
|
@@ -17,7 +17,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
17
17
|
|
|
18
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
19
|
|
|
20
|
-
const extraTypes = ['null', 'undefined', 'void', 'string', 'boolean', 'object', 'function', 'symbol', 'number', 'bigint', 'NaN', 'Infinity', 'any', '*', 'never', 'this', 'true', 'false', 'Array', 'Object', 'RegExp', 'Date', 'Function'];
|
|
20
|
+
const extraTypes = ['null', 'undefined', 'void', 'string', 'boolean', 'object', 'function', 'symbol', 'number', 'bigint', 'NaN', 'Infinity', 'any', '*', 'never', 'unknown', 'const', 'this', 'true', 'false', 'Array', 'Object', 'RegExp', 'Date', 'Function'];
|
|
21
21
|
|
|
22
22
|
const stripPseudoTypes = str => {
|
|
23
23
|
return str && str.replace(/(?:\.|<>|\.<>|\[\])$/u, '');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/rules/noUndefinedTypes.js"],"names":["extraTypes","stripPseudoTypes","str","replace","context","node","report","settings","sourceCode","utils","scopeManager","globalScope","definedTypes","options","definedPreferredTypes","preferredTypes","structuredTags","mode","Object","keys","length","values","map","preferredType","undefined","reportSettings","replacement","filter","typedefDeclarations","getAllComments","comment","value","startsWith","commentNode","flatMap","doc","tags","tag","isNamepathDefiningTag","name","ancestorNodes","currentNode","parent","push","getTemplateTags","ancestorNode","jsdoc","jsdocUtils","filterTags","templateTags","getPresentTags","closureGenericTypes","parseClosureTemplateTag","cjsOrESMScope","childScopes","block","type","allDefinedTypes","Set","variables","concat","jsdocTagsWithPossibleType","tagMightHaveTypePosition","parsedType","structuredTypes","has","Array","isArray","includes","markVariableAsUsed","iterateAllJsdocs","meta","docs","description","url","schema","additionalProperties","properties","items"],"mappings":";;;;;;;AAAA;;AAOA;;AAGA;;;;;;;;AAEA,MAAMA,UAAU,GAAG,CACjB,MADiB,EACT,WADS,EACI,MADJ,EACY,QADZ,EACsB,SADtB,EACiC,QADjC,EAEjB,UAFiB,EAEL,QAFK,EAGjB,QAHiB,EAGP,QAHO,EAGG,KAHH,EAGU,UAHV,EAIjB,KAJiB,EAIV,GAJU,EAIL,OAJK,EAKjB,MALiB,EAKT,MALS,EAKD,OALC,EAMjB,OANiB,EAMR,QANQ,EAME,QANF,EAMY,MANZ,EAMoB,UANpB,CAAnB;;AASA,MAAMC,gBAAgB,GAAIC,GAAD,IAAS;AAChC,SAAOA,GAAG,IAAIA,GAAG,CAACC,OAAJ,CAAY,uBAAZ,EAAqC,EAArC,CAAd;AACD,CAFD;;eAIe,2BAAa,CAAC;AAC3BC,EAAAA,OAD2B;AAE3BC,EAAAA,IAF2B;AAG3BC,EAAAA,MAH2B;AAI3BC,EAAAA,QAJ2B;AAK3BC,EAAAA,UAL2B;AAM3BC,EAAAA;AAN2B,CAAD,KAOtB;AAAA;;AACJ,QAAM;AACJC,IAAAA;AADI,MAEFF,UAFJ;AAGA,QAAM;AACJG,IAAAA;AADI,MAEFD,YAFJ;AAIA,QAA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AACD;;AAED,gCAAS8C,UAAT,EAAqB,CAAC;AACpBP,MAAAA,IADoB;AAEpBzB,MAAAA;AAFoB,KAAD,KAGf;AACJ,UAAIyB,IAAI,KAAK,eAAb,EAA8B;AAAA;;AAC5B,cAAMQ,eAAe,4BAAGhD,cAAc,CAACqB,GAAG,CAACA,GAAL,CAAjB,0DAAG,sBAAyBmB,IAAjD;;AACA,YAAI,CAACC,eAAe,CAACQ,GAAhB,CAAoBlC,KAApB,CAAD,KACD,CAACmC,KAAK,CAACC,OAAN,CAAcH,eAAd,CAAD,IAAmC,CAACA,eAAe,CAACI,QAAhB,CAAyBrC,KAAzB,CADnC,CAAJ,EAEE;AACAzB,UAAAA,MAAM,CAAE,aAAYyB,KAAM,iBAApB,EAAsC,IAAtC,EAA4CM,GAA5C,CAAN;AACD,SAJD,MAIO,IAAI,CAACrC,UAAU,CAACoE,QAAX,CAAoBrC,KAApB,CAAL,EAAiC;AACtC3B,UAAAA,OAAO,CAACiE,kBAAR,CAA2BtC,KAA3B;AACD;AACF;AACF,KAdD;AAeD;AACF,CAlKc,EAkKZ;AACDuC,EAAAA,gBAAgB,EAAE,IADjB;AAEDC,EAAAA,IAAI,EAAE;AACJC,IAAAA,IAAI,EAAE;AACJC,MAAAA,WAAW,EAAE,kDADT;AAEJC,MAAAA,GAAG,EAAE;AAFD,KADF;AAKJC,IAAAA,MAAM,EAAE,CACN;AACEC,MAAAA,oBAAoB,EAAE,KADxB;AAEEC,MAAAA,UAAU,EAAE;AACVjE,QAAAA,YAAY,EAAE;AACZkE,UAAAA,KAAK,EAAE;AACLtB,YAAAA,IAAI,EAAE;AADD,WADK;AAIZA,UAAAA,IAAI,EAAE;AAJM;AADJ,OAFd;AAUEA,MAAAA,IAAI,EAAE;AAVR,KADM,CALJ;AAmBJA,IAAAA,IAAI,EAAE;AAnBF;AAFL,CAlKY,C","sourcesContent":["import {\n getJSDocComment,\n\n traverse,\n parse as parseType,\n tryParse as tryParseType,\n} from '@es-joy/jsdoccomment';\nimport iterateJsdoc, {\n parseComment,\n} from '../iterateJsdoc';\nimport jsdocUtils from '../jsdocUtils';\n\nconst extraTypes = [\n 'null', 'undefined', 'void', 'string', 'boolean', 'object',\n 'function', 'symbol',\n 'number', 'bigint', 'NaN', 'Infinity',\n 'any', '*', 'never',\n 'this', 'true', 'false',\n 'Array', 'Object', 'RegExp', 'Date', 'Function',\n];\n\nconst stripPseudoTypes = (str) => {\n return str && str.replace(/(?:\\.|<>|\\.<>|\\[\\])$/u, '');\n};\n\nexport default iterateJsdoc(({\n context,\n node,\n report,\n settings,\n sourceCode,\n utils,\n}) => {\n const {\n scopeManager,\n } = sourceCode;\n const {\n globalScope,\n } = scopeManager;\n\n const {\n definedTypes = [],\n } = context.options[0] || {};\n\n let definedPreferredTypes = [];\n const {\n preferredTypes,\n structuredTags,\n mode,\n } = settings;\n if (Object.keys(preferredTypes).length) {\n definedPreferredTypes = Object.values(preferredTypes).map((preferredType) => {\n if (typeof preferredType === 'string') {\n // May become an empty string but will be filtered out below\n return stripPseudoTypes(preferredType);\n }\n\n if (!preferredType) {\n return undefined;\n }\n\n if (typeof preferredType !== 'object') {\n utils.reportSettings(\n 'Invalid `settings.jsdoc.preferredTypes`. Values must be falsy, a string, or an object.',\n );\n }\n\n return stripPseudoTypes(preferredType.replacement);\n })\n .filter((preferredType) => {\n return preferredType;\n });\n }\n\n const typedefDeclarations = context.getAllComments()\n .filter((comment) => {\n return comment.value.startsWith('*');\n })\n .map((commentNode) => {\n return parseComment(commentNode, '');\n })\n .flatMap((doc) => {\n return doc.tags.filter(({\n tag,\n }) => {\n return utils.isNamepathDefiningTag(tag);\n });\n })\n .map((tag) => {\n return tag.name;\n });\n\n const ancestorNodes = [];\n\n let currentNode = node;\n // No need for Program node?\n while (currentNode?.parent) {\n ancestorNodes.push(currentNode);\n currentNode = currentNode.parent;\n }\n\n const getTemplateTags = function (ancestorNode) {\n const commentNode = getJSDocComment(sourceCode, ancestorNode, settings);\n if (!commentNode) {\n return [];\n }\n\n const jsdoc = parseComment(commentNode, '');\n\n return jsdocUtils.filterTags(jsdoc.tags, (tag) => {\n return tag.tag === 'template';\n });\n };\n\n // `currentScope` may be `null` or `Program`, so in such a case,\n // we look to present tags instead\n const templateTags = ancestorNodes.length ?\n ancestorNodes.flatMap((ancestorNode) => {\n return getTemplateTags(ancestorNode);\n }) :\n utils.getPresentTags('template');\n\n const closureGenericTypes = templateTags.flatMap((tag) => {\n return utils.parseClosureTemplateTag(tag);\n });\n\n // In modules, including Node, there is a global scope at top with the\n // Program scope inside\n const cjsOrESMScope = globalScope.childScopes[0]?.block.type === 'Program';\n\n const allDefinedTypes = new Set(globalScope.variables.map(({\n name,\n }) => {\n return name;\n })\n\n // If the file is a module, concat the variables from the module scope.\n .concat(\n cjsOrESMScope ?\n globalScope.childScopes.flatMap(({\n variables,\n }) => {\n return variables;\n }).map(({\n name,\n }) => {\n return name;\n }) : [],\n )\n .concat(extraTypes)\n .concat(typedefDeclarations)\n .concat(definedTypes)\n .concat(definedPreferredTypes)\n .concat(settings.mode === 'jsdoc' ? [] : closureGenericTypes));\n\n const jsdocTagsWithPossibleType = utils.filterTags(({\n tag,\n }) => {\n return utils.tagMightHaveTypePosition(tag) && (tag !== 'suppress' || settings.mode !== 'closure');\n });\n\n for (const tag of jsdocTagsWithPossibleType) {\n let parsedType;\n\n try {\n parsedType = mode === 'permissive' ? tryParseType(tag.type) : parseType(tag.type, mode);\n } catch {\n // On syntax error, will be handled by valid-types.\n continue;\n }\n\n traverse(parsedType, ({\n type,\n value,\n }) => {\n if (type === 'JsdocTypeName') {\n const structuredTypes = structuredTags[tag.tag]?.type;\n if (!allDefinedTypes.has(value) &&\n (!Array.isArray(structuredTypes) || !structuredTypes.includes(value))\n ) {\n report(`The type '${value}' is undefined.`, null, tag);\n } else if (!extraTypes.includes(value)) {\n context.markVariableAsUsed(value);\n }\n }\n });\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Checks that types in jsdoc comments are defined.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-undefined-types',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n definedTypes: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"noUndefinedTypes.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/rules/noUndefinedTypes.js"],"names":["extraTypes","stripPseudoTypes","str","replace","context","node","report","settings","sourceCode","utils","scopeManager","globalScope","definedTypes","options","definedPreferredTypes","preferredTypes","structuredTags","mode","Object","keys","length","values","map","preferredType","undefined","reportSettings","replacement","filter","typedefDeclarations","getAllComments","comment","value","startsWith","commentNode","flatMap","doc","tags","tag","isNamepathDefiningTag","name","ancestorNodes","currentNode","parent","push","getTemplateTags","ancestorNode","jsdoc","jsdocUtils","filterTags","templateTags","getPresentTags","closureGenericTypes","parseClosureTemplateTag","cjsOrESMScope","childScopes","block","type","allDefinedTypes","Set","variables","concat","jsdocTagsWithPossibleType","tagMightHaveTypePosition","parsedType","structuredTypes","has","Array","isArray","includes","markVariableAsUsed","iterateAllJsdocs","meta","docs","description","url","schema","additionalProperties","properties","items"],"mappings":";;;;;;;AAAA;;AAOA;;AAGA;;;;;;;;AAEA,MAAMA,UAAU,GAAG,CACjB,MADiB,EACT,WADS,EACI,MADJ,EACY,QADZ,EACsB,SADtB,EACiC,QADjC,EAEjB,UAFiB,EAEL,QAFK,EAGjB,QAHiB,EAGP,QAHO,EAGG,KAHH,EAGU,UAHV,EAIjB,KAJiB,EAIV,GAJU,EAIL,OAJK,EAII,SAJJ,EAIe,OAJf,EAKjB,MALiB,EAKT,MALS,EAKD,OALC,EAMjB,OANiB,EAMR,QANQ,EAME,QANF,EAMY,MANZ,EAMoB,UANpB,CAAnB;;AASA,MAAMC,gBAAgB,GAAIC,GAAD,IAAS;AAChC,SAAOA,GAAG,IAAIA,GAAG,CAACC,OAAJ,CAAY,uBAAZ,EAAq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jE,QAAAA,YAAY,EAAE;AACZkE,UAAAA,KAAK,EAAE;AACLtB,YAAAA,IAAI,EAAE;AADD,WADK;AAIZA,UAAAA,IAAI,EAAE;AAJM;AADJ,OAFd;AAUEA,MAAAA,IAAI,EAAE;AAVR,KADM,CALJ;AAmBJA,IAAAA,IAAI,EAAE;AAnBF;AAFL,CAlKY,C","sourcesContent":["import {\n getJSDocComment,\n\n traverse,\n parse as parseType,\n tryParse as tryParseType,\n} from '@es-joy/jsdoccomment';\nimport iterateJsdoc, {\n parseComment,\n} from '../iterateJsdoc';\nimport jsdocUtils from '../jsdocUtils';\n\nconst extraTypes = [\n 'null', 'undefined', 'void', 'string', 'boolean', 'object',\n 'function', 'symbol',\n 'number', 'bigint', 'NaN', 'Infinity',\n 'any', '*', 'never', 'unknown', 'const',\n 'this', 'true', 'false',\n 'Array', 'Object', 'RegExp', 'Date', 'Function',\n];\n\nconst stripPseudoTypes = (str) => {\n return str && str.replace(/(?:\\.|<>|\\.<>|\\[\\])$/u, '');\n};\n\nexport default iterateJsdoc(({\n context,\n node,\n report,\n settings,\n sourceCode,\n utils,\n}) => {\n const {\n scopeManager,\n } = sourceCode;\n const {\n globalScope,\n } = scopeManager;\n\n const {\n definedTypes = [],\n } = context.options[0] || {};\n\n let definedPreferredTypes = [];\n const {\n preferredTypes,\n structuredTags,\n mode,\n } = settings;\n if (Object.keys(preferredTypes).length) {\n definedPreferredTypes = Object.values(preferredTypes).map((preferredType) => {\n if (typeof preferredType === 'string') {\n // May become an empty string but will be filtered out below\n return stripPseudoTypes(preferredType);\n }\n\n if (!preferredType) {\n return undefined;\n }\n\n if (typeof preferredType !== 'object') {\n utils.reportSettings(\n 'Invalid `settings.jsdoc.preferredTypes`. Values must be falsy, a string, or an object.',\n );\n }\n\n return stripPseudoTypes(preferredType.replacement);\n })\n .filter((preferredType) => {\n return preferredType;\n });\n }\n\n const typedefDeclarations = context.getAllComments()\n .filter((comment) => {\n return comment.value.startsWith('*');\n })\n .map((commentNode) => {\n return parseComment(commentNode, '');\n })\n .flatMap((doc) => {\n return doc.tags.filter(({\n tag,\n }) => {\n return utils.isNamepathDefiningTag(tag);\n });\n })\n .map((tag) => {\n return tag.name;\n });\n\n const ancestorNodes = [];\n\n let currentNode = node;\n // No need for Program node?\n while (currentNode?.parent) {\n ancestorNodes.push(currentNode);\n currentNode = currentNode.parent;\n }\n\n const getTemplateTags = function (ancestorNode) {\n const commentNode = getJSDocComment(sourceCode, ancestorNode, settings);\n if (!commentNode) {\n return [];\n }\n\n const jsdoc = parseComment(commentNode, '');\n\n return jsdocUtils.filterTags(jsdoc.tags, (tag) => {\n return tag.tag === 'template';\n });\n };\n\n // `currentScope` may be `null` or `Program`, so in such a case,\n // we look to present tags instead\n const templateTags = ancestorNodes.length ?\n ancestorNodes.flatMap((ancestorNode) => {\n return getTemplateTags(ancestorNode);\n }) :\n utils.getPresentTags('template');\n\n const closureGenericTypes = templateTags.flatMap((tag) => {\n return utils.parseClosureTemplateTag(tag);\n });\n\n // In modules, including Node, there is a global scope at top with the\n // Program scope inside\n const cjsOrESMScope = globalScope.childScopes[0]?.block.type === 'Program';\n\n const allDefinedTypes = new Set(globalScope.variables.map(({\n name,\n }) => {\n return name;\n })\n\n // If the file is a module, concat the variables from the module scope.\n .concat(\n cjsOrESMScope ?\n globalScope.childScopes.flatMap(({\n variables,\n }) => {\n return variables;\n }).map(({\n name,\n }) => {\n return name;\n }) : [],\n )\n .concat(extraTypes)\n .concat(typedefDeclarations)\n .concat(definedTypes)\n .concat(definedPreferredTypes)\n .concat(settings.mode === 'jsdoc' ? [] : closureGenericTypes));\n\n const jsdocTagsWithPossibleType = utils.filterTags(({\n tag,\n }) => {\n return utils.tagMightHaveTypePosition(tag) && (tag !== 'suppress' || settings.mode !== 'closure');\n });\n\n for (const tag of jsdocTagsWithPossibleType) {\n let parsedType;\n\n try {\n parsedType = mode === 'permissive' ? tryParseType(tag.type) : parseType(tag.type, mode);\n } catch {\n // On syntax error, will be handled by valid-types.\n continue;\n }\n\n traverse(parsedType, ({\n type,\n value,\n }) => {\n if (type === 'JsdocTypeName') {\n const structuredTypes = structuredTags[tag.tag]?.type;\n if (!allDefinedTypes.has(value) &&\n (!Array.isArray(structuredTypes) || !structuredTypes.includes(value))\n ) {\n report(`The type '${value}' is undefined.`, null, tag);\n } else if (!extraTypes.includes(value)) {\n context.markVariableAsUsed(value);\n }\n }\n });\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Checks that types in jsdoc comments are defined.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-undefined-types',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n definedTypes: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"noUndefinedTypes.js"}
|
package/dist/rules/tagLines.js
CHANGED
|
@@ -16,11 +16,13 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
16
16
|
}) => {
|
|
17
17
|
const [alwaysNever = 'never', {
|
|
18
18
|
count = 1,
|
|
19
|
+
dropEndLines = false,
|
|
19
20
|
noEndLines = false,
|
|
20
21
|
tags = {}
|
|
21
22
|
} = {}] = context.options;
|
|
22
23
|
jsdoc.tags.some((tg, tagIdx) => {
|
|
23
24
|
let lastTag;
|
|
25
|
+
let lastEmpty = null;
|
|
24
26
|
let reportIndex = null;
|
|
25
27
|
|
|
26
28
|
for (const [idx, {
|
|
@@ -43,14 +45,31 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
43
45
|
continue;
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
|
|
48
|
+
const empty = !tag && !name && !type && !description;
|
|
49
|
+
|
|
50
|
+
if (empty && !end && (alwaysNever === 'never' || lastTag && ((_tags$lastTag$slice2 = tags[lastTag.slice(1)]) === null || _tags$lastTag$slice2 === void 0 ? void 0 : _tags$lastTag$slice2.lines) === 'never')) {
|
|
47
51
|
reportIndex = idx;
|
|
48
52
|
continue;
|
|
49
53
|
}
|
|
50
54
|
|
|
55
|
+
if (!end) {
|
|
56
|
+
lastEmpty = empty ? idx : null;
|
|
57
|
+
}
|
|
58
|
+
|
|
51
59
|
lastTag = tag;
|
|
52
60
|
}
|
|
53
61
|
|
|
62
|
+
if (dropEndLines && lastEmpty !== null && tagIdx === jsdoc.tags.length - 1) {
|
|
63
|
+
const fixer = () => {
|
|
64
|
+
utils.removeTagItem(tagIdx, lastEmpty);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
utils.reportJSDoc('Expected no trailing lines', {
|
|
68
|
+
line: tg.source[lastEmpty].number
|
|
69
|
+
}, fixer);
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
|
|
54
73
|
if (reportIndex !== null) {
|
|
55
74
|
const fixer = () => {
|
|
56
75
|
utils.removeTagItem(tagIdx, reportIndex);
|
|
@@ -142,6 +161,9 @@ var _default = (0, _iterateJsdoc.default)(({
|
|
|
142
161
|
count: {
|
|
143
162
|
type: 'integer'
|
|
144
163
|
},
|
|
164
|
+
dropEndLines: {
|
|
165
|
+
type: 'boolean'
|
|
166
|
+
},
|
|
145
167
|
noEndLines: {
|
|
146
168
|
type: 'boolean'
|
|
147
169
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/rules/tagLines.js"],"names":["context","jsdoc","utils","alwaysNever","count","noEndLines","tags","options","some","tg","tagIdx","lastTag","reportIndex","idx","tokens","tag","name","type","description","end","source","entries","includes","slice","lines","fixer","removeTagItem","reportJSDoc","line","number","currentTag","tagSourceIdx","splice","length","push","currentTg","tagCount","defaultAlways","overrideAlways","fixCount","addLines","iterateAllJsdocs","meta","docs","url","fixable","schema","enum","additionalProperies","properties","patternProperties","additionalProperties"],"mappings":";;;;;;;AAAA;;;;eAEe,2BAAa,CAAC;AAC3BA,EAAAA,OAD2B;AAE3BC,EAAAA,KAF2B;AAG3BC,EAAAA;AAH2B,CAAD,KAItB;AACJ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GAAsB,GAAI,2BAA0Bf,KAAK,CAACS,MAAO,EAD/F,EAEE;AACEL,QAAAA;AADF,OAFF,EAKEH,KALF;AAQA,aAAO,IAAP;AACD;;AAED,WAAO,KAAP;AACD,GAnED;AAoED,CA9Ic,EA8IZ;AACDgB,EAAAA,gBAAgB,EAAE,IADjB;AAEDC,EAAAA,IAAI,EAAE;AACJC,IAAAA,IAAI,EAAE;AACJzB,MAAAA,WAAW,EAAE,4CADT;AAEJ0B,MAAAA,GAAG,EAAE;AAFD,KADF;AAKJC,IAAAA,OAAO,EAAE,MALL;AAMJC,IAAAA,MAAM,EAAE,CACN;AACEC,MAAAA,IAAI,EAAE,CACJ,QADI,EACM,KADN,EACa,OADb,CADR;AAIE9B,MAAAA,IAAI,EAAE;AAJR,KADM,EAON;AACE+B,MAAAA,mBAAmB,EAAE,KADvB;AAEEC,MAAAA,UAAU,EAAE;AACV7C,QAAAA,KAAK,EAAE;AACLa,UAAAA,IAAI,EAAE;AADD,SADG;AAIVZ,QAAAA,UAAU,EAAE;AACVY,UAAAA,IAAI,EAAE;AADI,SAJF;AAOVX,QAAAA,IAAI,EAAE;AACJ4C,UAAAA,iBAAiB,EAAE;AACjB,kBAAM;AACJC,cAAAA,oBAAoB,EAAE,KADlB;AAEJF,cAAAA,UAAU,EAAE;AACV7C,gBAAAA,KAAK,EAAE;AACLa,kBAAAA,IAAI,EAAE;AADD,iBADG;AAIVO,gBAAAA,KAAK,EAAE;AACLuB,kBAAAA,IAAI,EAAE,CACJ,QADI,EACM,OADN,EACe,KADf,CADD;AAIL9B,kBAAAA,IAAI,EAAE;AAJD;AAJG;AAFR;AADW,WADf;AAiBJA,UAAAA,IAAI,EAAE;AAjBF;AAPI,OAFd;AA6BEA,MAAAA,IAAI,EAAE;AA7BR,KAPM,CANJ;AA6CJA,IAAAA,IAAI,EAAE;AA7CF;AAFL,CA9IY,C","sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n utils,\n}) => {\n const [\n alwaysNever = 'never',\n {\n count = 1,\n noEndLines = false,\n tags = {},\n } = {},\n ] = context.options;\n\n jsdoc.tags.some((tg, tagIdx) => {\n let lastTag;\n\n let reportIndex = null;\n for (const [\n idx,\n {\n tokens: {\n tag,\n name,\n type,\n description,\n end,\n },\n },\n ] of tg.source.entries()) {\n // May be text after a line break within a tag description\n if (description) {\n reportIndex = null;\n }\n\n if (lastTag && [\n 'any', 'always',\n ].includes(tags[lastTag.slice(1)]?.lines)) {\n continue;\n }\n\n if (\n !tag && !name && !type && !description && !end &&\n (alwaysNever === 'never' ||\n lastTag && tags[lastTag.slice(1)]?.lines === 'never'\n )\n ) {\n reportIndex = idx;\n\n continue;\n }\n\n lastTag = tag;\n }\n\n if (reportIndex !== null) {\n const fixer = () => {\n utils.removeTagItem(tagIdx, reportIndex);\n };\n\n utils.reportJSDoc(\n 'Expected no lines between tags',\n {\n line: tg.source[0].number + 1,\n },\n fixer,\n );\n\n return true;\n }\n\n return false;\n });\n\n (noEndLines ? jsdoc.tags.slice(0, -1) : jsdoc.tags).some((tg, tagIdx) => {\n const lines = [];\n\n let currentTag;\n let tagSourceIdx = 0;\n for (const [\n idx,\n {\n number,\n tokens: {\n tag,\n name,\n type,\n description,\n end,\n },\n },\n ] of tg.source.entries()) {\n if (description) {\n lines.splice(0, lines.length);\n tagSourceIdx = idx;\n }\n\n if (tag) {\n currentTag = tag;\n }\n\n if (!tag && !name && !type && !description && !end) {\n lines.push({\n idx,\n number,\n });\n }\n }\n\n const currentTg = currentTag && tags[currentTag.slice(1)];\n const tagCount = currentTg?.count;\n\n const defaultAlways = alwaysNever === 'always' && currentTg?.lines !== 'never' &&\n currentTg?.lines !== 'any' && lines.length < count;\n\n let overrideAlways;\n let fixCount = count;\n if (!defaultAlways) {\n fixCount = typeof tagCount === 'number' ? tagCount : count;\n overrideAlways = currentTg?.lines === 'always' &&\n lines.length < fixCount;\n }\n\n if (defaultAlways || overrideAlways) {\n const fixer = () => {\n utils.addLines(tagIdx, lines[lines.length - 1]?.idx || tagSourceIdx + 1, fixCount - lines.length);\n };\n\n const line = lines[lines.length - 1]?.number || tg.source[tagSourceIdx].number;\n utils.reportJSDoc(\n `Expected ${fixCount} line${fixCount === 1 ? '' : 's'} between tags but found ${lines.length}`,\n {\n line,\n },\n fixer,\n );\n\n return true;\n }\n\n return false;\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Enforces lines (or no lines) between tags.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-tag-lines',\n },\n fixable: 'code',\n schema: [\n {\n enum: [\n 'always', 'any', 'never',\n ],\n type: 'string',\n },\n {\n additionalProperies: false,\n properties: {\n count: {\n type: 'integer',\n },\n noEndLines: {\n type: 'boolean',\n },\n tags: {\n patternProperties: {\n '.*': {\n additionalProperties: false,\n properties: {\n count: {\n type: 'integer',\n },\n lines: {\n enum: [\n 'always', 'never', 'any',\n ],\n type: 'string',\n },\n },\n },\n },\n type: 'object',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"tagLines.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/rules/tagLines.js"],"names":["context","jsdoc","utils","alwaysNever","count","dropEndLines","noEndLines","tags","options","some","tg","tagIdx","lastTag","lastEmpty","reportIndex","idx","tokens","tag","name","type","description","end","source","entries","includes","slice","lines","empty","length","fixer","removeTagItem","reportJSDoc","line","number","currentTag","tagSourceIdx","splice","push","currentTg","tagCount","defaultAlways","overrideAlways","fixCount","addLines","iterateAllJsdocs","meta","docs","url","fixable","schema","enum","additionalProperies","properties","patternProperties","additionalProperties"],"mappings":";;;;;;;AAAA;;;;eAEe,2BAAa,CAAC;AAC3BA,EAAAA,OAD2B;AAE3BC,EAAAA,KAF2B;AAG3BC,EAAAA;AAH2B,CAAD,KAItB;AACJ,QAAM,CACJC,WAAW,GAAG,OADV,EAEJ;AACEC,IAAAA,KAAK,GAAG,CADV;AA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AAE;AACVa,UAAAA,IAAI,EAAE;AADI,SAPF;AAUVZ,QAAAA,IAAI,EAAE;AACJ8C,UAAAA,iBAAiB,EAAE;AACjB,kBAAM;AACJC,cAAAA,oBAAoB,EAAE,KADlB;AAEJF,cAAAA,UAAU,EAAE;AACVhD,gBAAAA,KAAK,EAAE;AACLe,kBAAAA,IAAI,EAAE;AADD,iBADG;AAIVO,gBAAAA,KAAK,EAAE;AACLwB,kBAAAA,IAAI,EAAE,CACJ,QADI,EACM,OADN,EACe,KADf,CADD;AAIL/B,kBAAAA,IAAI,EAAE;AAJD;AAJG;AAFR;AADW,WADf;AAiBJA,UAAAA,IAAI,EAAE;AAjBF;AAVI,OAFd;AAgCEA,MAAAA,IAAI,EAAE;AAhCR,KAPM,CANJ;AAgDJA,IAAAA,IAAI,EAAE;AAhDF;AAFL,CArKY,C","sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n utils,\n}) => {\n const [\n alwaysNever = 'never',\n {\n count = 1,\n dropEndLines = false,\n noEndLines = false,\n tags = {},\n } = {},\n ] = context.options;\n\n jsdoc.tags.some((tg, tagIdx) => {\n let lastTag;\n let lastEmpty = null;\n\n let reportIndex = null;\n for (const [\n idx,\n {\n tokens: {\n tag,\n name,\n type,\n description,\n end,\n },\n },\n ] of tg.source.entries()) {\n // May be text after a line break within a tag description\n if (description) {\n reportIndex = null;\n }\n\n if (lastTag && [\n 'any', 'always',\n ].includes(tags[lastTag.slice(1)]?.lines)) {\n continue;\n }\n\n const empty = !tag && !name && !type && !description;\n if (\n empty && !end &&\n (alwaysNever === 'never' ||\n lastTag && tags[lastTag.slice(1)]?.lines === 'never'\n )\n ) {\n reportIndex = idx;\n\n continue;\n }\n\n if (!end) {\n lastEmpty = empty ? idx : null;\n }\n\n lastTag = tag;\n }\n\n if (dropEndLines && lastEmpty !== null && tagIdx === jsdoc.tags.length - 1) {\n const fixer = () => {\n utils.removeTagItem(tagIdx, lastEmpty);\n };\n\n utils.reportJSDoc(\n 'Expected no trailing lines',\n {\n line: tg.source[lastEmpty].number,\n },\n fixer,\n );\n\n return true;\n }\n\n if (reportIndex !== null) {\n const fixer = () => {\n utils.removeTagItem(tagIdx, reportIndex);\n };\n\n utils.reportJSDoc(\n 'Expected no lines between tags',\n {\n line: tg.source[0].number + 1,\n },\n fixer,\n );\n\n return true;\n }\n\n return false;\n });\n\n (noEndLines ? jsdoc.tags.slice(0, -1) : jsdoc.tags).some((tg, tagIdx) => {\n const lines = [];\n\n let currentTag;\n let tagSourceIdx = 0;\n for (const [\n idx,\n {\n number,\n tokens: {\n tag,\n name,\n type,\n description,\n end,\n },\n },\n ] of tg.source.entries()) {\n if (description) {\n lines.splice(0, lines.length);\n tagSourceIdx = idx;\n }\n\n if (tag) {\n currentTag = tag;\n }\n\n if (!tag && !name && !type && !description && !end) {\n lines.push({\n idx,\n number,\n });\n }\n }\n\n const currentTg = currentTag && tags[currentTag.slice(1)];\n const tagCount = currentTg?.count;\n\n const defaultAlways = alwaysNever === 'always' && currentTg?.lines !== 'never' &&\n currentTg?.lines !== 'any' && lines.length < count;\n\n let overrideAlways;\n let fixCount = count;\n if (!defaultAlways) {\n fixCount = typeof tagCount === 'number' ? tagCount : count;\n overrideAlways = currentTg?.lines === 'always' &&\n lines.length < fixCount;\n }\n\n if (defaultAlways || overrideAlways) {\n const fixer = () => {\n utils.addLines(tagIdx, lines[lines.length - 1]?.idx || tagSourceIdx + 1, fixCount - lines.length);\n };\n\n const line = lines[lines.length - 1]?.number || tg.source[tagSourceIdx].number;\n utils.reportJSDoc(\n `Expected ${fixCount} line${fixCount === 1 ? '' : 's'} between tags but found ${lines.length}`,\n {\n line,\n },\n fixer,\n );\n\n return true;\n }\n\n return false;\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Enforces lines (or no lines) between tags.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-tag-lines',\n },\n fixable: 'code',\n schema: [\n {\n enum: [\n 'always', 'any', 'never',\n ],\n type: 'string',\n },\n {\n additionalProperies: false,\n properties: {\n count: {\n type: 'integer',\n },\n dropEndLines: {\n type: 'boolean',\n },\n noEndLines: {\n type: 'boolean',\n },\n tags: {\n patternProperties: {\n '.*': {\n additionalProperties: false,\n properties: {\n count: {\n type: 'integer',\n },\n lines: {\n enum: [\n 'always', 'never', 'any',\n ],\n type: 'string',\n },\n },\n },\n },\n type: 'object',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"file":"tagLines.js"}
|
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@babel/preset-env": "^7.16.11",
|
|
26
26
|
"@babel/register": "^7.17.0",
|
|
27
27
|
"@hkdobrev/run-if-changed": "^0.3.1",
|
|
28
|
-
"@typescript-eslint/parser": "^5.
|
|
28
|
+
"@typescript-eslint/parser": "^5.14.0",
|
|
29
29
|
"babel-plugin-add-module-exports": "^1.0.4",
|
|
30
30
|
"babel-plugin-istanbul": "^6.1.1",
|
|
31
31
|
"camelcase": "^6.3.0",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"gitdown": "^3.1.5",
|
|
38
38
|
"glob": "^7.2.0",
|
|
39
39
|
"husky": "^7.0.4",
|
|
40
|
-
"lint-staged": "^12.3.
|
|
40
|
+
"lint-staged": "^12.3.5",
|
|
41
41
|
"lodash.defaultsdeep": "^4.6.1",
|
|
42
42
|
"mocha": "^9.2.1",
|
|
43
43
|
"nyc": "^15.1.0",
|
|
@@ -116,5 +116,5 @@
|
|
|
116
116
|
"test-cov": "cross-env TIMING=1 nyc --reporter text npm run test-no-cov",
|
|
117
117
|
"test-index": "npm run test-no-cov -- test/rules/index.js"
|
|
118
118
|
},
|
|
119
|
-
"version": "
|
|
119
|
+
"version": "38.0.1"
|
|
120
120
|
}
|