File tree Expand file tree Collapse file tree 3 files changed +45
-20
lines changed Expand file tree Collapse file tree 3 files changed +45
-20
lines changed Original file line number Diff line number Diff line change @@ -275,9 +275,6 @@ const getSettings = (context) => {
275
275
settings . allowImplementsWithoutParam = _ . get ( context , 'settings.jsdoc.allowImplementsWithoutParam' ) ;
276
276
settings . allowAugmentsExtendsWithoutParam = _ . get ( context , 'settings.jsdoc.allowAugmentsExtendsWithoutParam' ) ;
277
277
278
- // `require-example` only
279
- settings . avoidExampleOnConstructors = Boolean ( _ . get ( context , 'settings.jsdoc.avoidExampleOnConstructors' ) ) ;
280
-
281
278
return settings ;
282
279
} ;
283
280
Original file line number Diff line number Diff line change 1
1
import _ from 'lodash' ;
2
2
import iterateJsdoc from '../iterateJsdoc' ;
3
+ import warnRemovedSettings from '../warnRemovedSettings' ;
3
4
4
5
export default iterateJsdoc ( ( {
5
6
jsdoc,
6
7
report,
7
8
utils,
8
- settings
9
+ context
9
10
} ) => {
11
+ warnRemovedSettings ( context , 'require-example' ) ;
12
+
10
13
if ( utils . avoidDocs ( ) ) {
11
14
return ;
12
15
}
13
16
17
+ const options = context . options [ 0 ] || {
18
+ avoidExampleOnConstructors : false
19
+ } ;
20
+
14
21
const targetTagName = 'example' ;
15
22
16
23
const functionExamples = _ . filter ( jsdoc . tags , {
17
24
tag : targetTagName
18
25
} ) ;
19
26
20
- if ( settings . avoidExampleOnConstructors && (
27
+ if ( options . avoidExampleOnConstructors && (
21
28
utils . hasATag ( [
22
29
'class' ,
23
30
'constructor'
@@ -46,6 +53,10 @@ export default iterateJsdoc(({
46
53
{
47
54
additionalProperties : false ,
48
55
properties : {
56
+ avoidExampleOnConstructors : {
57
+ default : false ,
58
+ type : 'boolean'
59
+ } ,
49
60
exemptedBy : {
50
61
items : {
51
62
type : 'string'
Original file line number Diff line number Diff line change @@ -30,6 +30,29 @@ export default {
30
30
}
31
31
]
32
32
} ,
33
+ {
34
+ code : `
35
+ /**
36
+ * @constructor
37
+ */
38
+ function f () {
39
+
40
+ }
41
+ ` ,
42
+ errors : [
43
+ {
44
+ message : '`settings.jsdoc.avoidExampleOnConstructors` has been removed, use options in the rule `require-example` instead.'
45
+ } ,
46
+ {
47
+ message : 'Missing JSDoc @example declaration.'
48
+ }
49
+ ] ,
50
+ settings : {
51
+ jsdoc : {
52
+ avoidExampleOnConstructors : true
53
+ }
54
+ }
55
+ } ,
33
56
{
34
57
code : `
35
58
/**
@@ -108,11 +131,9 @@ export default {
108
131
109
132
}
110
133
` ,
111
- settings : {
112
- jsdoc : {
113
- avoidExampleOnConstructors : true
114
- }
115
- }
134
+ options : [
135
+ { avoidExampleOnConstructors : true }
136
+ ]
116
137
} ,
117
138
{
118
139
code : `
@@ -124,11 +145,9 @@ export default {
124
145
125
146
}
126
147
` ,
127
- settings : {
128
- jsdoc : {
129
- avoidExampleOnConstructors : true
130
- }
131
- }
148
+ options : [
149
+ { avoidExampleOnConstructors : true }
150
+ ]
132
151
} ,
133
152
{
134
153
code : `
@@ -141,11 +160,9 @@ export default {
141
160
}
142
161
}
143
162
` ,
144
- settings : {
145
- jsdoc : {
146
- avoidExampleOnConstructors : true
147
- }
148
- }
163
+ options : [
164
+ { avoidExampleOnConstructors : true }
165
+ ]
149
166
} ,
150
167
{
151
168
code : `
You can’t perform that action at this time.
0 commit comments