Skip to content

Commit ad5e376

Browse files
committed
fix: in conjunction with comment-parser update, remove last line break in last tag description for proper stringification (and fix old tests)
Impacts `check-param-names`, `check-property-names`, `empty-tags`, `no-defaults`, `no-types`, `require-example`, `require-param`, `require-property`. Also updating other devDeps.
1 parent f9e2283 commit ad5e376

File tree

6 files changed

+25
-19
lines changed

6 files changed

+25
-19
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5293,6 +5293,17 @@ function quux (foo) {
52935293
*/
52945294
function quux () {
52955295
5296+
}
5297+
// Message: Types are not permitted on @returns.
5298+
5299+
/**
5300+
* Beep
5301+
* Boop
5302+
*
5303+
* @returns {number}
5304+
*/
5305+
function quux () {
5306+
52965307
}
52975308
// Message: Types are not permitted on @returns.
52985309
````

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"url": "http://gajus.com"
66
},
77
"dependencies": {
8-
"comment-parser": "^0.7.2",
8+
"comment-parser": "^0.7.3",
99
"debug": "^4.1.1",
1010
"jsdoctypeparser": "^6.1.0",
1111
"lodash": "^4.17.15",
@@ -16,12 +16,12 @@
1616
"description": "JSDoc linting rules for ESLint.",
1717
"devDependencies": {
1818
"@babel/cli": "^7.8.4",
19-
"@babel/core": "^7.9.0",
19+
"@babel/core": "^7.9.6",
2020
"@babel/node": "^7.8.7",
2121
"@babel/plugin-transform-flow-strip-types": "^7.9.0",
22-
"@babel/preset-env": "^7.9.5",
22+
"@babel/preset-env": "^7.9.6",
2323
"@babel/register": "^7.9.0",
24-
"@typescript-eslint/parser": "^2.28.0",
24+
"@typescript-eslint/parser": "^2.31.0",
2525
"babel-eslint": "^10.1.0",
2626
"babel-plugin-add-module-exports": "^1.0.2",
2727
"babel-plugin-istanbul": "^6.0.0",
@@ -32,10 +32,10 @@
3232
"gitdown": "^3.1.3",
3333
"glob": "^7.1.6",
3434
"husky": "^4.2.5",
35-
"mocha": "^7.1.1",
35+
"mocha": "^7.1.2",
3636
"nyc": "^15.0.1",
3737
"rimraf": "^3.0.2",
38-
"semantic-release": "^17.0.6",
38+
"semantic-release": "^17.0.7",
3939
"typescript": "^3.8.3"
4040
},
4141
"engines": {

src/bin/generateReadme.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import glob from 'glob';
88
import Gitdown from 'gitdown';
99

1010
const trimCode = (code) => {
11-
let lines = code.replace(/^\n/u, '').trimEnd().split('\n');
11+
// todo[engine:node@>10]: Change to `trimEnd`
12+
// eslint-disable-next-line unicorn/prefer-trim-start-end
13+
let lines = code.replace(/^\n/u, '').trimRight().split('\n');
1214

1315
const firsLineIndentation = lines[0].match(/^\s+/u);
1416
const lastLineIndentation = lines[lines.length - 1].match(/^\s+/u);

src/iterateJsdoc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ const getUtils = (
154154

155155
utils.stringify = (tagBlock) => {
156156
const indent = jsdocUtils.getIndent(sourceCode);
157+
if (ruleConfig.noTrim) {
158+
const lastTag = tagBlock.tags[tagBlock.tags.length - 1];
159+
lastTag.description = lastTag.description.replace(/\n$/, '');
160+
}
157161

158162
return commentStringify([tagBlock], {indent}).slice(indent.length - 1);
159163
};

src/rules/noTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ export default iterateJsdoc(({
3636
],
3737
type: 'suggestion',
3838
},
39+
noTrim: true,
3940
});

test/rules/assertions/requireParam.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,6 @@ export default {
605605
interface ITest {
606606
/**
607607
* Test description.
608-
*
609608
* @param id
610609
*/
611610
TestMethod(id: number): void;
@@ -645,7 +644,6 @@ export default {
645644
{
646645
/**
647646
* A test method.
648-
*
649647
* @param id
650648
*/
651649
abstract TestFunction(id);
@@ -712,7 +710,6 @@ export default {
712710
output: `
713711
/**
714712
* A test function.
715-
*
716713
* @param id
717714
*/
718715
declare let TestFunction: (id) => void;
@@ -740,7 +737,6 @@ export default {
740737
output: `
741738
/**
742739
* A test function.
743-
*
744740
* @param id
745741
*/
746742
let TestFunction: (id) => void;
@@ -772,7 +768,6 @@ export default {
772768
output: `
773769
/**
774770
* A test function.
775-
*
776771
* @param id
777772
*/
778773
function test(
@@ -807,7 +802,6 @@ export default {
807802
output: `
808803
/**
809804
* A test function.
810-
*
811805
* @param id
812806
*/
813807
let test = (processor: (id: number) => string) =>
@@ -841,7 +835,6 @@ export default {
841835
class TestClass {
842836
/**
843837
* A class property.
844-
*
845838
* @param id
846839
*/
847840
public Test: (id: number) => string;
@@ -875,7 +868,6 @@ export default {
875868
class TestClass {
876869
/**
877870
* A class method.
878-
*
879871
* @param id
880872
*/
881873
public TestMethod(): (id: number) => string
@@ -909,7 +901,6 @@ export default {
909901
interface TestInterface {
910902
/**
911903
* An interface property.
912-
*
913904
* @param id
914905
*/
915906
public Test: (id: number) => string;
@@ -941,7 +932,6 @@ export default {
941932
interface TestInterface {
942933
/**
943934
* An interface method.
944-
*
945935
* @param id
946936
*/
947937
public TestMethod(): (id: number) => string;
@@ -970,7 +960,6 @@ export default {
970960
output: `
971961
/**
972962
* A function with return type
973-
*
974963
* @param id
975964
*/
976965
function test(): (id: number) => string;
@@ -1001,7 +990,6 @@ export default {
1001990
output: `
1002991
/**
1003992
* A function with return type
1004-
*
1005993
* @param id
1006994
*/
1007995
let test = (): (id: number) => string =>

0 commit comments

Comments
 (0)