eslint-plugin-jsdoc 41.1.2 → 43.0.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.
@@ -1,71 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc"));
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
- var _default = (0, _iterateJsdoc.default)(({
10
- jsdoc,
11
- report,
12
- context,
13
- jsdocNode,
14
- sourceCode,
15
- indent,
16
- utils
17
- }) => {
18
- let always;
19
- if (!jsdoc.description.trim() || !jsdoc.tags.length) {
20
- return;
21
- }
22
- if (0 in context.options) {
23
- always = context.options[0] === 'always';
24
- } else {
25
- always = true;
26
- }
27
- const {
28
- description,
29
- lastDescriptionLine
30
- } = utils.getDescription();
31
- const descriptionEndsWithANewline = /\n\r?$/u.test(description);
32
- if (always) {
33
- if (!descriptionEndsWithANewline) {
34
- const sourceLines = sourceCode.getText(jsdocNode).split('\n');
35
- report('There must be a newline after the description of the JSDoc block.', fixer => {
36
- // Add the new line
37
- const injectedLine = `${indent} *` + (sourceLines[lastDescriptionLine].endsWith('\r') ? '\r' : '');
38
- sourceLines.splice(lastDescriptionLine + 1, 0, injectedLine);
39
- return fixer.replaceText(jsdocNode, sourceLines.join('\n'));
40
- }, {
41
- line: lastDescriptionLine
42
- });
43
- }
44
- } else if (descriptionEndsWithANewline) {
45
- const sourceLines = sourceCode.getText(jsdocNode).split('\n');
46
- report('There must be no newline after the description of the JSDoc block.', fixer => {
47
- // Remove the extra line
48
- sourceLines.splice(lastDescriptionLine, 1);
49
- return fixer.replaceText(jsdocNode, sourceLines.join('\n'));
50
- }, {
51
- line: lastDescriptionLine
52
- });
53
- }
54
- }, {
55
- iterateAllJsdocs: true,
56
- meta: {
57
- docs: {
58
- description: 'Enforces a consistent padding of the block description.',
59
- url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-newline-after-description'
60
- },
61
- fixable: 'whitespace',
62
- schema: [{
63
- enum: ['always', 'never'],
64
- type: 'string'
65
- }],
66
- type: 'layout'
67
- }
68
- });
69
- exports.default = _default;
70
- module.exports = exports.default;
71
- //# sourceMappingURL=newlineAfterDescription.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"newlineAfterDescription.js","names":["_iterateJsdoc","_interopRequireDefault","require","obj","__esModule","default","_default","iterateJsdoc","jsdoc","report","context","jsdocNode","sourceCode","indent","utils","always","description","trim","tags","length","options","lastDescriptionLine","getDescription","descriptionEndsWithANewline","test","sourceLines","getText","split","fixer","injectedLine","endsWith","splice","replaceText","join","line","iterateAllJsdocs","meta","docs","url","fixable","schema","enum","type","exports","module"],"sources":["../../src/rules/newlineAfterDescription.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc';\n\nexport default iterateJsdoc(({\n jsdoc,\n report,\n context,\n jsdocNode,\n sourceCode,\n indent,\n utils,\n}) => {\n let always;\n\n if (!jsdoc.description.trim() || !jsdoc.tags.length) {\n return;\n }\n\n if (0 in context.options) {\n always = context.options[0] === 'always';\n } else {\n always = true;\n }\n\n const {\n description,\n lastDescriptionLine,\n } = utils.getDescription();\n const descriptionEndsWithANewline = (/\\n\\r?$/u).test(description);\n\n if (always) {\n if (!descriptionEndsWithANewline) {\n const sourceLines = sourceCode.getText(jsdocNode).split('\\n');\n\n report('There must be a newline after the description of the JSDoc block.', (fixer) => {\n // Add the new line\n const injectedLine = `${indent} *` +\n (sourceLines[lastDescriptionLine].endsWith('\\r') ? '\\r' : '');\n sourceLines.splice(lastDescriptionLine + 1, 0, injectedLine);\n\n return fixer.replaceText(jsdocNode, sourceLines.join('\\n'));\n }, {\n line: lastDescriptionLine,\n });\n }\n } else if (descriptionEndsWithANewline) {\n const sourceLines = sourceCode.getText(jsdocNode).split('\\n');\n report('There must be no newline after the description of the JSDoc block.', (fixer) => {\n // Remove the extra line\n sourceLines.splice(lastDescriptionLine, 1);\n\n return fixer.replaceText(jsdocNode, sourceLines.join('\\n'));\n }, {\n line: lastDescriptionLine,\n });\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Enforces a consistent padding of the block description.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-newline-after-description',\n },\n fixable: 'whitespace',\n schema: [\n {\n enum: [\n 'always', 'never',\n ],\n type: 'string',\n },\n ],\n type: 'layout',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA2C,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,IAAAG,QAAA,GAE5B,IAAAC,qBAAY,EAAC,CAAC;EAC3BC,KAAK;EACLC,MAAM;EACNC,OAAO;EACPC,SAAS;EACTC,UAAU;EACVC,MAAM;EACNC;AACF,CAAC,KAAK;EACJ,IAAIC,MAAM;EAEV,IAAI,CAACP,KAAK,CAACQ,WAAW,CAACC,IAAI,EAAE,IAAI,CAACT,KAAK,CAACU,IAAI,CAACC,MAAM,EAAE;IACnD;EACF;EAEA,IAAI,CAAC,IAAIT,OAAO,CAACU,OAAO,EAAE;IACxBL,MAAM,GAAGL,OAAO,CAACU,OAAO,CAAC,CAAC,CAAC,KAAK,QAAQ;EAC1C,CAAC,MAAM;IACLL,MAAM,GAAG,IAAI;EACf;EAEA,MAAM;IACJC,WAAW;IACXK;EACF,CAAC,GAAGP,KAAK,CAACQ,cAAc,EAAE;EAC1B,MAAMC,2BAA2B,GAAI,SAAS,CAAEC,IAAI,CAACR,WAAW,CAAC;EAEjE,IAAID,MAAM,EAAE;IACV,IAAI,CAACQ,2BAA2B,EAAE;MAChC,MAAME,WAAW,GAAGb,UAAU,CAACc,OAAO,CAACf,SAAS,CAAC,CAACgB,KAAK,C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