Skip to content

Commit a7bd9cd

Browse files
committed
refactoring: avoid fixer for subsequent items
1 parent cd44885 commit a7bd9cd

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/iterateJsdoc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ const getUtils = (
9999
};
100100

101101
utils.reportJSDoc = (msg, tag, handler) => {
102-
report(msg, (fixer) => {
102+
report(msg, handler ? (fixer) => {
103103
handler();
104104
const replacement = utils.stringify(jsdoc);
105105

106106
return fixer.replaceText(jsdocNode, replacement);
107-
}, tag);
107+
} : null, tag);
108108
};
109109

110110
utils.getFunctionParameterNames = () => {

src/rules/requireParam.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,15 @@ export default iterateJsdoc(({
6363
};
6464

6565
missingTags.forEach(({functionParameterName}, index) => {
66-
utils.reportJSDoc(`Missing JSDoc @${preferredTagName} "${functionParameterName}" declaration.`, null, () => {
66+
// Fix all missing tags the first time.
67+
const fixer = index > 0 ? null : () => {
6768
if (!jsdoc.tags) {
6869
jsdoc.tags = [];
6970
}
7071

71-
// Fix all missing tags at the first time.
72-
if (index === 0) {
73-
fixAll(missingTags, jsdoc.tags);
74-
}
75-
});
72+
fixAll(missingTags, jsdoc.tags);
73+
};
74+
utils.reportJSDoc(`Missing JSDoc @${preferredTagName} "${functionParameterName}" declaration.`, null, fixer);
7675
});
7776
}, {
7877
meta: {

0 commit comments

Comments
 (0)