Skip to content

Commit

Permalink
feat: add fixer for no-types (#350)
Browse files Browse the repository at this point in the history
feat(no-types): add fixer; partial fix for #336 (#350)
  • Loading branch information
yeonjuan authored and brettz9 committed Jul 21, 2019
1 parent 1febd69 commit 5863029
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/rules/noTypes.js
@@ -1,18 +1,20 @@
import iterateJsdoc from '../iterateJsdoc';

export default iterateJsdoc(({
utils,
report
utils
}) => {
const tags = utils.getPresentTags(['param', 'arg', 'argument', 'returns', 'return']);

tags.forEach((tag) => {
if (tag.type) {
report(`Types are not permitted on @${tag.tag}.`, null, tag);
utils.reportJSDoc(`Types are not permitted on @${tag.tag}.`, tag, () => {
tag.type = '';
});
}
});
}, {
meta: {
fixable: true,
type: 'suggestion'
}
});
20 changes: 18 additions & 2 deletions test/rules/assertions/noTypes.js
Expand Up @@ -13,7 +13,15 @@ export default {
{
message: 'Types are not permitted on @param.'
}
]
],
output: `
/**
* @param foo
*/
function quux (foo) {
}
`
},
{
code: `
Expand All @@ -28,7 +36,15 @@ export default {
{
message: 'Types are not permitted on @returns.'
}
]
],
output: `
/**
* @returns
*/
function quux () {
}
`
}
],
valid: [
Expand Down

0 comments on commit 5863029

Please sign in to comment.