Skip to content

Commit 5863029

Browse files
yeonjuanbrettz9
authored andcommitted
feat: add fixer for no-types (#350)
feat(no-types): add fixer; partial fix for #336 (#350)
1 parent 1febd69 commit 5863029

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

src/rules/noTypes.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
import iterateJsdoc from '../iterateJsdoc';
22

33
export default iterateJsdoc(({
4-
utils,
5-
report
4+
utils
65
}) => {
76
const tags = utils.getPresentTags(['param', 'arg', 'argument', 'returns', 'return']);
87

98
tags.forEach((tag) => {
109
if (tag.type) {
11-
report(`Types are not permitted on @${tag.tag}.`, null, tag);
10+
utils.reportJSDoc(`Types are not permitted on @${tag.tag}.`, tag, () => {
11+
tag.type = '';
12+
});
1213
}
1314
});
1415
}, {
1516
meta: {
17+
fixable: true,
1618
type: 'suggestion'
1719
}
1820
});

test/rules/assertions/noTypes.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ export default {
1313
{
1414
message: 'Types are not permitted on @param.'
1515
}
16-
]
16+
],
17+
output: `
18+
/**
19+
* @param foo
20+
*/
21+
function quux (foo) {
22+
23+
}
24+
`
1725
},
1826
{
1927
code: `
@@ -28,7 +36,15 @@ export default {
2836
{
2937
message: 'Types are not permitted on @returns.'
3038
}
31-
]
39+
],
40+
output: `
41+
/**
42+
* @returns
43+
*/
44+
function quux () {
45+
46+
}
47+
`
3248
}
3349
],
3450
valid: [

0 commit comments

Comments
 (0)