Skip to content

Commit 280b736

Browse files
azyzz228ljharb
authored andcommitted
[Tests] namespace: add passing test case to close #2572
1 parent 519d256 commit 280b736

File tree

5 files changed

+64
-0
lines changed

5 files changed

+64
-0
lines changed

tests/files/jsx/bar/baz.jsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
export function Baz1() {
3+
return (
4+
<div>
5+
</div>
6+
);
7+
}
8+
9+
// Fragment Syntax
10+
export function Baz2() {
11+
return (
12+
<div>
13+
<span>Baz2</span>
14+
</div>
15+
);
16+
}

tests/files/jsx/bar/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from "./baz.jsx";
2+
export { Qux1, Qux2 } from "./qux.jsx";

tests/files/jsx/bar/qux.jsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
export function Qux1() {
3+
return (
4+
<div>
5+
<p>Qux1</p>
6+
</div>
7+
);
8+
}
9+
10+
export function Qux2() {
11+
return (
12+
<div>
13+
<p>Qux1</p>
14+
</div>
15+
);;
16+
}

tests/files/jsx/re-export.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './named.jsx'

tests/src/rules/namespace.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,35 @@ const valid = [
2929
ecmaVersion: 2015,
3030
},
3131
}),
32+
// import re-exported jsx files, where jsx file exports a string
33+
test({
34+
code: `
35+
import * as foo from "./jsx/re-export.js";
36+
console.log(foo.jsxFoo);
37+
`,
38+
settings: {
39+
'import/extensions': ['.js', '.jsx'],
40+
},
41+
}),
42+
// import re-exported jsx files, where jsx files export functions that return html tags
43+
test({
44+
code: `
45+
import * as foo from "./jsx/bar/index.js";
46+
console.log(foo.Baz1);
47+
console.log(foo.Baz2);
48+
console.log(foo.Qux1);
49+
console.log(foo.Qux2);
50+
`,
51+
settings: {
52+
'import/extensions': ['.js', '.jsx'],
53+
},
54+
parserOptions: {
55+
ecmaFeatures: {
56+
jsx: true,
57+
},
58+
},
59+
}),
60+
3261
test({ code: "import * as foo from './common';" }),
3362

3463
// destructuring namespaces

0 commit comments

Comments
 (0)