-
Notifications
You must be signed in to change notification settings - Fork 4.1k
/
jsdoc.js
98 lines (94 loc) · 2.41 KB
/
jsdoc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
* External dependencies
*/
const globals = require( 'globals' );
/**
* The temporary list of types defined in Gutenberg which are whitelisted to avoid
* ESLint warnings. It should be removed once importing is going to be implemented
* in the tool which generates public APIs from JSDoc comments. Related issue to
* fix the root cause `@wordpress/docgen`:
* https://github.com/WordPress/gutenberg/issues/18045.
*/
const temporaryWordPressInternalTypes = [
'WPBlockChildren',
'WPBlockNode',
'WPBlockSelection',
'WPBlockSerializationOptions',
'WPBlock',
'WPBlockPattern',
'WPBlockTypeIcon',
'WPBlockTypeIconRender',
'WPBlockTypeIconDescriptor',
'WPComponent',
'WPElement',
'WPIcon',
];
/**
* The temporary list of external types used in Gutenberg which are whitelisted
* to avoid ESLint warnings. It's similar to `wordpressInternalTypes` and it
* should be removed once the related issues is fixed:
* https://github.com/WordPress/gutenberg/issues/18045
*/
const temporaryExternalTypes = [
'DOMHighResTimeStamp',
'espree',
];
/**
* Helpful utilities that are globally defined and known to the TypeScript compiler.
*
* @see http://www.typescriptlang.org/docs/handbook/utility-types.html
*/
const typescriptUtilityTypes = [
'ArrayLike',
'Exclude',
'Extract',
'InstanceType',
'Iterable',
'IterableIterator',
'NonNullable',
'Omit',
'Partial',
'Pick',
'PromiseLike',
'Readonly',
'ReadonlyArray',
'ReadonlyMap',
'ReadonlySet',
'Record',
'Required',
'ReturnType',
'ThisType',
];
module.exports = {
extends: [
'plugin:jsdoc/recommended',
],
settings: {
jsdoc: {
preferredTypes: {
object: 'Object',
},
tagNamePreference: {
returns: 'return',
yields: 'yield',
},
},
},
rules: {
'jsdoc/no-undefined-types': [ 'warn', {
definedTypes: [
// Required to reference browser types because we don't have the `browser` environment enabled for the project.
// Here we filter out all browser globals that don't begin with an uppercase letter because those
// generally refer to window-level event listeners and are not a valid type to reference (e.g. `onclick`).
...Object.keys( globals.browser ).filter( ( k ) => /^[A-Z]/.test( k ) ),
...typescriptUtilityTypes,
...temporaryWordPressInternalTypes,
...temporaryExternalTypes,
'void',
],
} ],
'jsdoc/require-jsdoc': 'off',
'jsdoc/require-param-description': 'off',
'jsdoc/require-returns': 'off',
},
};