Skip to content

Commit

Permalink
Introduce jsduck config (#286)
Browse files Browse the repository at this point in the history
Contains overrides for jsdoc for legacy environments still using jsduck.

Fixes #285
  • Loading branch information
edg2s committed Jun 15, 2020
1 parent cb6b05c commit bcc85cb
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 2 deletions.
2 changes: 0 additions & 2 deletions jsdoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
"settings": {
"jsdoc": {
"tagNamePreference": {
"alternateClassName": "alias",
"arg": "param",
"argument": "param",
"augments": "extends",
"cfg": "cfg",
"chainable": "chainable",
"context": "this",
"constant": "const",
"defaultvalue": "default",
"description": "desc",
Expand Down
16 changes: 16 additions & 0 deletions jsduck.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": [ "./jsdoc" ],
"settings": {
"jsdoc": {
"tagNamePreference": {
"this": "context",
"alias": "alternateClassName",
"typedef": "type"
}
}
},
"rules": {
"jsdoc/require-returns": "off",
"jsdoc/require-returns-check": "off"
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"node.json",
"jquery.json",
"jsdoc.json",
"jsduck.json",
"mediawiki.json",
"mocha.json",
"qunit.json",
Expand Down
22 changes: 22 additions & 0 deletions test/fixtures/jsdoc/invalid.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@
APP.method = function () {
};

/* eslint-disable jsdoc/require-returns, jsdoc/require-returns-check */
/**
* @return {Object} foo
* @return {number} foo.bar
*/
APP.method = function () {
return { bar: 7 };
};
/* eslint-enable jsdoc/require-returns, jsdoc/require-returns-check */

// eslint-disable-next-line jsdoc/implements-on-classes
/**
* @implements {HTMLElement}
Expand Down Expand Up @@ -239,4 +249,16 @@
* @yields
*/

// eslint-disable-next-line jsdoc/check-tag-names
/**
* @context
*/

// eslint-disable-next-line jsdoc/check-tag-names
/**
* @alternateClassName
*/

// @type is allowed in jsdoc and jsduck

}( this ) );
3 changes: 3 additions & 0 deletions test/fixtures/jsdoc/valid.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
* {@link APP}
* {@link APP}
*
* @this Foo
* @alias Bar
* @typedef Baz
* @abstract
* @extends String
* @class
Expand Down
11 changes: 11 additions & 0 deletions test/fixtures/jsduck/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"root": true,
"extends": [
"../../../client",
"../../../jsduck"
],
"rules": {
"no-usused-vars": "off",
"no-implicit-globals": "off"
}
}
18 changes: 18 additions & 0 deletions test/fixtures/jsduck/invalid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
( function () {

// eslint-disable-next-line jsdoc/check-tag-names
/**
* @this Foo
*/

// eslint-disable-next-line jsdoc/check-tag-names
/**
* @alias Bar
*/

// eslint-disable-next-line jsdoc/check-tag-names
/**
* @typedef Baz
*/

}( this ) );
44 changes: 44 additions & 0 deletions test/fixtures/jsduck/valid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
( function () {
var APP;

// In jsduck environments we need to support this use case
// to document complex returns, however this triggers
// require-returns and require-returns check:

// Off: jsdoc/require-returns
// Off: jsdoc/require-returns-check
/**
* @return {Object} foo
* @return {number} foo.bar
*/
APP.method = function () {
return { bar: 7 };
};

// These means we can't catch the following errors:

// Off: jsdoc/require-returns
/**
* @param {number} bar
*/
APP.method = function ( bar ) {
return { bar: bar };
};

// Off: jsdoc/require-returns-check
/**
* @return {number}
*/
APP.method = function () {
};

// Some different aliases are used in jsduck:
/**
* @context {jQuery}
* @alternateClassName otherName
* @type {Object}
*/
APP.method = function () {
};

}( this ) );

0 comments on commit bcc85cb

Please sign in to comment.