File tree 12 files changed +115
-3
lines changed
12 files changed +115
-3
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ Markdown and you therefore do not wish for it to be accidentally interpreted
10
10
as such by the likes of Visual Studio Code or if you wish to view it escaped
11
11
within it or your documentation.
12
12
13
+ ` @example ` tag content will not be checked.
14
+
13
15
## Fixer
14
16
15
17
(TODO)
Original file line number Diff line number Diff line change @@ -216,5 +216,10 @@ function quux () {
216
216
* @returns {string[]} The array of nodes.
217
217
*/
218
218
function quux () {}
219
+
220
+ /** Application boot function.
221
+ @async
222
+ @private **/
223
+ function quux () {}
219
224
````
220
225
Original file line number Diff line number Diff line change @@ -807,6 +807,15 @@ function quux(foo) {
807
807
808
808
quux (0 );
809
809
810
+ function quux() {
811
+ const foo = 1 ;
812
+ /** {@link foo } */
813
+ const bar = foo ;
814
+ console .log (bar );
815
+ }
816
+
817
+ quux ();
818
+
810
819
/**
811
820
* @import BadImportIgnoredByThisRule
812
821
*/
Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ Markdown and you therefore do not wish for it to be accidentally interpreted
19
19
as such by the likes of Visual Studio Code or if you wish to view it escaped
20
20
within it or your documentation.
21
21
22
+ ` @example ` tag content will not be checked.
23
+
22
24
<a name =" user-content-text-escaping-fixer " ></a >
23
25
<a name =" text-escaping-fixer " ></a >
24
26
## Fixer
@@ -175,5 +177,21 @@ The following patterns are not considered problems:
175
177
* to escape
176
178
*/
177
179
// "jsdoc/text-escaping": ["error"|"warn", {"escapeHTML":true}]
180
+
181
+ /**
182
+ * @example
183
+ * ```
184
+ * Some things to escape: <a> and > and ઼ and `test`
185
+ * ```
186
+ */
187
+ // "jsdoc/text-escaping": ["error"|"warn", {"escapeHTML":true}]
188
+
189
+ /**
190
+ * @example
191
+ * ```
192
+ * Some things to escape: <a> and > and ઼ and `test`
193
+ * ```
194
+ */
195
+ // "jsdoc/text-escaping": ["error"|"warn", {"escapeMarkdown":true}]
178
196
````
179
197
Original file line number Diff line number Diff line change @@ -202,6 +202,9 @@ const getDocPaths = () => {
202
202
// Will get path separately below
203
203
return null ;
204
204
}
205
+ if ( docFile === '.DS_Store' ) {
206
+ return null ;
207
+ }
205
208
206
209
const innerBasePath = path . join ( basePath , docFile ) ;
207
210
const writeInnerBasePath = path . join ( writeBasePath , docFile ) ;
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ import validTypes from './rules/validTypes.js';
59
59
import { getJsdocProcessorPlugin } from './getJsdocProcessorPlugin.js' ;
60
60
61
61
/**
62
- * @typedef {"recommended" | "stylistic" | "contents" | "logical" } ConfigGroups
62
+ * @typedef {"recommended" | "stylistic" | "contents" | "logical" | "requirements" } ConfigGroups
63
63
* @typedef {"" | "-typescript" | "-typescript-flavor" } ConfigVariants
64
64
* @typedef {"" | "-error" } ErrorLevelVariants
65
65
* @type {import('eslint').ESLint.Plugin & {
Original file line number Diff line number Diff line change @@ -42,9 +42,12 @@ export default iterateJsdoc(({
42
42
settings . mode !== 'closure' && emptyIfNotClosure . has ( tagName ) ;
43
43
} ) ;
44
44
45
- for ( const tag of emptyTags ) {
45
+ for ( const [ key , tag ] of emptyTags . entries ( ) ) {
46
46
const content = tag . name || tag . description || tag . type ;
47
- if ( content . trim ( ) ) {
47
+ if ( content . trim ( ) && (
48
+ // Allow for JSDoc-block final asterisks
49
+ key !== emptyTags . length - 1 || ! ( / ^ \s * \* + $ / u) . test ( content )
50
+ ) ) {
48
51
const fix = ( ) => {
49
52
// By time of call in fixer, `tag` will have `line` added
50
53
utils . setTag (
Original file line number Diff line number Diff line change @@ -222,6 +222,21 @@ export default iterateJsdoc(({
222
222
// Program scope inside
223
223
const cjsOrESMScope = globalScope . childScopes [ 0 ] ?. block ?. type === 'Program' ;
224
224
225
+ /**
226
+ * @param {import("eslint").Scope.Scope | null } scope
227
+ * @returns {Set<string> }
228
+ */
229
+ const getValidRuntimeIdentifiers = ( scope ) => {
230
+ const result = new Set ( )
231
+ while ( scope ) {
232
+ for ( const { name} of scope . variables ) {
233
+ result . add ( name )
234
+ }
235
+ scope = scope . upper
236
+ }
237
+ return result
238
+ } ;
239
+
225
240
const allDefinedTypes = new Set ( globalScope . variables . map ( ( {
226
241
name,
227
242
} ) => {
@@ -247,6 +262,7 @@ export default iterateJsdoc(({
247
262
. concat ( importTags )
248
263
. concat ( definedTypes )
249
264
. concat ( /** @type {string[] } */ ( definedPreferredTypes ) )
265
+ . concat ( ...getValidRuntimeIdentifiers ( node && sourceCode . getScope ( node ) ) )
250
266
. concat (
251
267
settings . mode === 'jsdoc' ?
252
268
[ ] :
Original file line number Diff line number Diff line change @@ -73,6 +73,9 @@ export default iterateJsdoc(({
73
73
}
74
74
75
75
for ( const tag of jsdoc . tags ) {
76
+ if ( tag . tag === 'example' ) {
77
+ continue ;
78
+ }
76
79
if ( /** @type {string[] } */ (
77
80
utils . getTagDescription ( tag , true )
78
81
) . some ( ( desc ) => {
@@ -100,6 +103,9 @@ export default iterateJsdoc(({
100
103
}
101
104
102
105
for ( const tag of jsdoc . tags ) {
106
+ if ( tag . tag === 'example' ) {
107
+ continue ;
108
+ }
103
109
if ( /** @type {string[] } */ (
104
110
utils . getTagDescription ( tag , true )
105
111
) . some ( ( desc ) => {
Original file line number Diff line number Diff line change @@ -308,5 +308,13 @@ export default /** @type {import('../index.js').TestCases} */ ({
308
308
function quux () {}
309
309
` ,
310
310
} ,
311
+ {
312
+ code : `
313
+ /** Application boot function.
314
+ @async
315
+ @private **/
316
+ function quux () {}
317
+ ` ,
318
+ } ,
311
319
] ,
312
320
} ) ;
Original file line number Diff line number Diff line change @@ -1482,6 +1482,18 @@ export default /** @type {import('../index.js').TestCases} */ ({
1482
1482
'no-unused-vars' : 'error' ,
1483
1483
} ,
1484
1484
} ,
1485
+ {
1486
+ code : `
1487
+ function quux() {
1488
+ const foo = 1;
1489
+ /** {@link foo} */
1490
+ const bar = foo;
1491
+ console.log(bar);
1492
+ }
1493
+
1494
+ quux();
1495
+ ` ,
1496
+ } ,
1485
1497
{
1486
1498
code : `
1487
1499
/**
Original file line number Diff line number Diff line change @@ -316,5 +316,35 @@ export default /** @type {import('../index.js').TestCases} */ ({
316
316
} ,
317
317
] ,
318
318
} ,
319
+ {
320
+ code : `
321
+ /**
322
+ * @example
323
+ * \`\`\`
324
+ * Some things to escape: <a> and > and ઼ and \`test\`
325
+ * \`\`\`
326
+ */
327
+ ` ,
328
+ options : [
329
+ {
330
+ escapeHTML : true ,
331
+ } ,
332
+ ]
333
+ } ,
334
+ {
335
+ code : `
336
+ /**
337
+ * @example
338
+ * \`\`\`
339
+ * Some things to escape: <a> and > and ઼ and \`test\`
340
+ * \`\`\`
341
+ */
342
+ ` ,
343
+ options : [
344
+ {
345
+ escapeMarkdown : true ,
346
+ } ,
347
+ ]
348
+ } ,
319
349
] ,
320
350
} ) ;
You can’t perform that action at this time.
0 commit comments