Skip to content

Commit 0fae7ae

Browse files
committed
refactor: change option extraction codes
1 parent 8033309 commit 0fae7ae

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

src/rules/requireExample.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,15 @@ export default iterateJsdoc(({
1414
return;
1515
}
1616

17-
const options = context.options[0] || {
18-
avoidExampleOnConstructors: false
19-
};
17+
const {avoidExampleOnConstructors = false} = context.options[0] || {};
2018

2119
const targetTagName = 'example';
2220

2321
const functionExamples = _.filter(jsdoc.tags, {
2422
tag: targetTagName
2523
});
2624

27-
if (options.avoidExampleOnConstructors && (
25+
if (avoidExampleOnConstructors && (
2826
utils.hasATag([
2927
'class',
3028
'constructor'

src/rules/requireReturns.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ export default iterateJsdoc(({
5454
return;
5555
}
5656

57-
const options = context.options[0] || {
58-
forceRequireReturn: false,
59-
forceReturnsWithAsync: false
60-
};
57+
const {
58+
forceRequireReturn = false,
59+
forceReturnsWithAsync = false
60+
} = context.options[0] || {};
6161

6262
const tagName = utils.getPreferredTagName('returns');
6363
if (!tagName) {
@@ -73,7 +73,7 @@ export default iterateJsdoc(({
7373
const [tag] = tags;
7474
const missingReturnTag = typeof tag === 'undefined' || tag === null;
7575
if (missingReturnTag &&
76-
((utils.isAsync() && !utils.hasReturnValue(true) ? options.forceReturnsWithAsync : utils.hasReturnValue()) || options.forceRequireReturn)
76+
((utils.isAsync() && !utils.hasReturnValue(true) ? forceReturnsWithAsync : utils.hasReturnValue()) || forceRequireReturn)
7777
) {
7878
report(`Missing JSDoc @${tagName} declaration.`);
7979
}

src/rules/validTypes.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ export default iterateJsdoc(({
1212
}) => {
1313
warnRemovedSettings(context, 'valid-types');
1414

15-
const options = context.options[0] || {
16-
allowEmptyNamepaths: true,
17-
checkSeesForNamepaths: false
18-
};
15+
const {
16+
allowEmptyNamepaths = true,
17+
checkSeesForNamepaths = false
18+
} = context.options[0] || {};
1919

2020
if (!jsdoc.tags) {
2121
return;
@@ -75,8 +75,8 @@ export default iterateJsdoc(({
7575

7676
validTypeParsing(thatNamepath);
7777
}
78-
} else if (utils.isNamepathTag(tag.tag, options.checkSeesForNamepaths)) {
79-
if (utils.passesEmptyNamepathCheck(tag, options.allowEmptyNamepaths)) {
78+
} else if (utils.isNamepathTag(tag.tag, checkSeesForNamepaths)) {
79+
if (utils.passesEmptyNamepathCheck(tag, allowEmptyNamepaths)) {
8080
return;
8181
}
8282
validTypeParsing(tag.name, tag.tag);

0 commit comments

Comments
 (0)