@@ -7,6 +7,7 @@ const ruleTester = new RuleTester()
7
7
8
8
ruleTester . run ( 'no-internal-modules' , rule , {
9
9
valid : [
10
+ // imports
10
11
test ( {
11
12
code : 'import a from "./plugin2"' ,
12
13
filename : testFilePath ( './internal-modules/plugins/plugin.js' ) ,
@@ -57,9 +58,44 @@ ruleTester.run('no-internal-modules', rule, {
57
58
allow : [ '**/index{.js,}' ] ,
58
59
} ] ,
59
60
} ) ,
61
+ // exports
62
+ test ( {
63
+ code : 'export {a} from "./internal.js"' ,
64
+ filename : testFilePath ( './internal-modules/plugins/plugin2/index.js' ) ,
65
+ } ) ,
66
+ test ( {
67
+ code : 'export * from "lodash.get"' ,
68
+ filename : testFilePath ( './internal-modules/plugins/plugin2/index.js' ) ,
69
+ } ) ,
70
+ test ( {
71
+ code : 'export {b} from "@org/package"' ,
72
+ filename : testFilePath ( './internal-modules/plugins/plugin2/internal.js' ) ,
73
+ } ) ,
74
+ test ( {
75
+ code : 'export {b} from "../../api/service"' ,
76
+ filename : testFilePath ( './internal-modules/plugins/plugin2/internal.js' ) ,
77
+ options : [ {
78
+ allow : [ '**/api/*' ] ,
79
+ } ] ,
80
+ } ) ,
81
+ test ( {
82
+ code : 'export * from "jquery/dist/jquery"' ,
83
+ filename : testFilePath ( './internal-modules/plugins/plugin2/internal.js' ) ,
84
+ options : [ {
85
+ allow : [ 'jquery/dist/*' ] ,
86
+ } ] ,
87
+ } ) ,
88
+ test ( {
89
+ code : 'export * from "./app/index.js";\nexport * from "./app/index"' ,
90
+ filename : testFilePath ( './internal-modules/plugins/plugin2/internal.js' ) ,
91
+ options : [ {
92
+ allow : [ '**/index{.js,}' ] ,
93
+ } ] ,
94
+ } ) ,
60
95
] ,
61
96
62
97
invalid : [
98
+ // imports
63
99
test ( {
64
100
code : 'import "./plugin2/index.js";\nimport "./plugin2/app/index"' ,
65
101
filename : testFilePath ( './internal-modules/plugins/plugin.js' ) ,
@@ -126,5 +162,72 @@ ruleTester.run('no-internal-modules', rule, {
126
162
} ,
127
163
] ,
128
164
} ) ,
165
+ // exports
166
+ test ( {
167
+ code : 'export * from "./plugin2/index.js";\nexport * from "./plugin2/app/index"' ,
168
+ filename : testFilePath ( './internal-modules/plugins/plugin.js' ) ,
169
+ options : [ {
170
+ allow : [ '*/index.js' ] ,
171
+ } ] ,
172
+ errors : [ {
173
+ message : 'Reaching to "./plugin2/app/index" is not allowed.' ,
174
+ line : 2 ,
175
+ column : 15 ,
176
+ } ] ,
177
+ } ) ,
178
+ test ( {
179
+ code : 'export * from "./app/index.js"' ,
180
+ filename : testFilePath ( './internal-modules/plugins/plugin2/internal.js' ) ,
181
+ errors : [ {
182
+ message : 'Reaching to "./app/index.js" is not allowed.' ,
183
+ line : 1 ,
184
+ column : 15 ,
185
+ } ] ,
186
+ } ) ,
187
+ test ( {
188
+ code : 'export {b} from "./plugin2/internal"' ,
189
+ filename : testFilePath ( './internal-modules/plugins/plugin.js' ) ,
190
+ errors : [ {
191
+ message : 'Reaching to "./plugin2/internal" is not allowed.' ,
192
+ line : 1 ,
193
+ column : 17 ,
194
+ } ] ,
195
+ } ) ,
196
+ test ( {
197
+ code : 'export {a} from "../api/service/index"' ,
198
+ filename : testFilePath ( './internal-modules/plugins/plugin.js' ) ,
199
+ options : [ {
200
+ allow : [ '**/internal-modules/*' ] ,
201
+ } ] ,
202
+ errors : [
203
+ {
204
+ message : 'Reaching to "../api/service/index" is not allowed.' ,
205
+ line : 1 ,
206
+ column : 17 ,
207
+ } ,
208
+ ] ,
209
+ } ) ,
210
+ test ( {
211
+ code : 'export {b} from "@org/package/internal"' ,
212
+ filename : testFilePath ( './internal-modules/plugins/plugin2/internal.js' ) ,
213
+ errors : [
214
+ {
215
+ message : 'Reaching to "@org/package/internal" is not allowed.' ,
216
+ line : 1 ,
217
+ column : 17 ,
218
+ } ,
219
+ ] ,
220
+ } ) ,
221
+ test ( {
222
+ code : 'export {get} from "debug/node"' ,
223
+ filename : testFilePath ( './internal-modules/plugins/plugin.js' ) ,
224
+ errors : [
225
+ {
226
+ message : 'Reaching to "debug/node" is not allowed.' ,
227
+ line : 1 ,
228
+ column : 19 ,
229
+ } ,
230
+ ] ,
231
+ } ) ,
129
232
] ,
130
233
} )
0 commit comments