-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathjsdoc.js
124 lines (120 loc) · 3.29 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/**
* 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',
'WPBlockType',
'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',
'Parameters',
'Partial',
'Pick',
'PromiseLike',
'Readonly',
'ReadonlyArray',
'ReadonlyMap',
'ReadonlySet',
'Record',
'Required',
'ReturnType',
'ThisType',
'unknown',
'never',
'NodeJS',
];
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',
'jsdoc/check-access': 'error',
'jsdoc/check-alignment': 'error',
'jsdoc/check-param-names': 'error',
'jsdoc/check-property-names': 'error',
'jsdoc/check-tag-names': 'error',
'jsdoc/check-types': 'error',
'jsdoc/check-values': 'off',
'jsdoc/empty-tags': 'error',
'jsdoc/implements-on-classes': 'error',
'jsdoc/newline-after-description': 'error',
'jsdoc/require-param': 'error',
'jsdoc/require-param-name': 'error',
'jsdoc/require-param-type': 'error',
'jsdoc/require-property': 'error',
'jsdoc/require-property-description': 'error',
'jsdoc/require-property-name': 'error',
'jsdoc/require-property-type': 'error',
'jsdoc/require-returns-check': 'error',
'jsdoc/require-returns-description': 'error',
'jsdoc/require-returns-type': 'error',
'jsdoc/valid-types': 'error',
},
};