@@ -391,6 +391,22 @@ ruleTester.run('extensions', rule, {
391391 options : [ 'never' , { ignorePackages : true } ] ,
392392 } ) ,
393393
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+
394410 // export (#964)
395411 test ( {
396412 code : [
@@ -444,6 +460,48 @@ ruleTester.run('extensions', rule, {
444460 } ,
445461 ] ,
446462 } ) ,
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+ } ) ,
447505 test ( {
448506 code : 'import foo from "@/ImNotAScopedModule"' ,
449507 options : [ 'always' ] ,
@@ -454,5 +512,40 @@ ruleTester.run('extensions', rule, {
454512 } ,
455513 ] ,
456514 } ) ,
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+ } ) ,
457550 ] ,
458551} ) ;
0 commit comments