Skip to content

Commit

Permalink
feat: Strip new lines and excess spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
cartant committed Mar 14, 2021
1 parent 43ad121 commit 16d19d0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
9 changes: 6 additions & 3 deletions source/rules/no-deprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,13 @@ const rule = ruleCreator({
) {
return;
}
const comment = getTag("deprecated", identifier, typeChecker);
if (comment !== undefined) {
const tag = getTag("deprecated", identifier, typeChecker);
if (tag !== undefined) {
context.report({
data: { comment, name: identifier.text },
data: {
comment: tag.replace(/[\n\r\s\t]+/g, " "),
name: identifier.text,
},
messageId: "forbidden",
node,
});
Expand Down
24 changes: 24 additions & 0 deletions tests/rules/no-deprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,5 +325,29 @@ ruleTester({ comments: true, types: true }).run("no-deprecated", rule, {
],
}
),
fromFixture(
stripIndent`
// Multi-line comments
/**
* @deprecated Don't
* use this
* function
*/
declare function func(): void;
func();
~~~~ [forbidden { "comment": "Don't use this function", "name": "func" }]
`
),
fromFixture(
stripIndent`
// Multi-space comments
/**
* @deprecated Don't use this function
*/
declare function func(): void;
func();
~~~~ [forbidden { "comment": "Don't use this function", "name": "func" }]
`
),
],
});

0 comments on commit 16d19d0

Please sign in to comment.