@@ -96,13 +96,28 @@ describe('rules/disallow-multiple-var-decl', function() {
9696 it ( 'should report multiple var decls with require mixed with normal' , function ( ) {
9797 expect ( checker . checkString ( 'var first = require("first"), second = 1;' ) )
9898 . to . have . one . validation . error . from ( 'disallowMultipleVarDecl' ) ;
99+
100+ var test = 'var first = require("first"), second = 1, third = require("foo").Foo' ;
101+ expect ( checker . checkString ( test ) ) . to . have . one . validation . error . from ( 'disallowMultipleVarDecl' ) ;
102+ } ) ;
103+ it ( 'should report multiple var decls with require mixed with undefined' , function ( ) {
104+ var test = 'var first = require("first"), second = require("foo").Foo, third;' ;
105+ expect ( checker . checkString ( test ) ) . to . have . one . validation . error . from ( 'disallowMultipleVarDecl' ) ;
99106 } ) ;
100107 it ( 'should report multiple var decls' , function ( ) {
101108 expect ( checker . checkString ( 'var x, y;' ) ) . to . have . one . validation . error . from ( 'disallowMultipleVarDecl' ) ;
102109 } ) ;
103110 it ( 'should not report consecutive var decls' , function ( ) {
104111 expect ( checker . checkString ( 'var x; var y;' ) ) . to . have . no . errors ( ) ;
105112 } ) ;
113+ it ( 'should not report multiple var decls sourced from required' , function ( ) {
114+ expect ( checker . checkString ( 'var x = require("fs"), y = require("fs").File;' ) ) . to . have . no . errors ( ) ;
115+ expect ( checker . checkString ( 'var x = require("fs").File, y = require("fs").foo();' ) ) . to . have . no . errors ( ) ;
116+ expect ( checker . checkString ( 'var x = require("fs"), y = require("fs").some.long().chain.test();' ) )
117+ . to . have . no . errors ( ) ;
118+ expect ( checker . checkString ( 'var x = require("fs"), y = require("fs").some().long().chain.test;' ) )
119+ . to . have . no . errors ( ) ;
120+ } ) ;
106121 } ) ;
107122
108123 describe ( 'options as object' , function ( ) {
@@ -114,8 +129,8 @@ describe('rules/disallow-multiple-var-decl', function() {
114129 it ( 'should accept require and undefined as allExcept value' , function ( ) {
115130 checker . configure ( { disallowMultipleVarDecl : { allExcept : [ 'undefined' , 'require' ] } } ) ;
116131
117- expect ( checker . checkString ( 'var a = require("a"), b = require("b"), x, y, z;' ) ) . to . have . no . errors ( ) ;
118- expect ( checker . checkString ( 'var a = require("a"), b = require("b"), x, y, c = 1;' ) )
132+ expect ( checker . checkString ( 'var a = require("a"), b = require("b").getMe() , x, y, z;' ) ) . to . have . no . errors ( ) ;
133+ expect ( checker . checkString ( 'var a = require("a").Instance , b = require("b"), x, y, c = 1;' ) )
119134 . to . have . one . validation . error . from ( 'disallowMultipleVarDecl' ) ;
120135 } ) ;
121136 it ( 'should accept strict as option' , function ( ) {
0 commit comments