@@ -391,6 +391,22 @@ ruleTester.run('extensions', rule, {
391
391
options : [ 'never' , { ignorePackages : true } ] ,
392
392
} ) ,
393
393
394
+ test ( {
395
+ code : `
396
+ import foo from './foo.js'
397
+ import bar from './bar.json'
398
+ import Component from './Component.jsx'
399
+ ` ,
400
+ errors : [
401
+ {
402
+ message : 'Unexpected use of file extension "jsx" for "./Component.jsx"' ,
403
+ line : 4 ,
404
+ column : 31 ,
405
+ } ,
406
+ ] ,
407
+ options : [ 'always' , { pattern : { jsx : 'never' } } ] ,
408
+ } ) ,
409
+
394
410
// export (#964)
395
411
test ( {
396
412
code : [
@@ -444,6 +460,48 @@ ruleTester.run('extensions', rule, {
444
460
} ,
445
461
] ,
446
462
} ) ,
463
+ // require (#1230)
464
+ test ( {
465
+ code : [
466
+ 'const { foo } = require("./foo")' ,
467
+ 'export { foo }' ,
468
+ ] . join ( '\n' ) ,
469
+ options : [ 'always' ] ,
470
+ errors : [
471
+ {
472
+ message : 'Missing file extension for "./foo"' ,
473
+ line : 1 ,
474
+ column : 25 ,
475
+ } ,
476
+ ] ,
477
+ } ) ,
478
+ test ( {
479
+ code : [
480
+ 'const { foo } = require("./foo.js")' ,
481
+ 'export { foo }' ,
482
+ ] . join ( '\n' ) ,
483
+ options : [ 'never' ] ,
484
+ errors : [
485
+ {
486
+ message : 'Unexpected use of file extension "js" for "./foo.js"' ,
487
+ line : 1 ,
488
+ column : 25 ,
489
+ } ,
490
+ ] ,
491
+ } ) ,
492
+
493
+ // export { } from
494
+ test ( {
495
+ code : 'export { foo } from "./foo"' ,
496
+ options : [ 'always' ] ,
497
+ errors : [
498
+ {
499
+ message : 'Missing file extension for "./foo"' ,
500
+ line : 1 ,
501
+ column : 21 ,
502
+ } ,
503
+ ] ,
504
+ } ) ,
447
505
test ( {
448
506
code : 'import foo from "@/ImNotAScopedModule"' ,
449
507
options : [ 'always' ] ,
@@ -454,5 +512,40 @@ ruleTester.run('extensions', rule, {
454
512
} ,
455
513
] ,
456
514
} ) ,
515
+ test ( {
516
+ code : 'export { foo } from "./foo.js"' ,
517
+ options : [ 'never' ] ,
518
+ errors : [
519
+ {
520
+ message : 'Unexpected use of file extension "js" for "./foo.js"' ,
521
+ line : 1 ,
522
+ column : 21 ,
523
+ } ,
524
+ ] ,
525
+ } ) ,
526
+
527
+ // export * from
528
+ test ( {
529
+ code : 'export * from "./foo"' ,
530
+ options : [ 'always' ] ,
531
+ errors : [
532
+ {
533
+ message : 'Missing file extension for "./foo"' ,
534
+ line : 1 ,
535
+ column : 15 ,
536
+ } ,
537
+ ] ,
538
+ } ) ,
539
+ test ( {
540
+ code : 'export * from "./foo.js"' ,
541
+ options : [ 'never' ] ,
542
+ errors : [
543
+ {
544
+ message : 'Unexpected use of file extension "js" for "./foo.js"' ,
545
+ line : 1 ,
546
+ column : 15 ,
547
+ } ,
548
+ ] ,
549
+ } ) ,
457
550
] ,
458
551
} ) ;
0 commit comments