Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
8396a90
added new rule: require-description-complete-sentence
dtracers May 31, 2015
0c97487
removed extra semi-colon
dtracers May 31, 2015
d4af535
removed duplicate assignments
dtracers May 31, 2015
573e78e
fixed null value being assigned
dtracers May 31, 2015
ded7e8a
turned off rule by default
dtracers May 31, 2015
0a2fa93
fixed the cursor appearing in the wrong location
dtracers May 31, 2015
97faf6c
removed extra line! and fixed potential bug
dtracers May 31, 2015
82005b4
removed error in test.
dtracers May 31, 2015
7f4a23b
Should fix location of missing period marker
dtracers May 31, 2015
a7c75b8
missing semi colon *facepalm*
dtracers May 31, 2015
ff1c0ca
missing backslash
dtracers May 31, 2015
68a4203
changed to matching word character instead of word boundary
dtracers May 31, 2015
085d279
changed lines -> line
dtracers May 31, 2015
2527ff5
Fixed build.
dtracers May 31, 2015
085f32c
Added readme documentation.
dtracers May 31, 2015
d85d5d7
Added tests for multiple lines with period
dtracers May 31, 2015
b8e26d6
Changed how the rules work.
dtracers May 31, 2015
1e68a45
New Rule: Require Param Description
dtracers Jun 14, 2015
19e1e6c
Merge remote-tracking branch 'jscs-dev/master'
dtracers Jun 14, 2015
be35ab4
added new rule: require-description-complete-sentence
dtracers May 31, 2015
d707777
removed extra semi-colon
dtracers May 31, 2015
fb04d46
removed duplicate assignments
dtracers May 31, 2015
1b3be57
fixed null value being assigned
dtracers May 31, 2015
b37a025
turned off rule by default
dtracers May 31, 2015
441c6ab
fixed the cursor appearing in the wrong location
dtracers May 31, 2015
b6988cd
removed extra line! and fixed potential bug
dtracers May 31, 2015
4b34557
removed error in test.
dtracers May 31, 2015
90d88d3
Should fix location of missing period marker
dtracers May 31, 2015
a3df74d
missing semi colon *facepalm*
dtracers May 31, 2015
478bea8
missing backslash
dtracers May 31, 2015
71fce83
changed to matching word character instead of word boundary
dtracers May 31, 2015
fc67b8f
changed lines -> line
dtracers May 31, 2015
3bd1004
Fixed build.
dtracers May 31, 2015
3799434
Added tests for multiple lines with period
dtracers May 31, 2015
edb5de7
Changed how the rules work.
dtracers May 31, 2015
aa804f9
New Rule: Require Param Description
dtracers Jun 14, 2015
f3497fd
Merge branch 'master' of https://github.com/dtracers/jscs-jsdoc
dtracers Jun 21, 2015
cba30a6
# This is a combination of 15 commits.
dtracers May 31, 2015
599fc9e
New Rule: Require Param Description
dtracers May 31, 2015
2b284a3
New Rule: Require Param Description
dtracers Jun 14, 2015
86c4584
Merge branch 'master' of https://github.com/dtracers/jscs-jsdoc
dtracers Jun 21, 2015
22586ca
addressed the comments
dtracers Jun 21, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/rules/validate-jsdoc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var validatorsByName = module.exports = {
checkParamNames: require('./check-param-names'),
checkRedundantParams: require('./check-redundant-params'),
requireParamTypes: require('./require-param-types'),
requireParamDescription: require('./require-param-description'),
requireHyphenBeforeDescription: require('./require-hyphen-before-description'),

checkReturnTypes: require('./check-return-types'),
Expand Down
32 changes: 32 additions & 0 deletions lib/rules/validate-jsdoc/require-param-description.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = validateParamTagDescription;
module.exports.tags = ['param', 'arg', 'argument'];
module.exports.scopes = ['function'];
module.exports.options = {
requireParamDescription: {allowedValues: [true]}
};

/**
* Validator for @param
*
* @param {(FunctionDeclaration|FunctionExpression)} node
* @param {DocTag} tag
* @param {Function} err
*/
function validateParamTagDescription(node, tag, err) {
// checking existance
if (tag.description) {
return;
}
var offset = 0;
if (tag.name && tag.name.value && tag.name.value.length) {
offset = tag.name.value.length;
}
var loc = (tag.name ? tag.name.loc : null) || tag.loc;

// we create a new one to prevent modifing given location
var locWithOffset = {
line: loc.line,
column: loc.column + offset
};
return err('Missing param description', locWithOffset);
}
146 changes: 146 additions & 0 deletions test/lib/rules/validate-jsdoc/require-param-description.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
describe('lib/rules/validate-jsdoc/require-param-description', function () {
var checker = global.checker({
plugins: ['./lib/index']
});

describe('not configured', function() {

it('should report with undefined', function() {
global.expect(function() {
checker.configure({requireParamDescription: undefined});
}).to.throws(/accepted value/i);
});

it('should report with an object', function() {
global.expect(function() {
checker.configure({requireParamDescription: {}});
}).to.throws(/accepted value/i);
});

});

describe('with true', function() {
checker.rules({requireParamDescription: true});

checker.cases([
/* jshint ignore:start */
{
it: 'should not report',
code: function() {
function yay(yey) {
}
}
}, {
it: 'should report missing jsdoc-param description for function',
errors: 1,
code: function () {
var x = 1;
/**
* @param xxx
*/
function funcName(xxx) {
// dummy
}
}
}, {
it: 'should report missing jsdoc-param description for method',
errors: 1,
code: function () {
Cls.prototype = {
/**
* @param yyy
*/
run: function(xxx) {
// dummy
}
};
}
}, {
it: 'should not report invalid jsdoc for method',
code: function () {
var x = 1;
/**
* @param {String} xxx description
*/
function funcName(xxx) {
// dummy
}
}
}, {
it: 'should not report invalid jsdoc for function',
code: function () {
Cls.prototype = {
/**
* @param {String} xxx description
*/
run: function(xxx) {
// dummy
}
};
}
}, {
it: 'should not report invalid jsdoc with object type for method',
code: function () {
var x = 1;
/**
* @param {{foo: string}} xxx description
*/
function funcName(xxx) {
// dummy
}
}
}, {
it: 'should not report invalid jsdoc with object type for function',
code: function () {
Cls.prototype = {
/**
* @param {{foo: string}} xxx description
*/
run: function(xxx) {
// dummy
}
};
}
}, {
it: 'should not report invalid jsdoc with no param type for method',
code: function () {
var x = 1;
/**
* @param xxx description
*/
function funcName(xxx) {
// dummy
}
}
}, {
it: 'should not report invalid jsdoc with no param type for function',
code: function () {
Cls.prototype = {
/**
* @param xxx description
*/
run: function(xxx) {
// dummy
}
};
}
}, {
it: 'should report with right location',
code: function () {
Cls.prototype = {
/**
* @param xxx
*/
run: function(xxx) {
// dummy
}
};
},
errors: {column: 17, line: 3}
}
/* jshint ignore:end */
]);

});

});