Skip to content

Commit 8ae72bc

Browse files
committed
feat(escape-inline-tags): add new rule
Also: - chore: update jsdoccomment and devDeps. - docs: improve linebreaks Now parses identifiers sans hyphens and avoiding treating NaN and Infinity as numbers
1 parent f72ac1a commit 8ae72bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1041
-143
lines changed

.README/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ Finally, enable all of the rules that you would like to use.
227227
"jsdoc/check-values": 1, // Recommended
228228
"jsdoc/convert-to-jsdoc-comments": 1,
229229
"jsdoc/empty-tags": 1, // Recommended
230+
"jsdoc/escape-inline-tags": 1, // Recommended for TS configs
230231
"jsdoc/implements-on-classes": 1, // Recommended
231232
"jsdoc/imports-as-dependencies": 1,
232233
"jsdoc/informative-docs": 1,
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# `escape-inline-tags`
2+
3+
Reports use of JSDoc tags in non-tag positions (in the default "typescript" mode).
4+
5+
Note that while the JSDoc standard refers to inline tags as those being surrounded
6+
by curly brackets, such as those in the form `{@link https://example.com}`, for the
7+
purposes of this rule, we are referring to inline tags as a simple reference to
8+
tags such as `@param` outside of the normal location of a tag and which may need to
9+
be wrapped in `{}` to be proper inline JSDoc or need to be escaped with `\` or
10+
wrapped with ` to be normal text. E.g.
11+
12+
```js
13+
/** Supports shorthands such as `@yearly` to simplify setup. */
14+
```
15+
16+
## Options
17+
18+
{"gitdown": "options"}
19+
20+
|||
21+
|---|---|
22+
|Context|everywhere|
23+
|Tags|``|
24+
|Recommended|true (unless `mode` is changed away from "typescript")|
25+
|Settings|`mode`|
26+
|Options|`allowedInlineTags`, `enableFixer`, `fixType`|
27+
28+
## Failing examples
29+
30+
<!-- assertions-failing escapeInlineTags -->
31+
32+
## Passing examples
33+
34+
<!-- assertions-passing escapeInlineTags -->

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ Finally, enable all of the rules that you would like to use.
254254
"jsdoc/check-values": 1, // Recommended
255255
"jsdoc/convert-to-jsdoc-comments": 1,
256256
"jsdoc/empty-tags": 1, // Recommended
257+
"jsdoc/escape-inline-tags": 1, // Recommended for TS configs
257258
"jsdoc/implements-on-classes": 1, // Recommended
258259
"jsdoc/imports-as-dependencies": 1,
259260
"jsdoc/informative-docs": 1,
@@ -442,6 +443,7 @@ non-default-recommended fixer).
442443
|:heavy_check_mark:|| [check-values](./docs/rules/check-values.md#readme) | This rule checks the values for a handful of tags: `@version`, `@since`, `@license` and `@author`. |
443444
||:wrench:| [convert-to-jsdoc-comments](./docs/rules/convert-to-jsdoc-comments.md#readme) | Converts non-JSDoc comments preceding or following nodes into JSDoc ones |
444445
|:heavy_check_mark:|:wrench:| [empty-tags](./docs/rules/empty-tags.md#readme) | Checks tags that are expected to be empty (e.g., `@abstract` or `@async`), reporting if they have content |
446+
|:heavy_check_mark:|:wrench:| [escape-inline-tags](./docs/rules/escape-inline-tags.md#readme) | Reports use of JSDoc tags in non-tag positions (in the default "typescript" mode). |
445447
|:heavy_check_mark:|| [implements-on-classes](./docs/rules/implements-on-classes.md#readme) | Prohibits use of `@implements` on non-constructor functions (to enforce the tag only being used on classes/constructors). |
446448
||| [imports-as-dependencies](./docs/rules/imports-as-dependencies.md#readme) | Reports if JSDoc `import()` statements point to a package which is not listed in `dependencies` or `devDependencies` |
447449
||| [informative-docs](./docs/rules/informative-docs.md#readme) | This rule reports doc comments that only restate their attached name. |

docs/rules/check-line-alignment.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,43 +56,51 @@ If a spacing is not defined, it defaults to one.
5656
#### <code>postDelimiter</code>
5757

5858
Affects spacing after the asterisk (e.g., `* @param`)
59+
5960
<a name="user-content-check-line-alignment-options-customspacings-posthyphen"></a>
6061
<a name="check-line-alignment-options-customspacings-posthyphen"></a>
6162
#### <code>postHyphen</code>
6263

6364
Affects spacing after any hyphens in the description (e.g., `* @param {someType} name - A description`)
65+
6466
<a name="user-content-check-line-alignment-options-customspacings-postname"></a>
6567
<a name="check-line-alignment-options-customspacings-postname"></a>
6668
#### <code>postName</code>
6769

6870
Affects spacing after the name (e.g., `* @param {someType} name `)
71+
6972
<a name="user-content-check-line-alignment-options-customspacings-posttag"></a>
7073
<a name="check-line-alignment-options-customspacings-posttag"></a>
7174
#### <code>postTag</code>
7275

7376
Affects spacing after the tag (e.g., `* @param `)
77+
7478
<a name="user-content-check-line-alignment-options-customspacings-posttype"></a>
7579
<a name="check-line-alignment-options-customspacings-posttype"></a>
7680
#### <code>postType</code>
7781

7882
Affects spacing after the type (e.g., `* @param {someType} `)
83+
7984
<a name="user-content-check-line-alignment-options-disablewrapindent"></a>
8085
<a name="check-line-alignment-options-disablewrapindent"></a>
8186
### <code>disableWrapIndent</code>
8287

8388
Disables `wrapIndent`; existing wrap indentation is preserved without changes.
89+
8490
<a name="user-content-check-line-alignment-options-preservemaindescriptionpostdelimiter"></a>
8591
<a name="check-line-alignment-options-preservemaindescriptionpostdelimiter"></a>
8692
### <code>preserveMainDescriptionPostDelimiter</code>
8793

8894
A boolean to determine whether to preserve the post-delimiter spacing of the
8995
main description. If `false` or unset, will be set to a single space.
96+
9097
<a name="user-content-check-line-alignment-options-tags"></a>
9198
<a name="check-line-alignment-options-tags"></a>
9299
### <code>tags</code>
93100

94101
Use this to change the tags which are sought for alignment changes. Defaults to an array of
95102
`['param', 'arg', 'argument', 'property', 'prop', 'returns', 'return', 'template']`.
103+
96104
<a name="user-content-check-line-alignment-options-wrapindent"></a>
97105
<a name="check-line-alignment-options-wrapindent"></a>
98106
### <code>wrapIndent</code>

docs/rules/check-param-names.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,21 @@ If set to `true`, this option will allow extra `@param` definitions (e.g.,
7272
representing future expected or virtual params) to be present without needing
7373
their presence within the function signature. Other inconsistencies between
7474
`@param`'s and present function parameters will still be reported.
75+
7576
<a name="user-content-check-param-names-options-checkdestructured"></a>
7677
<a name="check-param-names-options-checkdestructured"></a>
7778
### <code>checkDestructured</code>
7879

7980
Whether to check destructured properties. Defaults to `true`.
81+
8082
<a name="user-content-check-param-names-options-checkrestproperty"></a>
8183
<a name="check-param-names-options-checkrestproperty"></a>
8284
### <code>checkRestProperty</code>
8385

8486
If set to `true`, will require that rest properties are documented and
8587
that any extraneous properties (which may have been within the rest property)
8688
are documented. Defaults to `false`.
89+
8790
<a name="user-content-check-param-names-options-checktypespattern"></a>
8891
<a name="check-param-names-options-checktypespattern"></a>
8992
### <code>checkTypesPattern</code>
@@ -123,6 +126,7 @@ your expression as a string, but like a literal, e.g., `/^object$/vi`.
123126
You could set this regular expression to a more expansive list, or you
124127
could restrict it such that even types matching those strings would not
125128
need destructuring.
129+
126130
<a name="user-content-check-param-names-options-disableextrapropertyreporting"></a>
127131
<a name="check-param-names-options-disableextrapropertyreporting"></a>
128132
### <code>disableExtraPropertyReporting</code>
@@ -134,11 +138,13 @@ their own types. Note that extra properties will always be reported if another
134138
item at the same level is destructured as destructuring will prevent other
135139
access and this option is only intended to permit documenting extra properties
136140
that are available and actually used in the function.
141+
137142
<a name="user-content-check-param-names-options-disablemissingparamchecks"></a>
138143
<a name="check-param-names-options-disablemissingparamchecks"></a>
139144
### <code>disableMissingParamChecks</code>
140145

141146
Whether to avoid checks for missing `@param` definitions. Defaults to `false`. Change to `true` if you want to be able to omit properties.
147+
142148
<a name="user-content-check-param-names-options-enablefixer"></a>
143149
<a name="check-param-names-options-enablefixer"></a>
144150
### <code>enableFixer</code>
@@ -149,6 +155,7 @@ names).
149155
Note that this option will remove duplicates of the same name even if
150156
the definitions do not match in other ways (e.g., the second param will
151157
be removed even if it has a different type or description).
158+
152159
<a name="user-content-check-param-names-options-usedefaultobjectproperties"></a>
153160
<a name="check-param-names-options-usedefaultobjectproperties"></a>
154161
### <code>useDefaultObjectProperties</code>

docs/rules/check-tag-names.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,18 +238,21 @@ The format is as follows:
238238
"definedTags": ["note", "record"]
239239
}
240240
```
241+
241242
<a name="user-content-check-tag-names-options-enablefixer"></a>
242243
<a name="check-tag-names-options-enablefixer"></a>
243244
### <code>enableFixer</code>
244245

245246
Set to `false` to disable auto-removal of types that are redundant with the [`typed` option](#user-content-typed).
247+
246248
<a name="user-content-check-tag-names-options-inlinetags"></a>
247249
<a name="check-tag-names-options-inlinetags"></a>
248250
### <code>inlineTags</code>
249251

250252
List of tags to allow inline.
251253

252254
Defaults to array of `'link', 'linkcode', 'linkplain', 'tutorial'`
255+
253256
<a name="user-content-check-tag-names-options-jsxtags"></a>
254257
<a name="check-tag-names-options-jsxtags"></a>
255258
### <code>jsxTags</code>
@@ -264,6 +267,7 @@ jsxRuntime
264267
```
265268

266269
For more information, see the [babel documentation](https://babeljs.io/docs/en/babel-plugin-transform-react-jsx).
270+
267271
<a name="user-content-check-tag-names-options-typed"></a>
268272
<a name="check-tag-names-options-typed"></a>
269273
### <code>typed</code>

docs/rules/check-types.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ A single options object has the following properties.
4545
### <code>exemptTagContexts</code>
4646

4747
Avoids reporting when a bad type is found on a specified tag.
48+
4849
A single options object has the following properties.
4950

5051
<a name="user-content-check-types-options-exempttagcontexts-tag"></a>
5152
<a name="check-types-options-exempttagcontexts-tag"></a>
5253
##### <code>tag</code>
5354

5455
Set a key `tag` to the tag to exempt
56+
5557
<a name="user-content-check-types-options-exempttagcontexts-types"></a>
5658
<a name="check-types-options-exempttagcontexts-types"></a>
5759
##### <code>types</code>
@@ -65,13 +67,15 @@ behavior of `settings.jsdoc.preferredTypes`. This option is useful
6567
for normally restricting generic types like `object` with
6668
`preferredTypes`, but allowing `typedef` to indicate that its base
6769
type is `object`.
70+
6871
<a name="user-content-check-types-options-nodefaults"></a>
6972
<a name="check-types-options-nodefaults"></a>
7073
### <code>noDefaults</code>
7174

7275
Insists that only the supplied option type
7376
map is to be used, and that the default preferences (such as "string"
7477
over "String") will not be enforced. The option's default is `false`.
78+
7579
<a name="user-content-check-types-options-unifyparentandchildtypechecks"></a>
7680
<a name="check-types-options-unifyparentandchildtypechecks"></a>
7781
### <code>unifyParentAndChildTypeChecks</code>

docs/rules/check-values.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,14 @@ A single options object has the following properties.
4242

4343
An array of allowable author values. If absent, only non-whitespace will
4444
be checked for.
45+
4546
<a name="user-content-check-values-options-allowedlicenses"></a>
4647
<a name="check-values-options-allowedlicenses"></a>
4748
### <code>allowedLicenses</code>
4849

4950
An array of allowable license values or `true` to allow any license text.
5051
If present as an array, will be used in place of [SPDX identifiers](https://spdx.org/licenses/).
52+
5153
<a name="user-content-check-values-options-licensepattern"></a>
5254
<a name="check-values-options-licensepattern"></a>
5355
### <code>licensePattern</code>
@@ -62,6 +64,7 @@ Note that the `/` delimiters are optional, but necessary to add flags.
6264

6365
Defaults to using the `v` flag, so to add your own flags, encapsulate
6466
your expression as a string, but like a literal, e.g., `/^mit$/vi`.
67+
6568
<a name="user-content-check-values-options-numericonlyvariation"></a>
6669
<a name="check-values-options-numericonlyvariation"></a>
6770
### <code>numericOnlyVariation</code>

docs/rules/convert-to-jsdoc-comments.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ An array of prefixes to allow at the beginning of a comment.
2828
Defaults to `['@ts-', 'istanbul ', 'c8 ', 'v8 ', 'eslint', 'prettier-']`.
2929

3030
Supplying your own value overrides the defaults.
31+
3132
<a name="user-content-convert-to-jsdoc-comments-options-contexts"></a>
3233
<a name="convert-to-jsdoc-comments-options-contexts"></a>
3334
### <code>contexts</code>
@@ -48,6 +49,7 @@ The contexts array which will be checked for content on the same line after.
4849
Can either be strings or an object with a `context` string and an optional, default `false` `inlineCommentBlock` boolean.
4950

5051
Defaults to an empty array.
52+
5153
<a name="user-content-convert-to-jsdoc-comments-options-contextsbeforeandafter"></a>
5254
<a name="convert-to-jsdoc-comments-options-contextsbeforeandafter"></a>
5355
### <code>contextsBeforeAndAfter</code>
@@ -58,11 +60,13 @@ line after.
5860
Can either be strings or an object with a `context` string and an optional, default `false` `inlineCommentBlock` boolean.
5961

6062
Defaults to `VariableDeclarator`, `TSPropertySignature`, `PropertyDefinition`.
63+
6164
<a name="user-content-convert-to-jsdoc-comments-options-enablefixer"></a>
6265
<a name="convert-to-jsdoc-comments-options-enablefixer"></a>
6366
### <code>enableFixer</code>
6467

6568
Set to `false` to disable fixing.
69+
6670
<a name="user-content-convert-to-jsdoc-comments-options-enforcejsdoclinestyle"></a>
6771
<a name="convert-to-jsdoc-comments-options-enforcejsdoclinestyle"></a>
6872
### <code>enforceJsdocLineStyle</code>

docs/rules/empty-tags.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ add them within this option.
6161
```
6262

6363

64-
6564
<a name="user-content-context-and-settings"></a>
6665
<a name="context-and-settings"></a>
6766
## Context and settings

0 commit comments

Comments
 (0)