|
| 1 | +<a name="user-content-escape-inline-tags"></a> |
| 2 | +<a name="escape-inline-tags"></a> |
| 3 | +# <code>escape-inline-tags</code> |
| 4 | + |
| 5 | +Reports use of JSDoc tags in non-tag positions (in the default "typescript" mode). |
| 6 | + |
| 7 | +Note that while the JSDoc standard refers to inline tags as those being surrounded |
| 8 | +by curly brackets, such as those in the form `{@link https://example.com}`, for the |
| 9 | +purposes of this rule, we are referring to inline tags as a simple reference to |
| 10 | +tags such as `@param` outside of the normal location of a tag. |
| 11 | + |
| 12 | +<a name="user-content-escape-inline-tags-options"></a> |
| 13 | +<a name="escape-inline-tags-options"></a> |
| 14 | +## Options |
| 15 | + |
| 16 | +A single options object has the following properties. |
| 17 | + |
| 18 | +<a name="user-content-escape-inline-tags-options-allowedinlinetags"></a> |
| 19 | +<a name="escape-inline-tags-options-allowedinlinetags"></a> |
| 20 | +### <code>allowedInlineTags</code> |
| 21 | + |
| 22 | +A listing of tags you wish to allow unescaped. Defaults to an empty array. |
| 23 | +<a name="user-content-escape-inline-tags-options-enablefixer"></a> |
| 24 | +<a name="escape-inline-tags-options-enablefixer"></a> |
| 25 | +### <code>enableFixer</code> |
| 26 | + |
| 27 | +Whether to enable the fixer. Defaults to `true`. |
| 28 | +<a name="user-content-escape-inline-tags-options-fixascode"></a> |
| 29 | +<a name="escape-inline-tags-options-fixascode"></a> |
| 30 | +### <code>fixAsCode</code> |
| 31 | + |
| 32 | +Whether to enclose tags in backticks, treating as code segments rather than a `@` literal |
| 33 | + |
| 34 | + |
| 35 | +||| |
| 36 | +|---|---| |
| 37 | +|Context|everywhere| |
| 38 | +|Tags|``| |
| 39 | +|Recommended|true (unless `mode` is changed away from "typescript")| |
| 40 | +|Settings|`mode`| |
| 41 | +|Options|`allowedInlineTags`, `enableFixer`, `fixAsCode`| |
| 42 | + |
| 43 | +<a name="user-content-escape-inline-tags-failing-examples"></a> |
| 44 | +<a name="escape-inline-tags-failing-examples"></a> |
| 45 | +## Failing examples |
| 46 | + |
| 47 | +The following patterns are considered problems: |
| 48 | + |
| 49 | +````ts |
| 50 | +/** |
| 51 | + * |
| 52 | + * Whether to include a @yearly, @monthly etc text labels in the generated expression. |
| 53 | + */ |
| 54 | +// Message: Unexpected inline JSDoc tag. Did you mean to use {@yearly}, \@yearly, or `@yearly`? |
| 55 | + |
| 56 | +/** |
| 57 | + * Some text |
| 58 | + * Whether to include a @yearly, @monthly etc text labels in the generated expression. |
| 59 | + */ |
| 60 | +// Message: Unexpected inline JSDoc tag. Did you mean to use {@yearly}, \@yearly, or `@yearly`? |
| 61 | + |
| 62 | +/** |
| 63 | + * Whether to include a @yearly, @yearly etc text labels in the generated expression. |
| 64 | + */ |
| 65 | +// Message: Unexpected inline JSDoc tag. Did you mean to use {@yearly}, \@yearly, or `@yearly`? |
| 66 | + |
| 67 | +/** |
| 68 | + * Whether to include a @yearly, |
| 69 | + * or @yearly etc text labels in the generated expression. |
| 70 | + */ |
| 71 | +// Message: Unexpected inline JSDoc tag. Did you mean to use {@yearly}, \@yearly, or `@yearly`? |
| 72 | + |
| 73 | +/** |
| 74 | + * Whether to include a @yearly, @monthly etc text labels in the generated expression. |
| 75 | + */ |
| 76 | +// "jsdoc/escape-inline-tags": ["error"|"warn", {"allowedInlineTags":["monthly"],"fixAsCode":true}] |
| 77 | +// Message: Unexpected inline JSDoc tag. Did you mean to use {@yearly}, \@yearly, or `@yearly`? |
| 78 | + |
| 79 | +/** |
| 80 | + * Some description @sth |
| 81 | + */ |
| 82 | +// Message: Unexpected inline JSDoc tag. Did you mean to use {@sth}, \@sth, or `@sth`? |
| 83 | + |
| 84 | +/** |
| 85 | + * Some description @sth |
| 86 | + */ |
| 87 | +// "jsdoc/escape-inline-tags": ["error"|"warn", {"enableFixer":false}] |
| 88 | +// Message: Unexpected inline JSDoc tag. Did you mean to use {@sth}, \@sth, or `@sth`? |
| 89 | + |
| 90 | +/** |
| 91 | + * @param includeNonStandard Whether to include a @yearly, @monthly etc text labels in the generated expression. |
| 92 | + */ |
| 93 | +// Message: Unexpected inline JSDoc tag. Did you mean to use {@yearly}, \@yearly, or `@yearly`? |
| 94 | + |
| 95 | +/** |
| 96 | + * @param includeNonStandard Whether to include a @yearly, @monthly etc text labels in the generated expression. |
| 97 | + */ |
| 98 | +// "jsdoc/escape-inline-tags": ["error"|"warn", {"allowedInlineTags":["monthly"],"fixAsCode":true}] |
| 99 | +// Message: Unexpected inline JSDoc tag. Did you mean to use {@yearly}, \@yearly, or `@yearly`? |
| 100 | + |
| 101 | +/** |
| 102 | + * @param aName @sth |
| 103 | + */ |
| 104 | +// Message: Unexpected inline JSDoc tag. Did you mean to use {@sth}, \@sth, or `@sth`? |
| 105 | + |
| 106 | +/** |
| 107 | + * @param aName @sth |
| 108 | + * and @another |
| 109 | + * @param anotherName @yetAnother |
| 110 | + */ |
| 111 | +// Message: Unexpected inline JSDoc tag. Did you mean to use {@sth}, \@sth, or `@sth`? |
| 112 | + |
| 113 | +/** |
| 114 | + * @param aName @sth |
| 115 | + */ |
| 116 | +// "jsdoc/escape-inline-tags": ["error"|"warn", {"enableFixer":false}] |
| 117 | +// Message: Unexpected inline JSDoc tag. Did you mean to use {@sth}, \@sth, or `@sth`? |
| 118 | +```` |
| 119 | + |
| 120 | + |
| 121 | + |
| 122 | +<a name="user-content-escape-inline-tags-passing-examples"></a> |
| 123 | +<a name="escape-inline-tags-passing-examples"></a> |
| 124 | +## Passing examples |
| 125 | + |
| 126 | +The following patterns are not considered problems: |
| 127 | + |
| 128 | +````ts |
| 129 | +/** |
| 130 | + * A description with an escaped \@tag. |
| 131 | + */ |
| 132 | + |
| 133 | +/** |
| 134 | + * A description with a markdown `@tag`. |
| 135 | + */ |
| 136 | + |
| 137 | +/** |
| 138 | + * A description with a non@tag. |
| 139 | + */ |
| 140 | + |
| 141 | +/** |
| 142 | + * @param {SomeType} aName A description with an escaped \@tag. |
| 143 | + */ |
| 144 | + |
| 145 | +/** |
| 146 | + * @param {SomeType} aName A description with a markdown `@tag`. |
| 147 | + */ |
| 148 | + |
| 149 | +/** |
| 150 | + * @param {SomeType} aName A description with a non@tag. |
| 151 | + */ |
| 152 | + |
| 153 | +/** |
| 154 | + * {@link https://example.com} |
| 155 | + */ |
| 156 | + |
| 157 | +/** |
| 158 | + * A description with a {@link https://example.com} |
| 159 | + */ |
| 160 | + |
| 161 | +/** |
| 162 | + * @someTag {@link https://example.com} |
| 163 | + */ |
| 164 | + |
| 165 | +/** |
| 166 | + * @param {SomeType} aName {@link https://example.com} |
| 167 | + */ |
| 168 | + |
| 169 | +/** |
| 170 | + * @param {SomeType} aName A description with a {@link https://example.com}. |
| 171 | + */ |
| 172 | + |
| 173 | +/** |
| 174 | + * @example |
| 175 | + * Here are some unescaped tags: @yearly, @monthly |
| 176 | + */ |
| 177 | + |
| 178 | +/** |
| 179 | + * Whether to include a @yearly, @monthly etc text labels in the generated expression. |
| 180 | + */ |
| 181 | +// Settings: {"jsdoc":{"mode":"jsdoc"}} |
| 182 | +```` |
| 183 | + |
0 commit comments