@@ -58,7 +58,11 @@ ruleTester.run('no-commonjs', require('rules/no-commonjs'), {
58
58
{ code : 'module.exports = "foo"' , options : [ { allowPrimitiveModules : true } ] } ,
59
59
60
60
{ code : 'if (typeof window !== "undefined") require("x")' , options : [ { allowRequire : true } ] } ,
61
+ { code : 'if (typeof window !== "undefined") require("x")' , options : [ { allowRequire : false } ] } ,
61
62
{ code : 'if (typeof window !== "undefined") { require("x") }' , options : [ { allowRequire : true } ] } ,
63
+ { code : 'if (typeof window !== "undefined") { require("x") }' , options : [ { allowRequire : false } ] } ,
64
+
65
+ { code : 'try { require("x") } catch (error) {}' } ,
62
66
] ,
63
67
64
68
invalid : [
@@ -68,12 +72,6 @@ ruleTester.run('no-commonjs', require('rules/no-commonjs'), {
68
72
{ code : 'var x = require("x")' , errors : [ { message : IMPORT_MESSAGE } ] } ,
69
73
{ code : 'x = require("x")' , errors : [ { message : IMPORT_MESSAGE } ] } ,
70
74
{ code : 'require("x")' , errors : [ { message : IMPORT_MESSAGE } ] } ,
71
- { code : 'if (typeof window !== "undefined") require("x")' ,
72
- errors : [ { message : IMPORT_MESSAGE } ] ,
73
- } ,
74
- { code : 'if (typeof window !== "undefined") { require("x") }' ,
75
- errors : [ { message : IMPORT_MESSAGE } ] ,
76
- } ,
77
75
] ) ,
78
76
79
77
// exports
0 commit comments