-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathrequire-description-complete-sentence.js
304 lines (295 loc) · 10.4 KB
/
require-description-complete-sentence.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
describe('lib/rules/validate-jsdoc/require-description-complete-sentence', function () {
var checker = global.checker({
plugins: ['.']
});
describe('not configured', function() {
it('should report with undefined', function() {
global.expect(function() {
checker.configure({requireDescriptionCompleteSentence: undefined});
}).to.throws(/accepted value/i);
});
it('should report with an object', function() {
global.expect(function() {
checker.configure({requireDescriptionCompleteSentence: {}});
}).to.throws(/accepted value/i);
});
});
describe('with true', function() {
checker.rules({requireDescriptionCompleteSentence: true});
checker.cases([
/* jshint ignore:start */
{
it: 'should not report common cases',
code: function() {
function fun(p) {
}
/**
* @param p
*/
function fun(p) {
}
}
}, {
it: 'should report missing period at end of description',
code: function () {
/**
* Some description
* @param {number} p description without hyphen
*/
function fun(p) {
}
},
errors: {
line: 1,
column: 0
}
}, {
it: 'should report missing upper case letter followed by period',
code: function () {
/**
* Some description. hola.
* @param {number} p description without hyphen
*/
function fun(p) {
}
},
errors: {
line: 1,
column: 0
}
}, {
it: 'should report missing period at end of multi line description',
code: function () {
/**
* Some description
* that takes up multiple lines
* @param {number} p description without hyphen
*/
function fun(p) {
}
},
errors: {
line: 1,
column: 0
}
}, {
it: 'should report missing period if upper case letter follows',
code: function () {
/**
* Some description
* That takes up multiple lines.
* @param {number} p description without hyphen
*/
function fun(p) {
}
},
errors: {
line: 1,
column: 0
}
}, {
it: 'should report missing upper case at beginning of description',
code: function () {
/**
* some description.
* @param {number} p description without hyphen
*/
function fun(p) {
}
},
errors: {
line: 1,
column: 0
},
}, {
it: 'should not report missing period or missing upper case letter',
code: function () {
/**
* Some description.
*
* @param {number} p description without hyphen
*/
function fun(p) {}
}
}, {
it: 'should report trailing white-space',
code: function () {
/**
* Some description .
*
* @param {number} p description without hyphen
*/
function fun(p) {}
},
errors: 1
}, {
it: 'should not report final non-word characters',
code: function () {
/**
* Some `description`.
*/
function fun(p) {}
},
errors: 0
}, {
it: 'should report final non-word characters without dot',
code: function () {
/**
* Some `description`
*/
function fun(p) {}
},
errors: 1
}, {
it: 'should not report because of strings between backtick',
code: function () {
/**
* Some `fo.o` and some `b.ar`. Also some `ba.r` and some `.foo`.
*/
function fun(p) {}
},
errors: 0
}, {
it: 'should not report because of strings between single quotes',
code: function () {
/**
* Some 'fo.o' and some 'b.ar'. Also some 'ba.r' and some '.foo'.
*/
function fun(p) {}
},
errors: 0
}, {
it: 'should not report because of strings between double quotes',
code: function () {
/**
* Some "fo.o" and some "b.ar". Also some "ba.r" and some ".foo".
*/
function fun(p) {}
},
errors: 0
}, {
it: 'should report missing period at end of first line',
code: function () {
/**
* Some description
*
* More description.
* @param {number} p description without hyphen
*/
function fun(p) {
}
},
errors: {
line: 1,
column: 0
}
}, {
it: 'should not report missing period',
code: function () {
/**
* Some description
* which is continued on the next line.
* @param {number} p description without hyphen
*/
function fun(p) {}
}
}, {
it: 'should not report inlined tags #180',
code: function () {
/**
* Heading.
*
* This method uses the algorithm defined here:
* {@link http://stackoverflow.com/questions/1073336/circle-line-segment-collision-detection-algorithm}
*/
function fun(p) {}
}
}, {
it: 'should not report strings like "e.g." #145',
code: function () {
/**
* Checks if token is part of an @-word (e.g. `@import`, `@include`).
*/
function fun(p) {}
}
}, {
it: 'should not report sentences ending with dots inside quotes',
code: function () {
/**
* He said: "mickey."
*/
function fun(p) {}
}
}, {
it: 'should not report sentences ending with dots inside quotes',
code: function () {
/**
* She said "Mickey." but he asked her to shut up.
*/
function fun(p) {}
}
}, {
it: 'should not report sentences with periods inside quotes',
code: function () {
/**
* "r2. d2".
*/
function fun(p) {}
}
}, {
it: 'should not report correct sentences formatted as lists',
code: function () {
/**
* Foo
* `bar`.
*
* Baz:
*
* - qux
* - Zot
* - Qux
* - zot
*/
function quux() {}
}
}, {
it: 'should not report correct sentences formatted as (complex) lists',
code: function () {
/**
* To become a `Foo.Bar`, `element` has to:
*
* - be an `HTMLElement`
* - have an `options` property
* - have `foo` and `bar` properties in its `options` object
* - not have a foo (`.bar`) as source, or if it does:
* - have `options.foo` set to `true`
*/
function quux() {}
}
}, {
it: 'should not report sentences with html tags inside',
code: function () {
/**
* A foo is assigned the boolean value <p>true</p>.
*/
function fun(p) {}
}
}, {
it: 'should not report sentences that are html code',
code: function () {
/**
* The html code here
* <body>
* <p> Hello world!</p>
* </body>
* Should always be there.
* And the first letter of this line is in
* uppercase.
*/
function fun(p) {}
}
}
/* jshint ignore:end */
]);
});
});