Skip to content

Commit cf37cc6

Browse files
committed
feat(check-access): allow ignorePrivate setting to work with access private tag.
Test a rule with `iterateAllJsocs` and without.
1 parent 5d99663 commit cf37cc6

File tree

5 files changed

+55
-3
lines changed

5 files changed

+55
-3
lines changed

.README/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ supplied as the second argument in an array after the error level.
111111
### Allow `@private` to disable rules for that comment block
112112

113113
- `settings.jsdoc.ignorePrivate` - Disables all rules for the comment block
114-
on which a `@private` tag occurs. Defaults to
114+
on which a `@private` tag (or `@access private`) occurs. Defaults to
115115
`false`. Note: This has no effect with the rule `check-access` (whose
116116
purpose is to check access modifiers).
117117

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ supplied as the second argument in an array after the error level.
158158
### Allow <code>@private</code> to disable rules for that comment block
159159

160160
- `settings.jsdoc.ignorePrivate` - Disables all rules for the comment block
161-
on which a `@private` tag occurs. Defaults to
161+
on which a `@private` tag (or `@access private`) occurs. Defaults to
162162
`false`. Note: This has no effect with the rule `check-access` (whose
163163
purpose is to check access modifiers).
164164

@@ -683,6 +683,15 @@ function quux (foo) {
683683
// with spaces
684684
}
685685
// Settings: {"jsdoc":{"ignorePrivate":true}}
686+
687+
/**
688+
* @param {Number} foo
689+
* @access private
690+
*/
691+
function quux (foo) {
692+
// with spaces
693+
}
694+
// Settings: {"jsdoc":{"ignorePrivate":true}}
686695
````
687696

688697

@@ -8361,6 +8370,14 @@ function quux (foo) {
83618370
}
83628371
// Settings: {"jsdoc":{"ignorePrivate":true}}
83638372

8373+
/**
8374+
* @access private
8375+
*/
8376+
function quux (foo) {
8377+
8378+
}
8379+
// Settings: {"jsdoc":{"ignorePrivate":true}}
8380+
83648381
// issue 182: optional chaining
83658382
/** @const {boolean} test */
83668383
const test = something?.find(_ => _)

src/iterateJsdoc.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,11 @@ const iterate = (
450450
if (
451451
settings.ignorePrivate &&
452452
!ruleConfig.checkPrivate &&
453-
utils.hasTag('private')
453+
(utils.hasTag('private') || _.filter(jsdoc.tags, {
454+
tag: 'access',
455+
}).some(({description}) => {
456+
return description === 'private';
457+
}))
454458
) {
455459
return;
456460
}

test/rules/assertions/checkAlignment.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,5 +276,21 @@ function quux (foo) {
276276
},
277277
},
278278
},
279+
{
280+
code: `
281+
/**
282+
* @param {Number} foo
283+
* @access private
284+
*/
285+
function quux (foo) {
286+
// with spaces
287+
}
288+
`,
289+
settings: {
290+
jsdoc: {
291+
ignorePrivate: true,
292+
},
293+
},
294+
},
279295
],
280296
};

test/rules/assertions/requireParam.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,21 @@ export default {
910910
},
911911
},
912912
},
913+
{
914+
code: `
915+
/**
916+
* @access private
917+
*/
918+
function quux (foo) {
919+
920+
}
921+
`,
922+
settings: {
923+
jsdoc: {
924+
ignorePrivate: true,
925+
},
926+
},
927+
},
913928
{
914929
code: `
915930
// issue 182: optional chaining

0 commit comments

Comments
 (0)