@@ -119,6 +119,9 @@ describe('utils', () => {
119
119
'const notRule = foo(); export default notRule;' ,
120
120
'const notRule = function(){}; export default notRule;' ,
121
121
'const notRule = {}; export default notRule;' ,
122
+ 'const notRule = {}; export = notRule;' ,
123
+ 'const notRule: Rule.RuleModule = {}; export = notRule;' ,
124
+ 'export = {};' ,
122
125
] . forEach ( ( noRuleCase ) => {
123
126
it ( `returns null for ${ noRuleCase } ` , ( ) => {
124
127
const ast = typescriptEslintParser . parse ( noRuleCase , {
@@ -188,6 +191,65 @@ describe('utils', () => {
188
191
isNewStyle : true ,
189
192
} ,
190
193
194
+ // No helper.
195
+ 'export default { create() {}, meta: {} };' : {
196
+ create : { type : 'FunctionExpression' } ,
197
+ meta : { type : 'ObjectExpression' } ,
198
+ isNewStyle : true ,
199
+ } ,
200
+ // No helper, `export =` syntax.
201
+ 'export = { create() {}, meta: {} };' : {
202
+ create : { type : 'FunctionExpression' } ,
203
+ meta : { type : 'ObjectExpression' } ,
204
+ isNewStyle : true ,
205
+ } ,
206
+ // No helper, variable.
207
+ 'const rule = { create() {}, meta: {} }; export default rule;' : {
208
+ create : { type : 'FunctionExpression' } ,
209
+ meta : { type : 'ObjectExpression' } ,
210
+ isNewStyle : true ,
211
+ } ,
212
+ // no helper, variable with type.
213
+ 'const rule: Rule.RuleModule = { create() {}, meta: {} }; export default rule;' :
214
+ {
215
+ create : { type : 'FunctionExpression' } ,
216
+ meta : { type : 'ObjectExpression' } ,
217
+ isNewStyle : true ,
218
+ } ,
219
+ // No helper, variable, `export =` syntax.
220
+ 'const rule = { create() {}, meta: {} }; export = rule;' : {
221
+ create : { type : 'FunctionExpression' } ,
222
+ meta : { type : 'ObjectExpression' } ,
223
+ isNewStyle : true ,
224
+ } ,
225
+ // No helper, variable with type, `export =` syntax.
226
+ 'const rule: Rule.RuleModule = { create() {}, meta: {} }; export = rule;' :
227
+ {
228
+ create : { type : 'FunctionExpression' } ,
229
+ meta : { type : 'ObjectExpression' } ,
230
+ isNewStyle : true ,
231
+ } ,
232
+ // Helper, variable, `export =` syntax.
233
+ 'const rule = createESLintRule({ create() {}, meta: {} }); export = rule;' :
234
+ {
235
+ create : { type : 'FunctionExpression' } ,
236
+ meta : { type : 'ObjectExpression' } ,
237
+ isNewStyle : true ,
238
+ } ,
239
+ // Helper, variable with type, `export =` syntax.
240
+ 'const rule: Rule.RuleModule = createESLintRule({ create() {}, meta: {} }); export = rule;' :
241
+ {
242
+ create : { type : 'FunctionExpression' } ,
243
+ meta : { type : 'ObjectExpression' } ,
244
+ isNewStyle : true ,
245
+ } ,
246
+ // Helper, `export =` syntax.
247
+ 'export = createESLintRule({ create() {}, meta: {} });' : {
248
+ create : { type : 'FunctionExpression' } ,
249
+ meta : { type : 'ObjectExpression' } ,
250
+ isNewStyle : true ,
251
+ } ,
252
+
191
253
// Util function with "{} as const".
192
254
'export default createESLintRule({ create() {}, meta: {} as const });' :
193
255
{
0 commit comments