eslint-plugin-jsdoc 50.5.0 → 50.6.0
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.
|
@@ -15,6 +15,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
15
15
|
}) => {
|
|
16
16
|
var _tokenBefore$loc, _jsdocNode$loc;
|
|
17
17
|
const {
|
|
18
|
+
checkBlockStarts,
|
|
18
19
|
lines = 1,
|
|
19
20
|
ignoreSameLine = true,
|
|
20
21
|
excludedTags = ['type']
|
|
@@ -26,7 +27,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
26
27
|
includeComments: true
|
|
27
28
|
});
|
|
28
29
|
const tokenBefore = tokensBefore.slice(-1)[0];
|
|
29
|
-
if (!tokenBefore) {
|
|
30
|
+
if (!tokenBefore || tokenBefore.value === '{' && !checkBlockStarts) {
|
|
30
31
|
return;
|
|
31
32
|
}
|
|
32
33
|
if (((_tokenBefore$loc = tokenBefore.loc) === null || _tokenBefore$loc === void 0 || (_tokenBefore$loc = _tokenBefore$loc.end) === null || _tokenBefore$loc === void 0 ? void 0 : _tokenBefore$loc.line) + lines >= ( /** @type {number} */(_jsdocNode$loc = jsdocNode.loc) === null || _jsdocNode$loc === void 0 || (_jsdocNode$loc = _jsdocNode$loc.start) === null || _jsdocNode$loc === void 0 ? void 0 : _jsdocNode$loc.line)) {
|
|
@@ -74,6 +75,9 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
74
75
|
schema: [{
|
|
75
76
|
additionalProperties: false,
|
|
76
77
|
properties: {
|
|
78
|
+
checkBlockStarts: {
|
|
79
|
+
type: 'boolean'
|
|
80
|
+
},
|
|
77
81
|
excludedTags: {
|
|
78
82
|
type: 'array',
|
|
79
83
|
items: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linesBeforeBlock.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","context","jsdocNode","sourceCode","report","utils","_tokenBefore$loc","_jsdocNode$loc","lines","ignoreSameLine","excludedTags","options","hasATag","tokensBefore","getTokensBefore","includeComments","tokenBefore","slice","loc","end","line","start","_jsdocNode$loc2","_tokenBefore$loc2","startLine","sameLine","fix","fixer","indent","_jsdocNode$loc3","_tokenBefore$loc3","_jsdocNode$value$matc","spaceDiff","column","
|
|
1
|
+
{"version":3,"file":"linesBeforeBlock.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","context","jsdocNode","sourceCode","report","utils","_tokenBefore$loc","_jsdocNode$loc","checkBlockStarts","lines","ignoreSameLine","excludedTags","options","hasATag","tokensBefore","getTokensBefore","includeComments","tokenBefore","slice","value","loc","end","line","start","_jsdocNode$loc2","_tokenBefore$loc2","startLine","sameLine","fix","fixer","indent","_jsdocNode$loc3","_tokenBefore$loc3","_jsdocNode$value$matc","spaceDiff","column","match","tokenPrior","startColumn","_tokenPrior","_tokenPrior$loc","pop","repeat","insertTextAfter","iterateAllJsdocs","meta","fixable","docs","description","url","schema","additionalProperties","properties","type","items","module"],"sources":["../../src/rules/linesBeforeBlock.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n context,\n jsdocNode,\n sourceCode,\n report,\n utils,\n}) => {\n const {\n checkBlockStarts,\n lines = 1,\n ignoreSameLine = true,\n excludedTags = ['type']\n } = context.options[0] || {};\n\n if (utils.hasATag(excludedTags)) {\n return;\n }\n\n const tokensBefore = sourceCode.getTokensBefore(jsdocNode, {includeComments: true});\n const tokenBefore = tokensBefore.slice(-1)[0];\n if (!tokenBefore || (tokenBefore.value === '{' && !checkBlockStarts)) {\n return;\n }\n\n if (tokenBefore.loc?.end?.line + lines >=\n /** @type {number} */\n (jsdocNode.loc?.start?.line)\n ) {\n const startLine = jsdocNode.loc?.start?.line;\n const sameLine = tokenBefore.loc?.end?.line === startLine;\n\n if (sameLine && ignoreSameLine) {\n return;\n }\n\n /** @type {import('eslint').Rule.ReportFixer} */\n const fix = (fixer) => {\n let indent = '';\n if (sameLine) {\n const spaceDiff = /** @type {number} */ (jsdocNode.loc?.start?.column) -\n /** @type {number} */ (tokenBefore.loc?.end?.column);\n // @ts-expect-error Should be a comment\n indent = /** @type {import('estree').Comment} */ (\n jsdocNode\n ).value.match(/^\\*\\n([ \\t]*) \\*/)?.[1]?.slice(spaceDiff);\n if (!indent) {\n /** @type {import('eslint').AST.Token|import('estree').Comment|undefined} */\n let tokenPrior = tokenBefore;\n let startColumn;\n while (tokenPrior && tokenPrior?.loc?.start?.line === startLine) {\n startColumn = tokenPrior.loc?.start?.column;\n tokenPrior = tokensBefore.pop();\n }\n indent = ' '.repeat(\n /* c8 ignore next */\n /** @type {number} */ (startColumn ? startColumn - 1 : 0)\n );\n }\n }\n\n return fixer.insertTextAfter(\n /** @type {import('eslint').AST.Token} */\n (tokenBefore),\n '\\n'.repeat(lines) +\n (sameLine ? '\\n' + indent : '')\n );\n };\n report(`Required ${lines} line(s) before JSDoc block`, fix);\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n fixable: 'code',\n docs: {\n description: 'Enforces minimum number of newlines before JSDoc comment blocks',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/lines-before-block.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n checkBlockStarts: {\n type: 'boolean',\n },\n excludedTags: {\n type: 'array',\n items: {\n type: 'string'\n }\n },\n ignoreSameLine: {\n type: 'boolean',\n },\n lines: {\n type: 'integer'\n }\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8C,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,IAAAG,QAAA,GAAAC,OA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reList":[]}
|
package/package.json
CHANGED
|
@@ -134,7 +134,11 @@
|
|
|
134
134
|
},
|
|
135
135
|
"repository": {
|
|
136
136
|
"type": "git",
|
|
137
|
-
"url": "https://github.com/gajus/eslint-plugin-jsdoc"
|
|
137
|
+
"url": "git+https://github.com/gajus/eslint-plugin-jsdoc.git"
|
|
138
|
+
},
|
|
139
|
+
"homepage": "https://github.com/gajus/eslint-plugin-jsdoc#readme",
|
|
140
|
+
"bugs": {
|
|
141
|
+
"url": "https://github.com/gajus/eslint-plugin-jsdoc/issues"
|
|
138
142
|
},
|
|
139
143
|
"run-if-changed": {
|
|
140
144
|
"package-lock.json": "npm run install-offline"
|
|
@@ -157,5 +161,5 @@
|
|
|
157
161
|
"test-cov": "cross-env TIMING=1 c8 --reporter text npm run test-no-cov",
|
|
158
162
|
"test-index": "npm run test-no-cov -- test/rules/index.js"
|
|
159
163
|
},
|
|
160
|
-
"version": "50.
|
|
164
|
+
"version": "50.6.0"
|
|
161
165
|
}
|
|
@@ -8,6 +8,7 @@ export default iterateJsdoc(({
|
|
|
8
8
|
utils,
|
|
9
9
|
}) => {
|
|
10
10
|
const {
|
|
11
|
+
checkBlockStarts,
|
|
11
12
|
lines = 1,
|
|
12
13
|
ignoreSameLine = true,
|
|
13
14
|
excludedTags = ['type']
|
|
@@ -19,7 +20,7 @@ export default iterateJsdoc(({
|
|
|
19
20
|
|
|
20
21
|
const tokensBefore = sourceCode.getTokensBefore(jsdocNode, {includeComments: true});
|
|
21
22
|
const tokenBefore = tokensBefore.slice(-1)[0];
|
|
22
|
-
if (!tokenBefore) {
|
|
23
|
+
if (!tokenBefore || (tokenBefore.value === '{' && !checkBlockStarts)) {
|
|
23
24
|
return;
|
|
24
25
|
}
|
|
25
26
|
|
|
@@ -80,6 +81,9 @@ export default iterateJsdoc(({
|
|
|
80
81
|
{
|
|
81
82
|
additionalProperties: false,
|
|
82
83
|
properties: {
|
|
84
|
+
checkBlockStarts: {
|
|
85
|
+
type: 'boolean',
|
|
86
|
+
},
|
|
83
87
|
excludedTags: {
|
|
84
88
|
type: 'array',
|
|
85
89
|
items: {
|