Skip to content

allow undocumented jsdoc modifies tag and missing closure tags #394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
59 changes: 58 additions & 1 deletion .README/rules/check-tag-names.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ memberof
memberof!
mixes
mixin
modifies (Currently undocumented but in source)
module
name
namespace
Expand Down Expand Up @@ -75,6 +76,62 @@ version
yields
```

The following synonyms are also recognized:

```
arg
argument
const
constructor
defaultvalue
desc
emits
exception
extends
fileoverview
func
host
method
overview
prop
return
var
virtual
yield
```

For [TypeScript](https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#supported-jsdoc)
(or Closure), one may also use the following:

```
template
```

And for [Closure](https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler#nosideeffects-modifies-thisarguments),
one may also use:

```
define
dict
export
externs
final
implicitCast (casing distinct from that recognized by jsdoc internally)
inheritDoc (casing distinct from that recognized by jsdoc internally)
noalias
nocollapse
nocompile
noinline
nosideeffects
polymer
polymerBehavior
preserve
struct
suppress
template
unrestricted
```

Note that the tags indicated as replacements in `settings.jsdoc.tagNamePreference` will automatically be considered as valid.

#### Options
Expand All @@ -86,7 +143,7 @@ The format is as follows:

```json
{
"definedTags": ["define", "record"]
"definedTags": ["note", "record"]
}
```

Expand Down
59 changes: 58 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,7 @@ memberof
memberof!
mixes
mixin
modifies (Currently undocumented but in source)
module
name
namespace
Expand Down Expand Up @@ -1445,6 +1446,62 @@ version
yields
```

The following synonyms are also recognized:

```
arg
argument
const
constructor
defaultvalue
desc
emits
exception
extends
fileoverview
func
host
method
overview
prop
return
var
virtual
yield
```

For [TypeScript](https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#supported-jsdoc)
(or Closure), one may also use the following:

```
template
```

And for [Closure](https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler#nosideeffects-modifies-thisarguments),
one may also use:

```
define
dict
export
externs
final
implicitCast (casing distinct from that recognized by jsdoc internally)
inheritDoc (casing distinct from that recognized by jsdoc internally)
noalias
nocollapse
nocompile
noinline
nosideeffects
polymer
polymerBehavior
preserve
struct
suppress
template
unrestricted
```

Note that the tags indicated as replacements in `settings.jsdoc.tagNamePreference` will automatically be considered as valid.

<a name="eslint-plugin-jsdoc-rules-check-tag-names-options-2"></a>
Expand All @@ -1458,7 +1515,7 @@ The format is as follows:

```json
{
"definedTags": ["define", "record"]
"definedTags": ["note", "record"]
}
```

Expand Down
8 changes: 7 additions & 1 deletion src/jsdocUtils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import _ from 'lodash';
import tagNames from './tagNames';
import {jsdocTags, closureTags} from './tagNames';

// Todo: Distinguish closure tags
const tagNames = {
...closureTags,
...jsdocTags,
};

const getFunctionParameterNames = (functionNode : Object) : Array<string> => {
const getParamName = (param) => {
Expand Down
61 changes: 53 additions & 8 deletions src/tagNames.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
export default {
const jsdocTagsUndocumented = {
// Undocumented but present; see
// https://github.com/jsdoc/jsdoc/issues/1283#issuecomment-516816802
// https://github.com/jsdoc/jsdoc/blob/master/packages/jsdoc/lib/jsdoc/tag/dictionary/definitions.js#L594
modifies: [],
};

const jsdocTags = {
...jsdocTagsUndocumented,
abstract: [
'virtual',
],
Expand Down Expand Up @@ -65,6 +73,7 @@ export default {
'memberof!': [],
mixes: [],
mixin: [],

module: [],
name: [],
namespace: [],
Expand All @@ -90,13 +99,6 @@ export default {
static: [],
summary: [],

// `@template` is not part of standard jsdoc on https://jsdoc.app but is
// used by Closure per:
// https://github.com/google/closure-compiler/wiki/Generic-Types
// and by TypeScript per:
// https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#supported-jsdoc
template: [],

this: [],
throws: [
'exception',
Expand All @@ -111,3 +113,46 @@ export default {
'yield',
],
};

const TypeScriptTags = {
// `@template` is also in TypeScript per:
// https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#supported-jsdoc
template: [],
};

const closureTags = {
...TypeScriptTags,

// From https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler
// These are all recognized in https://github.com/jsdoc/jsdoc/blob/master/packages/jsdoc/lib/jsdoc/tag/dictionary/definitions.js
// except for the experimental `noinline` and the casing differences noted below

// Defined as a synonym of `const` in jsdoc `definitions.js`
define: [],

dict: [],
export: [],
externs: [],
final: [],

// With casing distinct from jsdoc `definitions.js`
implicitCast: [],

// With casing distinct from jsdoc `definitions.js`
inheritDoc: [],

noalias: [],
nocollapse: [],
nocompile: [],
noinline: [],
nosideeffects: [],
polymer: [],
polymerBehavior: [],
preserve: [],
struct: [],
suppress: [],

unrestricted: [],
};

export {jsdocTags, closureTags};