Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
jscs-jsdoc
Advanced tools
jsdoc
plugin for jscs. Twitter | Mailing List
NB Since jscs v2.0
the plugin jscs-jsdoc
is bundled into it.
jscs-jsdoc
can be installed using NPM and requires jscs.
Install it globally if you are using globally installed jscs
npm -g install jscs-jsdoc
But better install it into your project
npm install jscs-jsdoc --save-dev
We recommend installing jscs-jsdoc
via NPM using ^
, or ~
if you want more stable releases.
Semver (http://semver.org/) dictates that breaking changes be major version bumps. In the context of a linting tool, a bug fix that causes more errors to be reported can be interpreted as a breaking change. However, that would require major version bumps to occur more often than can be desirable. Therefore, as a compromise, we will only release bug fixes that cause more errors to be reported in minor versions.
Below you fill find our versioning strategy, and what you can expect to come out of a new jscs-jsdoc
release.
jscs-jsdoc
to report less errors;jscs-jsdoc
to report more errors;To use plugin you should add these lines to configuration file .jscsrc
:
{
"plugins": [
"jscs-jsdoc"
],
"jsDoc": {
"checkAnnotations": "closurecompiler",
"checkTypes": "strictNativeCase",
"enforceExistence": {
"allExcept": ["exports"]
}
}
}
Checks tag names are valid.
There are 3 presets for Closure Compiler
, JSDoc3
and JSDuck5
.
By default it allows any tag from any preset. You can pass Object
to select preset with preset
field and add custom tags with extra
field.
Type: Boolean
or String
or {"preset": String, "extra": Object}
(see tag values).
Values: true
, "closurecompiler"
, "jsdoc3"
, "jsduck5"
, Object
Context: file
Tags: *
extra
field should contains tags in keys and there are options for values:
false
means tag available with no valuetrue
means tag available with any value"some"
means tag available and requires some valueSee also tag presets.
"checkAnnotations": true
/**
* @chainable
* @param {string} message
* @return {string}
*/
function _f() {}
/**
* @pororo
* @lalala
*/
function _f() {}
"checkAnnotations": {
"preset": "jsdoc3",
"extra": {
"boomer": false
}
}
/**
* @boomer
* @argument {String}
*/
function _f() {}
/** @still-invalid */
Checks all parameters are documented.
Type: Boolean
Values: true
"checkParamExistence": true
/**
* @param {string} message
* @return {string}
*/
function _f ( message ) {
return true;
}
/**
* @inheritdoc
*/
function _f ( message ) {
return true;
}
/**
* @return {string}
*/
function _f ( message ) {
return true;
}
Checks param names in jsdoc and in function declaration are equal.
Type: Boolean
Values: true
Context: functions
Tags: param
, arg
, argument
"checkParamNames": true
/**
* @param {String} message
* @param {Number|Object} [line]
*/
function method(message, line) {}
/**
* @param {String} msg
* @param {Number|Object} [line]
*/
function method(message) {}
Checks params in jsdoc contains type.
Type: Boolean
Values: true
Context: functions
Tags: param
, arg
, argument
"requireParamTypes": true
/**
* @param {String} message
*/
function method() {}
/**
* @param message
*/
function method() {}
Reports redundant params in jsdoc.
Type: Boolean
Values: true
Context: functions
Tags: param
, arg
, argument
"checkRedundantParams": true
/**
* @param {String} message
*/
function method(message) {}
/**
* @param {String} message
*/
function method() {}
Checks for differences between the jsdoc and actual return types if both exist.
Type: Boolean
Values: true
Context: functions
Tags: return
, returns
"checkReturnTypes": true
/**
* @returns {String}
*/
function method() {
return 'foo';
}
/**
* @returns {String}
*/
function method(f) {
if (f) {
return true;
}
return 1;
}
Report statements for functions without return.
Type: Boolean
Values: true
Context: functions
Tags: return
, returns
"checkRedundantReturns": true
/**
* @returns {string}
*/
function f() {
return 'yes';
}
/**
* @returns {string}
*/
function f() {
// no return here
}
Checks returns in jsdoc contains type
Type: Boolean
Values: true
Context: functions
Tags: return
, returns
"requireReturnTypes": true
/**
* @returns {String}
*/
function method() {}
/**
* no @return
*/
function method() {}
/**
* @returns
*/
function method() {}
Reports invalid types for bunch of tags.
The strictNativeCase
mode checks that case of natives is the same as in this
list: boolean
, number
, string
, Object
, Array
, Date
, RegExp
.
The capitalizedNativeCase
mode checks that the first letter in all native
types and primitives is uppercased except the case with function
in google closure format: {function(...)}
Type: Boolean
or String
Values: true
or "strictNativeCase"
or "capitalizedNativeCase"
Context: *
Tags: typedef
, type
, param
, return
, returns
, enum
, var
, prop
, property
, arg
, argument
, cfg
, lends
, extends
, implements
, define
"checkTypes": true
/**
* @typedef {Object} ObjectLike
* @property {boolean} hasFlag
* @property {string} name
*/
/** @type {number} */
var bar = 1;
/** @const {number} */
var FOO = 2;
/**
* @const
* @type {number}
*/
var BAZ = 3;
/**
* @param {SomeX} x
* @returns {string}
*/
function method(x) {}
/** @type {some~number} */
var x = 1;
/**
* @param {function(redundantName: Number)} x
*/
function method(x) {}
/**
* @param {Number|Boolean|object|array} x invalid for strictNativeCase
*/
function method(x) {}
/** @type {some~number} */
var x = 1;
Reports redundant access declarations.
Type: Boolean
or String
Values: true
or "enforceLeadingUnderscore"
or "enforceTrailingUnderscore"
Context: functions
Tags: access
, private
, protected
, public
"checkRedundantAccess": true
"checkRedundantAccess": "enforceLeadingUnderscore"
/**
* @access private
*/
function _f() {}
/**
* @access public
*/
function f() {}
/**
* @private
* @access private
*/
function _f() {}
/**
* @private
*/
function _f() {}
Checks access declaration is set for _underscored
function names
Ignores a bunch of popular identifiers:
__filename
, __dirname
, __proto__
, __defineGetter__
, super_
,
__constructor
, etc.
Type: Boolean
or String
Values: true
(means not public), "private"
, "protected"
Context: functions
Tags: access
, private
, protected
, public
"leadingUnderscoreAccess": "protected"
/**
* @protected
*/
function _f() {}
function _g() {}
/**
* @private
*/
function _e() {}
Checks jsdoc block exists.
Type: Boolean
, String
or Object
Values:
true
"exceptExports"
(deprecated use "allExcept": ["exports"]
)Object
:
"allExcept"
array of exceptions:
"expressions"
skip expression functions"exports"
skip module.exports = function () {};
"paramless-procedures"
functions without parameters and with empty
return statements will be skippedContext: functions
"enforceExistence": true
/**
* @protected
*/
function _f() {}
function _g() {}
Checks a param description has a hyphen before it (checks for -
).
Type: Boolean
Values: true
Context: functions
Tags: param
, arg
, argument
"requireHyphenBeforeDescription": true
/**
* @param {String} - message
*/
function method() {}
/**
* @param {String} message
*/
function method() {}
Checks a doc comment description has padding newline.
Type: Boolean
Values: true
Context: functions
Tags: *
"requireNewlineAfterDescription": true
/**
* @param {String} msg - message
*/
function method(msg) {}
/**
* Description
*/
function method() {}
/**
* Description
*
* @param {String} msg - message
*/
function method(msg) {}
/**
* Description
* @param {String} message
*/
function method() {}
Checks a doc comment description has no padding newlines.
Type: Boolean
Values: true
Context: functions
Tags: *
"disallowNewlineAfterDescription": true
/**
* @param {String} msg - message
*/
function method(msg) {}
/**
* Description
*/
function method() {}
/**
* Description
* @param {String} msg - message
*/
function method(msg) {}
/**
* Description
*
* @param {String} message
*/
function method(message) {}
Checks a doc comment description is a complete sentence.
A complete sentence is defined as starting with an upper case letter and ending with a period.
Type: Boolean
Values: true
Context: functions
Tags: *
"requireDescriptionCompleteSentence": true
/**
* @param {String} msg - message
*/
function method(msg) {}
/**
* Description.
*/
function method() {}
/**
* (Description).
*/
function method() {}
/**
* Description.
*
* @param {String} msg - message
*/
function method(msg) {}
/**
* Description
* on multiple lines are allowed.
*
* @param {String} msg - message
*/
function method(msg) {}
/**
* Description
* @param {String} message
*/
function method() {}
/**
* Description
* On multiple lines should not start with an upper case.
*
* @param {String} - message
*/
function method() {}
/**
* description starting with a lower case letter.
* @param {String} message
*/
function method() {}
/**
* Description period is offset .
* @param {String} message
*/
function method() {}
/**
* Description!
* @param {String} message
*/
function method() {}
Checks a param description exists.
Type: Boolean
Values: true
Context: functions
Tags: param
, arg
, argument
"requireParamDescription": true
/**
* @param {String} arg message
*/
function method(arg) {}
/**
* @param arg message
*/
function method(arg) {}
/**
* @param {String} arg
*/
function method(arg) {}
/**
* @param arg
*/
function method(arg) {}
Checks a return description exists.
Type: Boolean
Values: true
Context: functions
Tags: return
, returns
"requireReturnDescription": true
/**
* @returns {Boolean} Method result.
*/
function method() {
return false;
}
/**
* @returns {String} method result
*/
function method() {
return 'Hello!';
}
/**
* @returns {Boolean}
*/
function method() {
return false;
}
[v1.3.0] - 2015-12-05
It was more than 2 months gap since the last release and here we are with a couple of bug fixes and better ES2015 support. A big part of fixes related to requireDescriptionCompleteSentence
rule. If you had troubles with it you can give it a try now. enforceExistence
now supports ES2015 exports and treats it like CommonJS module.exports
.
Also we should note that Jordan Harband came with a node v0.8
support :tada:. Thank you, Jordan!
Besides the current release there will be a huge update with a new :gift:jsdoctypeparser
with better support of jsdoc types and several very important changes especially for linters. It's still in alpha but feels like it could be a good idea to release an alpha version with it (I guess it will be the next :shipit: one).
P.S. Futher releases should be more often since I'll found few hours a week to do it... But if you feel that your ideas should be implemented, or you are ready to assist with issues, or even help with maintaining, let's collaborate, :trophy: waits you.
b9ffead365
] - Update Rule: inlined tags in requireDescriptionCompleteSentence (Alexey Yaroshevich)5cae0345b6
] - Update Rule: add arrow exception to enforceExistence rule (Alexej Yaroshevich)4735603a75
] - Fix: dont stick IIFE with outpadded docblock (Alexey Yaroshevich)42c642a98a
] - Fix: lists now treats like a sentence in requireDescriptionCompleteSentence (Alexey Yaroshevich)9805a4ebf5
] - Fix: dot in abbreviation is treated like an end (Alexey Yaroshevich)c771b255ed
] - Fix: slightly correct description calculation (Alexey Yaroshevich)84def6aedc
] - Fix: scope for arrow functions (Sergey Zarouski)739ed3fe2f
] - Fix: add ExportNamedDeclaration to enforceExistence (Alexej Yaroshevich)5f7d756aa8
] - Fix: add support of es6 exports in enforceExistence (Alexej Yaroshevich)d2070ef6e0
] - Tags: add override as a valid tag to jsdoc3 set (Brittany Tarvin)4db0f2b5d4
] - Docs: add changelog for release and fix readme (Alexey Yaroshevich)244c3876b8
] - Docs: fix travis link, change gitter chat to node-jscs (Alexey Yaroshevich)4d28215a06
] - Docs: drop browser section, add note about bundling into jscs (Alexey Yaroshevich)21f5eda422
] - Docs: fix mistyped example for requireDescriptionCompleteSentense (Alexey Yaroshevich)d91140dc43
] - Docs: fix grammar for couple of rules (Alexej Yaroshevich)6c74293b97
] - Docs: update deprecated enforceExistence in Usage section (Damien SEGUIN)0094e85d47
] - Chore: return peerDeps since they are valid (Alexey Yaroshevich)842dcb5f3d
] - Chore: add more nodes to travis: 0.8, 4 and 5 (Alexey Yaroshevich)c25a184fb4
] - Chore: bump comment-parser to v0.3.1 (Jordan Harband)5df4bff183
] - Misc: replace tabs with spaces (Alexej Yaroshevich)FAQs
JSCS jsdoc plugin
The npm package jscs-jsdoc receives a total of 30,015 weekly downloads. As such, jscs-jsdoc popularity was classified as popular.
We found that jscs-jsdoc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.