@@ -108,40 +108,11 @@ test({
108108 'const x = foo.length || `bar`' ,
109109 'const A_STRING = "bar"; const x = foo.length || A_STRING' ,
110110 'const size = props.size || "mini"' ,
111+ 'const x = foo.length || unknown' ,
112+ 'something(options.length || 500)' ,
113+ 'const itemCount = result.totalCount || result.length' ,
111114 ] ,
112115 invalid : [
113- suggestionCase ( {
114- code : 'const x = foo.length || bar()' ,
115- messageId : TYPE_NON_ZERO ,
116- output : 'const x = foo.length > 0 || bar()' ,
117- desc : 'Replace `.length` with `.length > 0`.' ,
118- } ) ,
119- suggestionCase ( {
120- code : 'const x = foo.length || unknown' ,
121- messageId : TYPE_NON_ZERO ,
122- output : 'const x = foo.length > 0 || unknown' ,
123- desc : 'Replace `.length` with `.length > 0`.' ,
124- } ) ,
125- suggestionCase ( {
126- code : 'const NON_NUMBER = true; const x = foo.length || NON_NUMBER' ,
127- messageId : TYPE_NON_ZERO ,
128- output : 'const NON_NUMBER = true; const x = foo.length > 0 || NON_NUMBER' ,
129- desc : 'Replace `.length` with `.length > 0`.' ,
130- } ) ,
131- suggestionCase ( {
132- code : 'const x = foo.length || bar()' ,
133- messageId : TYPE_NON_ZERO ,
134- output : 'const x = foo.length !== 0 || bar()' ,
135- desc : 'Replace `.length` with `.length !== 0`.' ,
136- options : [ { 'non-zero' : 'not-equal' } ] ,
137- } ) ,
138- suggestionCase ( {
139- code : 'const x = foo.length || bar()' ,
140- messageId : TYPE_NON_ZERO ,
141- output : 'const x = foo.length > 0 || bar()' ,
142- desc : 'Replace `.length` with `.length > 0`.' ,
143- options : [ { 'non-zero' : 'greater-than' } ] ,
144- } ) ,
145116 suggestionCase ( {
146117 code : '() => foo.length && bar()' ,
147118 messageId : TYPE_NON_ZERO ,
0 commit comments