@@ -23,7 +23,8 @@ const parserOptions = {
23
23
// Code Snippets
24
24
// ------------------------------------------------------------------------------
25
25
26
- const withJSX = 'module.exports = function MyComponent() { return <div>\n<div />\n</div>; }' ;
26
+ const withJSXElement = 'module.exports = function MyComponent() { return <div>\n<div />\n</div>; }' ;
27
+ const withJSXFragment = 'module.exports = function MyComponent() { return <>\n</>; }' ;
27
28
const withoutJSX = 'module.exports = {}' ;
28
29
29
30
// ------------------------------------------------------------------------------
@@ -36,29 +37,54 @@ ruleTester.run('jsx-filename-extension', rule, {
36
37
valid : [
37
38
{
38
39
filename : '<text>' ,
39
- code : withJSX
40
+ code : withJSXElement
40
41
} ,
41
42
{
42
43
filename : 'MyComponent.jsx' ,
43
- code : withJSX
44
+ code : withJSXElement
44
45
} , {
45
46
filename : 'MyComponent.js' ,
46
47
options : [ { extensions : [ '.js' , '.jsx' ] } ] ,
47
- code : withJSX
48
+ code : withJSXElement
48
49
} , {
49
50
filename : 'notAComponent.js' ,
50
51
code : withoutJSX
52
+ } , {
53
+ filename : '<text>' ,
54
+ code : withJSXFragment ,
55
+ parser : 'babel-eslint'
56
+ } ,
57
+ {
58
+ filename : 'MyComponent.jsx' ,
59
+ code : withJSXFragment ,
60
+ parser : 'babel-eslint'
61
+ } , {
62
+ filename : 'MyComponent.js' ,
63
+ options : [ { extensions : [ '.js' , '.jsx' ] } ] ,
64
+ code : withJSXFragment ,
65
+ parser : 'babel-eslint'
51
66
}
52
67
] ,
53
68
54
69
invalid : [
55
70
{
56
71
filename : 'MyComponent.js' ,
57
- code : withJSX ,
72
+ code : withJSXElement ,
73
+ errors : [ { message : 'JSX not allowed in files with extension \'.js\'' } ]
74
+ } , {
75
+ filename : 'MyComponent.jsx' ,
76
+ code : withJSXElement ,
77
+ options : [ { extensions : [ '.js' ] } ] ,
78
+ errors : [ { message : 'JSX not allowed in files with extension \'.jsx\'' } ]
79
+ } , {
80
+ filename : 'MyComponent.js' ,
81
+ code : withJSXFragment ,
82
+ parser : 'babel-eslint' ,
58
83
errors : [ { message : 'JSX not allowed in files with extension \'.js\'' } ]
59
84
} , {
60
85
filename : 'MyComponent.jsx' ,
61
- code : withJSX ,
86
+ code : withJSXFragment ,
87
+ parser : 'babel-eslint' ,
62
88
options : [ { extensions : [ '.js' ] } ] ,
63
89
errors : [ { message : 'JSX not allowed in files with extension \'.jsx\'' } ]
64
90
}
0 commit comments