Skip to content

Commit a977896

Browse files
committedMay 14, 2021
fix(no-missing-syntax): pass in missing comment
Also documents `message` values and adds test line numbers.
1 parent 310ea75 commit a977896

10 files changed

+285
-16
lines changed
 

‎.README/rules/no-missing-syntax.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ Use the `minimum` property (defaults to 1) to indicate how many are required
4242
for the rule to be reported.
4343

4444
Use the `message` property to indicate the specific error to be shown when an
45-
error is reported for that context being found missing.
45+
error is reported for that context being found missing. You may use
46+
`{{context}}` and `{{comment}}` with such messages.
4647

4748
Set to `"any"` if you want the rule to apply to any jsdoc block throughout
4849
your files (as is necessary for finding function blocks not attached to a

‎README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -7601,7 +7601,8 @@ Use the `minimum` property (defaults to 1) to indicate how many are required
76017601
for the rule to be reported.
76027602
76037603
Use the `message` property to indicate the specific error to be shown when an
7604-
error is reported for that context being found missing.
7604+
error is reported for that context being found missing. You may use
7605+
`{{context}}` and `{{comment}}` with such messages.
76057606
76067607
Set to `"any"` if you want the rule to apply to any jsdoc block throughout
76077608
your files (as is necessary for finding function blocks not attached to a
@@ -7628,16 +7629,16 @@ function quux () {
76287629
76297630
}
76307631
// "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":[{"comment":"JSDocBlock[postDelimiter=\"\"]:has(JSDocTypeUnion[left.name=\"Foo\"])","context":"FunctionDeclaration"}]}]
7631-
// Message: Syntax is required: FunctionDeclaration
7632+
// Message: Syntax is required: FunctionDeclaration with JSDocBlock[postDelimiter=""]:has(JSDocTypeUnion[left.name="Foo"])
76327633

76337634
/**
76347635
* @implements {Bar|Foo}
76357636
*/
76367637
function quux () {
76377638

76387639
}
7639-
// "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":[{"comment":"JSDocBlock[postDelimiter=\"\"]:has(JSDocTypeUnion[left.name=\"Foo\"])","context":"FunctionDeclaration","message":"Problematic function syntax: `{{context}}`."}]}]
7640-
// Message: Problematic function syntax: `FunctionDeclaration`.
7640+
// "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":[{"comment":"JSDocBlock[postDelimiter=\"\"]:has(JSDocTypeUnion[left.name=\"Foo\"])","context":"FunctionDeclaration","message":"Problematically missing function syntax: `{{context}}` with `{{comment}}`."}]}]
7641+
// Message: Problematically missing function syntax: `FunctionDeclaration` with `JSDocBlock[postDelimiter=""]:has(JSDocTypeUnion[left.name="Foo"])`.
76417642

76427643
/**
76437644
* @implements {Bar|Foo}
@@ -7663,7 +7664,7 @@ function quux () {
76637664

76647665
}
76657666
// "jsdoc/no-missing-syntax": ["error"|"warn", {"contexts":[{"comment":"JSDocBlock[postDelimiter=\"\"]:has(JSDocTypeUnion[left.name=\"Bar\"])","context":"FunctionDeclaration","minimum":2}]}]
7666-
// Message: Syntax is required: FunctionDeclaration
7667+
// Message: Syntax is required: FunctionDeclaration with JSDocBlock[postDelimiter=""]:has(JSDocTypeUnion[left.name="Bar"])
76677668
````
76687669

76697670
The following patterns are not considered problems:

‎src/rules/noMissingSyntax.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ export default iterateJsdoc(({
5656
!state.selectorMap[contextStr][comment] ||
5757
state.selectorMap[contextStr][comment] < (cntxt?.minimum ?? 1)
5858
) {
59-
const message = cntxt?.message ?? 'Syntax is required: {{context}}';
59+
const message = cntxt?.message ?? 'Syntax is required: {{context}}' +
60+
(comment ? ' with {{comment}}' : '');
6061
context.report({
6162
data: {
63+
comment,
6264
context: contextStr,
6365
},
6466
loc: {

‎test/rules/assertions/checkLineAlignment.js

+28
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default {
1212
`,
1313
errors: [
1414
{
15+
line: 2,
1516
message: 'Expected JSDoc block lines to be aligned.',
1617
type: 'Block',
1718
},
@@ -42,6 +43,7 @@ export default {
4243
`,
4344
errors: [
4445
{
46+
line: 2,
4547
message: 'Expected JSDoc block lines to be aligned.',
4648
type: 'Block',
4749
},
@@ -72,6 +74,7 @@ export default {
7274
`,
7375
errors: [
7476
{
77+
line: 2,
7578
message: 'Expected JSDoc block lines to be aligned.',
7679
type: 'Block',
7780
},
@@ -101,6 +104,7 @@ export default {
101104
`,
102105
errors: [
103106
{
107+
line: 2,
104108
message: 'Expected JSDoc block lines to be aligned.',
105109
type: 'Block',
106110
},
@@ -130,6 +134,7 @@ export default {
130134
`,
131135
errors: [
132136
{
137+
line: 2,
133138
message: 'Expected JSDoc block lines to be aligned.',
134139
type: 'Block',
135140
},
@@ -159,6 +164,7 @@ export default {
159164
`,
160165
errors: [
161166
{
167+
line: 2,
162168
message: 'Expected JSDoc block lines to be aligned.',
163169
type: 'Block',
164170
},
@@ -188,6 +194,7 @@ export default {
188194
`,
189195
errors: [
190196
{
197+
line: 2,
191198
message: 'Expected JSDoc block lines to be aligned.',
192199
type: 'Block',
193200
},
@@ -217,6 +224,7 @@ export default {
217224
`,
218225
errors: [
219226
{
227+
line: 2,
220228
message: 'Expected JSDoc block lines to be aligned.',
221229
type: 'Block',
222230
},
@@ -248,6 +256,7 @@ export default {
248256
`,
249257
errors: [
250258
{
259+
line: 3,
251260
message: 'Expected JSDoc block lines to be aligned.',
252261
type: 'Block',
253262
},
@@ -281,6 +290,7 @@ export default {
281290
`,
282291
errors: [
283292
{
293+
line: 3,
284294
message: 'Expected JSDoc block lines to be aligned.',
285295
type: 'Block',
286296
},
@@ -312,6 +322,7 @@ export default {
312322
`,
313323
errors: [
314324
{
325+
line: 2,
315326
message: 'Expected JSDoc block lines to be aligned.',
316327
type: 'Block',
317328
},
@@ -344,6 +355,7 @@ export default {
344355
`,
345356
errors: [
346357
{
358+
line: 2,
347359
message: 'Expected JSDoc block lines to be aligned.',
348360
type: 'Block',
349361
},
@@ -377,6 +389,7 @@ export default {
377389
`,
378390
errors: [
379391
{
392+
line: 2,
380393
message: 'Expected JSDoc block lines to be aligned.',
381394
type: 'Block',
382395
},
@@ -410,6 +423,7 @@ export default {
410423
`,
411424
errors: [
412425
{
426+
line: 2,
413427
message: 'Expected JSDoc block lines to be aligned.',
414428
type: 'Block',
415429
},
@@ -445,6 +459,7 @@ export default {
445459
`,
446460
errors: [
447461
{
462+
line: 2,
448463
message: 'Expected JSDoc block lines to be aligned.',
449464
type: 'Block',
450465
},
@@ -477,10 +492,12 @@ export default {
477492
`,
478493
errors: [
479494
{
495+
line: 5,
480496
message: 'Expected JSDoc block lines to not be aligned.',
481497
type: 'Block',
482498
},
483499
{
500+
line: 6,
484501
message: 'Expected JSDoc block lines to not be aligned.',
485502
type: 'Block',
486503
},
@@ -510,6 +527,7 @@ export default {
510527
`,
511528
errors: [
512529
{
530+
line: 6,
513531
message: 'Expected JSDoc block lines to not be aligned.',
514532
type: 'Block',
515533
},
@@ -539,6 +557,7 @@ export default {
539557
`,
540558
errors: [
541559
{
560+
line: 6,
542561
message: 'Expected JSDoc block lines to not be aligned.',
543562
type: 'Block',
544563
},
@@ -568,6 +587,7 @@ export default {
568587
`,
569588
errors: [
570589
{
590+
line: 6,
571591
message: 'Expected JSDoc block lines to not be aligned.',
572592
type: 'Block',
573593
},
@@ -595,6 +615,7 @@ export default {
595615
`,
596616
errors: [
597617
{
618+
line: 2,
598619
message: 'Expected JSDoc block lines to be aligned.',
599620
type: 'Block',
600621
},
@@ -628,6 +649,7 @@ export default {
628649
`,
629650
errors: [
630651
{
652+
line: 2,
631653
message: 'Expected JSDoc block lines to be aligned.',
632654
type: 'Block',
633655
},
@@ -659,6 +681,7 @@ export default {
659681
`,
660682
errors: [
661683
{
684+
line: 2,
662685
message: 'Expected JSDoc block lines to be aligned.',
663686
type: 'Block',
664687
},
@@ -718,6 +741,7 @@ export default {
718741
`,
719742
errors: [
720743
{
744+
line: 6,
721745
message: 'Expected JSDoc block lines to not be aligned.',
722746
type: 'Block',
723747
},
@@ -745,6 +769,7 @@ export default {
745769
`,
746770
errors: [
747771
{
772+
line: 6,
748773
message: 'Expected JSDoc block lines to not be aligned.',
749774
type: 'Block',
750775
},
@@ -772,6 +797,7 @@ export default {
772797
`,
773798
errors: [
774799
{
800+
line: 5,
775801
message: 'Expected JSDoc block lines to not be aligned.',
776802
type: 'Block',
777803
},
@@ -800,6 +826,7 @@ export default {
800826
`,
801827
errors: [
802828
{
829+
line: 7,
803830
message: 'Expected JSDoc block lines to not be aligned.',
804831
type: 'Block',
805832
},
@@ -873,6 +900,7 @@ export default {
873900
`,
874901
errors: [
875902
{
903+
line: 2,
876904
message: 'Expected JSDoc block lines to be aligned.',
877905
type: 'Block',
878906
},

‎test/rules/assertions/checkParamNames.js

+14
Original file line numberDiff line numberDiff line change
@@ -753,15 +753,19 @@ export default {
753753
`,
754754
errors: [
755755
{
756+
line: 4,
756757
message: 'Missing @param "bbox.x"',
757758
},
758759
{
760+
line: 4,
759761
message: 'Missing @param "bbox.y"',
760762
},
761763
{
764+
line: 4,
762765
message: 'Missing @param "bbox.width"',
763766
},
764767
{
768+
line: 4,
765769
message: 'Missing @param "bbox.height"',
766770
},
767771
],
@@ -783,15 +787,19 @@ export default {
783787
`,
784788
errors: [
785789
{
790+
line: 4,
786791
message: 'Missing @param "bbox.x"',
787792
},
788793
{
794+
line: 4,
789795
message: 'Missing @param "bbox.y"',
790796
},
791797
{
798+
line: 4,
792799
message: 'Missing @param "bbox.width"',
793800
},
794801
{
802+
line: 4,
795803
message: 'Missing @param "bbox.height"',
796804
},
797805
],
@@ -809,9 +817,11 @@ export default {
809817
`,
810818
errors: [
811819
{
820+
line: 4,
812821
message: 'Missing @param "fetchOptions.url"',
813822
},
814823
{
824+
line: 4,
815825
message: 'Missing @param "fetchOptions.options"',
816826
},
817827
],
@@ -905,9 +915,11 @@ export default {
905915
`,
906916
errors: [
907917
{
918+
line: 4,
908919
message: 'Missing @param "options.foo"',
909920
},
910921
{
922+
line: 4,
911923
message: 'Missing @param "options.foo.bar"',
912924
},
913925
],
@@ -958,9 +970,11 @@ export default {
958970
`,
959971
errors: [
960972
{
973+
line: 6,
961974
message: '@param "props.prop.a" does not exist on props',
962975
},
963976
{
977+
line: 7,
964978
message: '@param "props.prop.b" does not exist on props',
965979
},
966980
],

0 commit comments

Comments
 (0)
Please sign in to comment.