Skip to content

Commit ff98a3f

Browse files
authored
Merge pull request #236 from brettz9/ignore-private
- `ignorePrivate` setting; fixes #78
2 parents c269413 + 8cea022 commit ff98a3f

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2848,6 +2848,14 @@ class A {
28482848

28492849
}
28502850
}
2851+
2852+
/**
2853+
* @private
2854+
*/
2855+
function quux (foo) {
2856+
2857+
}
2858+
// Settings: {"jsdoc":{"ignorePrivate":true}}
28512859
````
28522860

28532861

src/iterateJsdoc.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,7 @@ export {
230230
parseComment
231231
};
232232

233-
export default (iterator, options) => {
234-
const opts = options || {};
235-
233+
export default (iterator, opts = {}) => {
236234
return {
237235
/**
238236
* The entrypoint for the JSDoc rule.
@@ -246,6 +244,9 @@ export default (iterator, options) => {
246244
create (context) {
247245
const sourceCode = context.getSourceCode();
248246

247+
// All rules
248+
const ignorePrivate = Boolean(_.get(context, 'settings.jsdoc.ignorePrivate'));
249+
249250
// `check-tag-names` and many require/param rules
250251
const tagNamePreference = _.get(context, 'settings.jsdoc.tagNamePreference') || {};
251252

@@ -351,6 +352,13 @@ export default (iterator, options) => {
351352
sourceCode
352353
);
353354

355+
if (
356+
ignorePrivate &&
357+
utils.hasTag('private')
358+
) {
359+
return;
360+
}
361+
354362
iterator({
355363
context,
356364
indent,

test/rules/assertions/requireParam.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,21 @@ export default {
474474
}
475475
}
476476
`
477+
},
478+
{
479+
code: `
480+
/**
481+
* @private
482+
*/
483+
function quux (foo) {
484+
485+
}
486+
`,
487+
settings: {
488+
jsdoc: {
489+
ignorePrivate: true
490+
}
491+
}
477492
}
478493
]
479494
};

0 commit comments

Comments
 (0)