Skip to content

Commit 2819c01

Browse files
committed
feat(check-tag-names and other rules): begin settings.jsdoc.mode; utilize in getPreferredTagName, isValidTag, getTagsByType; fixes part of gajus#356
BREAKING CHANGE: Allowable values: jsdoc|typescript|closure
1 parent fa82a11 commit 2819c01

File tree

9 files changed

+414
-56
lines changed

9 files changed

+414
-56
lines changed

.README/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ You can then selectively add to or override the recommended rules.
8888
- `settings.jsdoc.ignorePrivate` - Disables all rules for the comment block
8989
on which a `@private` tag occurs. Defaults to `false`.
9090

91+
### Mode
92+
93+
- `settings.jsdoc.mode` - Set to `jsdoc` (the default), `typescript`, or `closure`.
94+
Currently is used for checking preferred tag names and in the `check-tag-names`
95+
rule.
96+
9197
### Alias Preference
9298

9399
Use `settings.jsdoc.tagNamePreference` to configure a preferred alias name for a JSDoc tag. The format of the configuration is: `<primary tag name>: <preferred alias name>`, e.g.

.README/rules/check-tag-names.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,16 @@ yield
101101
```
102102

103103
For [TypeScript](https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#supported-jsdoc)
104-
(or Closure), one may also use the following:
104+
(or Closure), when `settings.jsdoc.mode` is set to `typescript` or `closure`,
105+
one may also use the following:
105106

106107
```
107108
template
108109
```
109110

110111
And for [Closure](https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler#nosideeffects-modifies-thisarguments),
111-
one may also use:
112+
when `settings.jsdoc.mode` is set to `closure`, one may use the following (in
113+
addition to the jsdoc and TypeScript tags):
112114

113115
```
114116
define
@@ -128,7 +130,6 @@ polymerBehavior
128130
preserve
129131
struct
130132
suppress
131-
template
132133
unrestricted
133134
```
134135

@@ -138,7 +139,7 @@ Note that the tags indicated as replacements in `settings.jsdoc.tagNamePreferenc
138139

139140
##### `definedTags`
140141

141-
Use an array of `definedTags` strings to configure additional, allowed JSDoc tags.
142+
Use an array of `definedTags` strings to configure additional, allowed tags.
142143
The format is as follows:
143144

144145
```json
@@ -152,6 +153,6 @@ The format is as follows:
152153
|Context|everywhere|
153154
|Tags|N/A|
154155
|Options|`definedTags`|
155-
|Settings|`tagNamePreference`|
156+
|Settings|`tagNamePreference`, `mode`|
156157

157158
<!-- assertions checkTagNames -->

README.md

Lines changed: 251 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ JSDoc linting rules for ESLint.
1313
* [Configuration](#eslint-plugin-jsdoc-configuration)
1414
* [Settings](#eslint-plugin-jsdoc-settings)
1515
* [Allow `@private` to disable rules for that comment block](#eslint-plugin-jsdoc-settings-allow-private-to-disable-rules-for-that-comment-block)
16+
* [Mode](#eslint-plugin-jsdoc-settings-mode)
1617
* [Alias Preference](#eslint-plugin-jsdoc-settings-alias-preference)
1718
* [`@override`/`@augments`/`@extends`/`@implements` Without Accompanying `@param`/`@description`/`@example`/`@returns`](#eslint-plugin-jsdoc-settings-override-augments-extends-implements-without-accompanying-param-description-example-returns)
1819
* [Settings to Configure `check-types` and `no-undefined-types`](#eslint-plugin-jsdoc-settings-settings-to-configure-check-types-and-no-undefined-types)
@@ -128,6 +129,13 @@ You can then selectively add to or override the recommended rules.
128129
- `settings.jsdoc.ignorePrivate` - Disables all rules for the comment block
129130
on which a `@private` tag occurs. Defaults to `false`.
130131

132+
<a name="eslint-plugin-jsdoc-settings-mode"></a>
133+
### Mode
134+
135+
- `settings.jsdoc.mode` - Set to `jsdoc` (the default), `typescript`, or `closure`.
136+
Currently is used for checking preferred tag names and in the `check-tag-names`
137+
rule.
138+
131139
<a name="eslint-plugin-jsdoc-settings-alias-preference"></a>
132140
### Alias Preference
133141

@@ -1471,14 +1479,16 @@ yield
14711479
```
14721480

14731481
For [TypeScript](https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#supported-jsdoc)
1474-
(or Closure), one may also use the following:
1482+
(or Closure), when `settings.jsdoc.mode` is set to `typescript` or `closure`,
1483+
one may also use the following:
14751484

14761485
```
14771486
template
14781487
```
14791488

14801489
And for [Closure](https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler#nosideeffects-modifies-thisarguments),
1481-
one may also use:
1490+
when `settings.jsdoc.mode` is set to `closure`, one may use the following (in
1491+
addition to the jsdoc and TypeScript tags):
14821492

14831493
```
14841494
define
@@ -1498,7 +1508,6 @@ polymerBehavior
14981508
preserve
14991509
struct
15001510
suppress
1501-
template
15021511
unrestricted
15031512
```
15041513

@@ -1510,7 +1519,7 @@ Note that the tags indicated as replacements in `settings.jsdoc.tagNamePreferenc
15101519
<a name="eslint-plugin-jsdoc-rules-check-tag-names-options-2-definedtags"></a>
15111520
##### <code>definedTags</code>
15121521

1513-
Use an array of `definedTags` strings to configure additional, allowed JSDoc tags.
1522+
Use an array of `definedTags` strings to configure additional, allowed tags.
15141523
The format is as follows:
15151524

15161525
```json
@@ -1524,7 +1533,7 @@ The format is as follows:
15241533
|Context|everywhere|
15251534
|Tags|N/A|
15261535
|Options|`definedTags`|
1527-
|Settings|`tagNamePreference`|
1536+
|Settings|`tagNamePreference`, `mode`|
15281537

15291538
The following patterns are considered problems:
15301539

@@ -1685,6 +1694,162 @@ function quux () {
16851694
}
16861695
// Settings: {"jsdoc":{"tagNamePreference":{"abc":"abcd"}}}
16871696
// Message: Invalid JSDoc tag (preference). Replace "abc" JSDoc tag with "abcd".
1697+
1698+
/**
1699+
* @modifies
1700+
* @abstract
1701+
* @access
1702+
* @alias
1703+
* @async
1704+
* @augments
1705+
* @author
1706+
* @borrows
1707+
* @callback
1708+
* @class
1709+
* @classdesc
1710+
* @constant
1711+
* @constructs
1712+
* @copyright
1713+
* @default
1714+
* @deprecated
1715+
* @description
1716+
* @enum
1717+
* @event
1718+
* @example
1719+
* @exports
1720+
* @external
1721+
* @file
1722+
* @fires
1723+
* @function
1724+
* @generator
1725+
* @global
1726+
* @hideconstructor
1727+
* @ignore
1728+
* @implements
1729+
* @inheritdoc
1730+
* @inner
1731+
* @instance
1732+
* @interface
1733+
* @kind
1734+
* @lends
1735+
* @license
1736+
* @listens
1737+
* @member
1738+
* @memberof
1739+
* @memberof!
1740+
* @mixes
1741+
* @mixin
1742+
* @module
1743+
* @name
1744+
* @namespace
1745+
* @override
1746+
* @package
1747+
* @param
1748+
* @private
1749+
* @property
1750+
* @protected
1751+
* @public
1752+
* @readonly
1753+
* @requires
1754+
* @returns
1755+
* @see
1756+
* @since
1757+
* @static
1758+
* @summary
1759+
* @this
1760+
* @throws
1761+
* @todo
1762+
* @tutorial
1763+
* @type
1764+
* @typedef
1765+
* @variation
1766+
* @version
1767+
* @yields
1768+
*/
1769+
function quux (foo) {}
1770+
// Settings: {"jsdoc":{"mode":"badMode"}}
1771+
// Message: Unrecognized value `badMode` for `settings.jsdoc.mode`.
1772+
1773+
/**
1774+
* @modifies
1775+
* @abstract
1776+
* @access
1777+
* @alias
1778+
* @async
1779+
* @augments
1780+
* @author
1781+
* @borrows
1782+
* @callback
1783+
* @class
1784+
* @classdesc
1785+
* @constant
1786+
* @constructs
1787+
* @copyright
1788+
* @default
1789+
* @deprecated
1790+
* @description
1791+
* @enum
1792+
* @event
1793+
* @example
1794+
* @exports
1795+
* @external
1796+
* @file
1797+
* @fires
1798+
* @function
1799+
* @generator
1800+
* @global
1801+
* @hideconstructor
1802+
* @ignore
1803+
* @implements
1804+
* @inheritdoc
1805+
* @inner
1806+
* @instance
1807+
* @interface
1808+
* @kind
1809+
* @lends
1810+
* @license
1811+
* @listens
1812+
* @member
1813+
* @memberof
1814+
* @memberof!
1815+
* @mixes
1816+
* @mixin
1817+
* @module
1818+
* @name
1819+
* @namespace
1820+
* @override
1821+
* @package
1822+
* @param
1823+
* @private
1824+
* @property
1825+
* @protected
1826+
* @public
1827+
* @readonly
1828+
* @requires
1829+
* @returns
1830+
* @see
1831+
* @since
1832+
* @static
1833+
* @summary
1834+
* @this
1835+
* @throws
1836+
* @todo
1837+
* @tutorial
1838+
* @type
1839+
* @typedef
1840+
* @variation
1841+
* @version
1842+
* @yields
1843+
* @template
1844+
*/
1845+
function quux (foo) {}
1846+
// Message: Invalid JSDoc tag name "template".
1847+
1848+
/**
1849+
* @externs
1850+
*/
1851+
function quux (foo) {}
1852+
// Message: Invalid JSDoc tag name "externs".
16881853
````
16891854

16901855
The following patterns are not considered problems:
@@ -1809,6 +1974,87 @@ function quux (foo) {
18091974
*/
18101975
function quux (foo) {}
18111976

1977+
/**
1978+
* @modifies
1979+
* @abstract
1980+
* @access
1981+
* @alias
1982+
* @async
1983+
* @augments
1984+
* @author
1985+
* @borrows
1986+
* @callback
1987+
* @class
1988+
* @classdesc
1989+
* @constant
1990+
* @constructs
1991+
* @copyright
1992+
* @default
1993+
* @deprecated
1994+
* @description
1995+
* @enum
1996+
* @event
1997+
* @example
1998+
* @exports
1999+
* @external
2000+
* @file
2001+
* @fires
2002+
* @function
2003+
* @generator
2004+
* @global
2005+
* @hideconstructor
2006+
* @ignore
2007+
* @implements
2008+
* @inheritdoc
2009+
* @inner
2010+
* @instance
2011+
* @interface
2012+
* @kind
2013+
* @lends
2014+
* @license
2015+
* @listens
2016+
* @member
2017+
* @memberof
2018+
* @memberof!
2019+
* @mixes
2020+
* @mixin
2021+
* @module
2022+
* @name
2023+
* @namespace
2024+
* @override
2025+
* @package
2026+
* @param
2027+
* @private
2028+
* @property
2029+
* @protected
2030+
* @public
2031+
* @readonly
2032+
* @requires
2033+
* @returns
2034+
* @see
2035+
* @since
2036+
* @static
2037+
* @summary
2038+
* @this
2039+
* @throws
2040+
* @todo
2041+
* @tutorial
2042+
* @type
2043+
* @typedef
2044+
* @variation
2045+
* @version
2046+
* @yields
2047+
* @template
2048+
*/
2049+
function quux (foo) {}
2050+
// Settings: {"jsdoc":{"mode":"typescript"}}
2051+
2052+
/**
2053+
* @externs
2054+
*/
2055+
function quux (foo) {}
2056+
// Settings: {"jsdoc":{"mode":"closure"}}
2057+
18122058
/**
18132059
*
18142060
*/

0 commit comments

Comments
 (0)