Skip to content

Commit

Permalink
feat(check-access): allow ignorePrivate setting to work with `acc…
Browse files Browse the repository at this point in the history
…ess private` tag.

Test a rule with `iterateAllJsocs` and without.
  • Loading branch information
brettz9 committed Dec 31, 2019
1 parent 5d99663 commit cf37cc6
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .README/README.md
Expand Up @@ -111,7 +111,7 @@ supplied as the second argument in an array after the error level.
### Allow `@private` to disable rules for that comment block

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

Expand Down
19 changes: 18 additions & 1 deletion README.md
Expand Up @@ -158,7 +158,7 @@ supplied as the second argument in an array after the error level.
### Allow <code>@private</code> to disable rules for that comment block

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

Expand Down Expand Up @@ -683,6 +683,15 @@ function quux (foo) {
// with spaces
}
// Settings: {"jsdoc":{"ignorePrivate":true}}

/**
* @param {Number} foo
* @access private
*/
function quux (foo) {
// with spaces
}
// Settings: {"jsdoc":{"ignorePrivate":true}}
````


Expand Down Expand Up @@ -8361,6 +8370,14 @@ function quux (foo) {
}
// Settings: {"jsdoc":{"ignorePrivate":true}}

/**
* @access private
*/
function quux (foo) {

}
// Settings: {"jsdoc":{"ignorePrivate":true}}

// issue 182: optional chaining
/** @const {boolean} test */
const test = something?.find(_ => _)
Expand Down
6 changes: 5 additions & 1 deletion src/iterateJsdoc.js
Expand Up @@ -450,7 +450,11 @@ const iterate = (
if (
settings.ignorePrivate &&
!ruleConfig.checkPrivate &&
utils.hasTag('private')
(utils.hasTag('private') || _.filter(jsdoc.tags, {
tag: 'access',
}).some(({description}) => {
return description === 'private';
}))
) {
return;
}
Expand Down
16 changes: 16 additions & 0 deletions test/rules/assertions/checkAlignment.js
Expand Up @@ -276,5 +276,21 @@ function quux (foo) {
},
},
},
{
code: `
/**
* @param {Number} foo
* @access private
*/
function quux (foo) {
// with spaces
}
`,
settings: {
jsdoc: {
ignorePrivate: true,
},
},
},
],
};
15 changes: 15 additions & 0 deletions test/rules/assertions/requireParam.js
Expand Up @@ -910,6 +910,21 @@ export default {
},
},
},
{
code: `
/**
* @access private
*/
function quux (foo) {
}
`,
settings: {
jsdoc: {
ignorePrivate: true,
},
},
},
{
code: `
// issue 182: optional chaining
Expand Down

0 comments on commit cf37cc6

Please sign in to comment.