Skip to content

Commit 79e316c

Browse files
author
Alexej Yaroshevich
committed
leadingUnderscoreAccess: skip checking for overriden methods
Fixes #114
1 parent abce52a commit 79e316c

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

lib/rules/validate-jsdoc/leading-underscore-access.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,20 @@ function validateLeadingUnderscoresAccess(node, err) {
7272

7373
var access;
7474
var accessTag;
75+
var override = false;
7576
node.jsdoc.iterate(function(tag) {
7677
if (!access && ['private', 'protected', 'public', 'access'].indexOf(tag.id) !== -1) {
7778
access = (tag.id === 'access' ? tag.name.value : tag.id);
7879
accessTag = tag;
80+
} else if (tag.id === 'override') {
81+
override = true;
7982
}
8083
});
8184

8285
if (!access || !accessTag) {
83-
err('Missing access tag for ' + (name || 'anonymous function'), (nameLocation || node.loc).start);
86+
if (!override) {
87+
err('Missing access tag for ' + (name || 'anonymous function'), (nameLocation || node.loc).start);
88+
}
8489
} else if ([true, access].indexOf(option) === -1) {
8590
err('Method access doesn\'t match', accessTag.loc);
8691
}

test/lib/rules/validate-jsdoc/leading-underscore-access.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,28 @@ describe('lib/rules/validate-jsdoc/leading-underscore-access', function () {
202202
*/
203203
var __proto__ = function (p) {};
204204
}
205+
}, {
206+
it: 'should not report overriden methods. #114',
207+
rules: {leadingUnderscoreAccess: 'private'},
208+
code: function () {
209+
/**
210+
* @override
211+
*/
212+
function _funcName(p) {
213+
}
214+
}
215+
}, {
216+
it: 'should report overriden with wrong @access value. #114',
217+
rules: {leadingUnderscoreAccess: 'private'},
218+
code: function () {
219+
/**
220+
* @override
221+
* @protected
222+
*/
223+
function _funcName(p) {
224+
}
225+
},
226+
errors: 1
205227
}
206228
/* jshint ignore:end */
207229
]);

0 commit comments

Comments
 (0)