Skip to content

Commit 0d930ea

Browse files
committed
INCOMPLETE: Depends on comment-parser fix: #447
fix: 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`
1 parent 1aabfd0 commit 0d930ea

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

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)