@@ -351,6 +351,19 @@ ruleTester.run('no-unescaped-entities', rule, {
351
351
{
352
352
messageId : 'unescapedEntityAlts' ,
353
353
data : { entity : '>' , alts : '`>`' } ,
354
+ suggestions : [ {
355
+ messageId : 'replaceWithAlt' ,
356
+ data : { alt : '>' } ,
357
+ output : `
358
+ var Hello = createReactClass({
359
+ render: function() {
360
+ return <>first line is ok
361
+ so is second
362
+ and here are some bad entities: ></>
363
+ }
364
+ });
365
+ ` ,
366
+ } ] ,
354
367
} ,
355
368
] ,
356
369
} ,
@@ -366,6 +379,52 @@ ruleTester.run('no-unescaped-entities', rule, {
366
379
{
367
380
messageId : 'unescapedEntityAlts' ,
368
381
data : { entity : '\'' , alts : '`'`, `‘`, `'`, `’`' } ,
382
+ suggestions : [
383
+ {
384
+ messageId : 'replaceWithAlt' ,
385
+ data : { alt : ''' } ,
386
+ output : `
387
+ var Hello = createReactClass({
388
+ render: function() {
389
+ return <div>'</div>;
390
+ }
391
+ });
392
+ ` ,
393
+ } ,
394
+ {
395
+ messageId : 'replaceWithAlt' ,
396
+ data : { alt : '‘' } ,
397
+ output : `
398
+ var Hello = createReactClass({
399
+ render: function() {
400
+ return <div>‘</div>;
401
+ }
402
+ });
403
+ ` ,
404
+ } ,
405
+ {
406
+ messageId : 'replaceWithAlt' ,
407
+ data : { alt : ''' } ,
408
+ output : `
409
+ var Hello = createReactClass({
410
+ render: function() {
411
+ return <div>'</div>;
412
+ }
413
+ });
414
+ ` ,
415
+ } ,
416
+ {
417
+ messageId : 'replaceWithAlt' ,
418
+ data : { alt : '’' } ,
419
+ output : `
420
+ var Hello = createReactClass({
421
+ render: function() {
422
+ return <div>’</div>;
423
+ }
424
+ });
425
+ ` ,
426
+ } ,
427
+ ] ,
369
428
} ,
370
429
] ,
371
430
} ,
@@ -382,6 +441,17 @@ ruleTester.run('no-unescaped-entities', rule, {
382
441
{
383
442
messageId : 'unescapedEntityAlts' ,
384
443
data : { entity : '}' , alts : '`}`' } ,
444
+ suggestions : [ {
445
+ messageId : 'replaceWithAlt' ,
446
+ data : { alt : '}' } ,
447
+ output : `
448
+ var Hello = createReactClass({
449
+ render: function() {
450
+ return <>{"Unbalanced braces - babel-eslint"}}</>;
451
+ }
452
+ });
453
+ ` ,
454
+ } ] ,
385
455
} ,
386
456
] ,
387
457
} ,
@@ -430,6 +500,17 @@ ruleTester.run('no-unescaped-entities', rule, {
430
500
{
431
501
messageId : 'unescapedEntityAlts' ,
432
502
data : { entity : '&' , alts : '`&`' } ,
503
+ suggestions : [ {
504
+ messageId : 'replaceWithAlt' ,
505
+ data : { alt : '&' } ,
506
+ output : `
507
+ var Hello = createReactClass({
508
+ render: function() {
509
+ return <span>foo & bar</span>;
510
+ }
511
+ });
512
+ ` ,
513
+ } ] ,
433
514
} ,
434
515
] ,
435
516
options : [
@@ -489,6 +570,36 @@ ruleTester.run('no-unescaped-entities', rule, {
489
570
data : { entity : '"' , alts : '`"`, `“`, `"`, `”`' } ,
490
571
line : 2 ,
491
572
column : 34 ,
573
+ suggestions : [
574
+ {
575
+ messageId : 'replaceWithAlt' ,
576
+ data : { alt : '"' } ,
577
+ output : `
578
+ <script>window.foo = "bar"</script>
579
+ ` ,
580
+ } ,
581
+ {
582
+ messageId : 'replaceWithAlt' ,
583
+ data : { alt : '“' } ,
584
+ output : `
585
+ <script>window.foo = "bar“</script>
586
+ ` ,
587
+ } ,
588
+ {
589
+ messageId : 'replaceWithAlt' ,
590
+ data : { alt : '"' } ,
591
+ output : `
592
+ <script>window.foo = "bar"</script>
593
+ ` ,
594
+ } ,
595
+ {
596
+ messageId : 'replaceWithAlt' ,
597
+ data : { alt : '”' } ,
598
+ output : `
599
+ <script>window.foo = "bar”</script>
600
+ ` ,
601
+ } ,
602
+ ] ,
492
603
} ,
493
604
] ,
494
605
}
0 commit comments