eslint-plugin-jsdoc 54.3.1 → 54.4.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.
|
@@ -6,40 +6,46 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs"));
|
|
8
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
/**
|
|
10
|
-
* @param {string} string
|
|
11
|
-
* @returns {string}
|
|
12
|
-
*/
|
|
13
|
-
const trimStart = string => {
|
|
14
|
-
return string.replace(/^\s+/v, '');
|
|
15
|
-
};
|
|
16
9
|
var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
10
|
+
context,
|
|
17
11
|
indent,
|
|
18
12
|
jsdocNode,
|
|
19
13
|
report,
|
|
20
14
|
sourceCode
|
|
21
15
|
}) => {
|
|
16
|
+
const {
|
|
17
|
+
innerIndent = 1
|
|
18
|
+
} = context.options[0] || {};
|
|
19
|
+
|
|
22
20
|
// `indent` is whitespace from line 1 (`/**`), so slice and account for "/".
|
|
23
|
-
const indentLevel = indent.length +
|
|
24
|
-
const sourceLines = sourceCode.getText(jsdocNode).split('\n').slice(1).map(line => {
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
const indentLevel = indent.length + innerIndent;
|
|
22
|
+
const sourceLines = sourceCode.getText(jsdocNode).split('\n').slice(1).map((line, number) => {
|
|
23
|
+
return {
|
|
24
|
+
line: line.split('*')[0],
|
|
25
|
+
number
|
|
26
|
+
};
|
|
27
|
+
}).filter(({
|
|
28
|
+
line
|
|
29
|
+
}) => {
|
|
30
|
+
return !line.trimStart().length;
|
|
28
31
|
});
|
|
29
32
|
|
|
30
33
|
/** @type {import('eslint').Rule.ReportFixer} */
|
|
31
34
|
const fix = fixer => {
|
|
32
35
|
const replacement = sourceCode.getText(jsdocNode).split('\n').map((line, index) => {
|
|
33
36
|
// Ignore the first line and all lines not starting with `*`
|
|
34
|
-
const ignored = !index ||
|
|
35
|
-
return ignored ? line : `${indent} ${trimStart(
|
|
37
|
+
const ignored = !index || line.split('*')[0].trimStart().length;
|
|
38
|
+
return ignored ? line : `${indent}${''.padStart(innerIndent, ' ')}${line.trimStart()}`;
|
|
36
39
|
}).join('\n');
|
|
37
40
|
return fixer.replaceText(jsdocNode, replacement);
|
|
38
41
|
};
|
|
39
|
-
sourceLines.some((
|
|
42
|
+
sourceLines.some(({
|
|
43
|
+
line,
|
|
44
|
+
number
|
|
45
|
+
}) => {
|
|
40
46
|
if (line.length !== indentLevel) {
|
|
41
47
|
report('Expected JSDoc block to be aligned.', fix, {
|
|
42
|
-
line:
|
|
48
|
+
line: number + 1
|
|
43
49
|
});
|
|
44
50
|
return true;
|
|
45
51
|
}
|
|
@@ -53,6 +59,15 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
|
|
|
53
59
|
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-alignment.md#repos-sticky-header'
|
|
54
60
|
},
|
|
55
61
|
fixable: 'code',
|
|
62
|
+
schema: [{
|
|
63
|
+
additionalProperties: false,
|
|
64
|
+
properties: {
|
|
65
|
+
innerIndent: {
|
|
66
|
+
default: 1,
|
|
67
|
+
type: 'integer'
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}],
|
|
56
71
|
type: 'layout'
|
|
57
72
|
}
|
|
58
73
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkAlignment.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","
|
|
1
|
+
{"version":3,"file":"checkAlignment.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","context","indent","jsdocNode","report","sourceCode","innerIndent","options","indentLevel","length","sourceLines","getText","split","slice","map","line","number","filter","trimStart","fix","fixer","replacement","index","ignored","padStart","join","replaceText","some","iterateAllJsdocs","meta","docs","description","url","fixable","schema","additionalProperties","properties","type","module"],"sources":["../../src/rules/checkAlignment.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n context,\n indent,\n jsdocNode,\n report,\n sourceCode,\n}) => {\n const {\n innerIndent = 1,\n } = context.options[0] || {};\n\n // `indent` is whitespace from line 1 (`/**`), so slice and account for \"/\".\n const indentLevel = indent.length + innerIndent;\n const sourceLines = sourceCode.getText(jsdocNode).split('\\n')\n .slice(1)\n .map((line, number) => {\n return {\n line: line.split('*')[0],\n number,\n };\n })\n .filter(({\n line,\n }) => {\n return !line.trimStart().length;\n });\n\n /** @type {import('eslint').Rule.ReportFixer} */\n const fix = (fixer) => {\n const replacement = sourceCode.getText(jsdocNode).split('\\n')\n .map((line, index) => {\n // Ignore the first line and all lines not starting with `*`\n const ignored = !index || line.split('*')[0].trimStart().length;\n\n return ignored ? line : `${indent}${''.padStart(innerIndent, ' ')}${line.trimStart()}`;\n })\n .join('\\n');\n\n return fixer.replaceText(jsdocNode, replacement);\n };\n\n sourceLines.some(({\n line,\n number,\n }) => {\n if (line.length !== indentLevel) {\n report('Expected JSDoc block to be aligned.', fix, {\n line: number + 1,\n });\n\n return true;\n }\n\n return false;\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Reports invalid alignment of JSDoc block asterisks.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-alignment.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n innerIndent: {\n default: 1,\n type: 'integer',\n },\n },\n },\n ],\n type: 'layout',\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,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,CAAC,CACDO,IAAI,CAAC,IAAI,CAAC;IAEb,OAAOL,KAAK,CAACM,WAAW,CAACvB,SAAS,EAAEkB,WAAW,CAAC;EAClD,CAAC;EAEDX,WAAW,CAACiB,IAAI,CAAC,CAAC;IAChBZ,IAAI;IACJC;EACF,CAAC,KAAK;IACJ,IAAID,IAAI,CAACN,MAAM,KAAKD,WAAW,EAAE;MAC/BJ,MAAM,CAAC,qCAAqC,EAAEe,GAAG,EAAE;QACjDJ,IAAI,EAAEC,MAAM,GAAG;MACjB,CAAC,CAAC;MAEF,OAAO,IAAI;IACb;IAEA,OAAO,KAAK;EACd,CAAC,CAAC;AACJ,CAAC,EAAE;EACDY,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,qDAAqD;MAClEC,GAAG,EAAE;IACP,CAAC;IACDC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACV9B,WAAW,EAAE;UACXT,OAAO,EAAE,CAAC;UACVwC,IAAI,EAAE;QACR;MACF;IACF,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAC,MAAA,CAAAvC,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
import iterateJsdoc from '../iterateJsdoc.js';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* @param {string} string
|
|
5
|
-
* @returns {string}
|
|
6
|
-
*/
|
|
7
|
-
const trimStart = (string) => {
|
|
8
|
-
return string.replace(/^\s+/v, '');
|
|
9
|
-
};
|
|
10
|
-
|
|
11
3
|
export default iterateJsdoc(({
|
|
4
|
+
context,
|
|
12
5
|
indent,
|
|
13
6
|
jsdocNode,
|
|
14
7
|
report,
|
|
15
8
|
sourceCode,
|
|
16
9
|
}) => {
|
|
10
|
+
const {
|
|
11
|
+
innerIndent = 1,
|
|
12
|
+
} = context.options[0] || {};
|
|
13
|
+
|
|
17
14
|
// `indent` is whitespace from line 1 (`/**`), so slice and account for "/".
|
|
18
|
-
const indentLevel = indent.length +
|
|
15
|
+
const indentLevel = indent.length + innerIndent;
|
|
19
16
|
const sourceLines = sourceCode.getText(jsdocNode).split('\n')
|
|
20
17
|
.slice(1)
|
|
21
|
-
.map((line) => {
|
|
22
|
-
return
|
|
18
|
+
.map((line, number) => {
|
|
19
|
+
return {
|
|
20
|
+
line: line.split('*')[0],
|
|
21
|
+
number,
|
|
22
|
+
};
|
|
23
23
|
})
|
|
24
|
-
.filter((
|
|
25
|
-
|
|
24
|
+
.filter(({
|
|
25
|
+
line,
|
|
26
|
+
}) => {
|
|
27
|
+
return !line.trimStart().length;
|
|
26
28
|
});
|
|
27
29
|
|
|
28
30
|
/** @type {import('eslint').Rule.ReportFixer} */
|
|
@@ -30,19 +32,22 @@ export default iterateJsdoc(({
|
|
|
30
32
|
const replacement = sourceCode.getText(jsdocNode).split('\n')
|
|
31
33
|
.map((line, index) => {
|
|
32
34
|
// Ignore the first line and all lines not starting with `*`
|
|
33
|
-
const ignored = !index ||
|
|
35
|
+
const ignored = !index || line.split('*')[0].trimStart().length;
|
|
34
36
|
|
|
35
|
-
return ignored ? line : `${indent} ${trimStart(
|
|
37
|
+
return ignored ? line : `${indent}${''.padStart(innerIndent, ' ')}${line.trimStart()}`;
|
|
36
38
|
})
|
|
37
39
|
.join('\n');
|
|
38
40
|
|
|
39
41
|
return fixer.replaceText(jsdocNode, replacement);
|
|
40
42
|
};
|
|
41
43
|
|
|
42
|
-
sourceLines.some((
|
|
44
|
+
sourceLines.some(({
|
|
45
|
+
line,
|
|
46
|
+
number,
|
|
47
|
+
}) => {
|
|
43
48
|
if (line.length !== indentLevel) {
|
|
44
49
|
report('Expected JSDoc block to be aligned.', fix, {
|
|
45
|
-
line:
|
|
50
|
+
line: number + 1,
|
|
46
51
|
});
|
|
47
52
|
|
|
48
53
|
return true;
|
|
@@ -58,6 +63,17 @@ export default iterateJsdoc(({
|
|
|
58
63
|
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-alignment.md#repos-sticky-header',
|
|
59
64
|
},
|
|
60
65
|
fixable: 'code',
|
|
66
|
+
schema: [
|
|
67
|
+
{
|
|
68
|
+
additionalProperties: false,
|
|
69
|
+
properties: {
|
|
70
|
+
innerIndent: {
|
|
71
|
+
default: 1,
|
|
72
|
+
type: 'integer',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
],
|
|
61
77
|
type: 'layout',
|
|
62
78
|
},
|
|
63
79
|
});
|