|
| 1 | +# Snapshot report for `test/consistent-existence-index-check.mjs` |
| 2 | + |
| 3 | +The actual snapshot is saved in `consistent-existence-index-check.mjs.snap`. |
| 4 | + |
| 5 | +Generated by [AVA](https://avajs.dev). |
| 6 | + |
| 7 | +## invalid(1): const index = foo.indexOf(bar); index < 0 |
| 8 | + |
| 9 | +> Input |
| 10 | +
|
| 11 | + `␊ |
| 12 | + 1 | const index = foo.indexOf(bar); index < 0␊ |
| 13 | + ` |
| 14 | + |
| 15 | +> Output |
| 16 | +
|
| 17 | + `␊ |
| 18 | + 1 | const index = foo.indexOf(bar); index === -1␊ |
| 19 | + ` |
| 20 | + |
| 21 | +> Error 1/1 |
| 22 | +
|
| 23 | + `␊ |
| 24 | + > 1 | const index = foo.indexOf(bar); index < 0␊ |
| 25 | + | ^^^ Prefer \`=== -1\` over \`< 0\` to check non-existence.␊ |
| 26 | + ` |
| 27 | + |
| 28 | +## invalid(2): const index = foo.indexOf(bar); index >= 0 |
| 29 | + |
| 30 | +> Input |
| 31 | +
|
| 32 | + `␊ |
| 33 | + 1 | const index = foo.indexOf(bar); index >= 0␊ |
| 34 | + ` |
| 35 | + |
| 36 | +> Output |
| 37 | +
|
| 38 | + `␊ |
| 39 | + 1 | const index = foo.indexOf(bar); index !== -1␊ |
| 40 | + ` |
| 41 | + |
| 42 | +> Error 1/1 |
| 43 | +
|
| 44 | + `␊ |
| 45 | + > 1 | const index = foo.indexOf(bar); index >= 0␊ |
| 46 | + | ^^^^ Prefer \`!== -1\` over \`>= 0\` to check existence.␊ |
| 47 | + ` |
| 48 | + |
| 49 | +## invalid(3): const index = foo.indexOf(bar); index > -1 |
| 50 | + |
| 51 | +> Input |
| 52 | +
|
| 53 | + `␊ |
| 54 | + 1 | const index = foo.indexOf(bar); index > -1␊ |
| 55 | + ` |
| 56 | + |
| 57 | +> Output |
| 58 | +
|
| 59 | + `␊ |
| 60 | + 1 | const index = foo.indexOf(bar); index !== -1␊ |
| 61 | + ` |
| 62 | + |
| 63 | +> Error 1/1 |
| 64 | +
|
| 65 | + `␊ |
| 66 | + > 1 | const index = foo.indexOf(bar); index > -1␊ |
| 67 | + | ^^^^ Prefer \`!== -1\` over \`> -1\` to check existence.␊ |
| 68 | + ` |
| 69 | + |
| 70 | +## invalid(4): const index = foo.indexOf(bar); index < 0 |
| 71 | + |
| 72 | +> Input |
| 73 | +
|
| 74 | + `␊ |
| 75 | + 1 | const index = foo.indexOf(bar); index < 0␊ |
| 76 | + ` |
| 77 | + |
| 78 | +> Output |
| 79 | +
|
| 80 | + `␊ |
| 81 | + 1 | const index = foo.indexOf(bar); index === -1␊ |
| 82 | + ` |
| 83 | + |
| 84 | +> Error 1/1 |
| 85 | +
|
| 86 | + `␊ |
| 87 | + > 1 | const index = foo.indexOf(bar); index < 0␊ |
| 88 | + | ^^^ Prefer \`=== -1\` over \`< 0\` to check non-existence.␊ |
| 89 | + ` |
| 90 | + |
| 91 | +## invalid(5): const index = foo.lastIndexOf(bar); index < 0 |
| 92 | + |
| 93 | +> Input |
| 94 | +
|
| 95 | + `␊ |
| 96 | + 1 | const index = foo.lastIndexOf(bar); index < 0␊ |
| 97 | + ` |
| 98 | + |
| 99 | +> Output |
| 100 | +
|
| 101 | + `␊ |
| 102 | + 1 | const index = foo.lastIndexOf(bar); index === -1␊ |
| 103 | + ` |
| 104 | + |
| 105 | +> Error 1/1 |
| 106 | +
|
| 107 | + `␊ |
| 108 | + > 1 | const index = foo.lastIndexOf(bar); index < 0␊ |
| 109 | + | ^^^ Prefer \`=== -1\` over \`< 0\` to check non-existence.␊ |
| 110 | + ` |
| 111 | + |
| 112 | +## invalid(6): const index = foo.findIndex(bar); index < 0 |
| 113 | + |
| 114 | +> Input |
| 115 | +
|
| 116 | + `␊ |
| 117 | + 1 | const index = foo.findIndex(bar); index < 0␊ |
| 118 | + ` |
| 119 | + |
| 120 | +> Output |
| 121 | +
|
| 122 | + `␊ |
| 123 | + 1 | const index = foo.findIndex(bar); index === -1␊ |
| 124 | + ` |
| 125 | + |
| 126 | +> Error 1/1 |
| 127 | +
|
| 128 | + `␊ |
| 129 | + > 1 | const index = foo.findIndex(bar); index < 0␊ |
| 130 | + | ^^^ Prefer \`=== -1\` over \`< 0\` to check non-existence.␊ |
| 131 | + ` |
| 132 | + |
| 133 | +## invalid(7): const index = foo.findLastIndex(bar); index < 0 |
| 134 | + |
| 135 | +> Input |
| 136 | +
|
| 137 | + `␊ |
| 138 | + 1 | const index = foo.findLastIndex(bar); index < 0␊ |
| 139 | + ` |
| 140 | + |
| 141 | +> Output |
| 142 | +
|
| 143 | + `␊ |
| 144 | + 1 | const index = foo.findLastIndex(bar); index === -1␊ |
| 145 | + ` |
| 146 | + |
| 147 | +> Error 1/1 |
| 148 | +
|
| 149 | + `␊ |
| 150 | + > 1 | const index = foo.findLastIndex(bar); index < 0␊ |
| 151 | + | ^^^ Prefer \`=== -1\` over \`< 0\` to check non-existence.␊ |
| 152 | + ` |
| 153 | + |
| 154 | +## invalid(8): const index = foo.indexOf(bar); function foo () { if (index < 0) {} } |
| 155 | + |
| 156 | +> Input |
| 157 | +
|
| 158 | + `␊ |
| 159 | + 1 | const index = foo.indexOf(bar);␊ |
| 160 | + 2 |␊ |
| 161 | + 3 | function foo () {␊ |
| 162 | + 4 | if (index < 0) {}␊ |
| 163 | + 5 | }␊ |
| 164 | + ` |
| 165 | + |
| 166 | +> Output |
| 167 | +
|
| 168 | + `␊ |
| 169 | + 1 | const index = foo.indexOf(bar);␊ |
| 170 | + 2 |␊ |
| 171 | + 3 | function foo () {␊ |
| 172 | + 4 | if (index === -1) {}␊ |
| 173 | + 5 | }␊ |
| 174 | + ` |
| 175 | + |
| 176 | +> Error 1/1 |
| 177 | +
|
| 178 | + `␊ |
| 179 | + 1 | const index = foo.indexOf(bar);␊ |
| 180 | + 2 |␊ |
| 181 | + 3 | function foo () {␊ |
| 182 | + > 4 | if (index < 0) {}␊ |
| 183 | + | ^^^ Prefer \`=== -1\` over \`< 0\` to check non-existence.␊ |
| 184 | + 5 | }␊ |
| 185 | + ` |
| 186 | + |
| 187 | +## invalid(9): const index1 = foo.indexOf("1"), index2 = foo.indexOf("2"); index1 < 0; index2 >= 0; |
| 188 | + |
| 189 | +> Input |
| 190 | +
|
| 191 | + `␊ |
| 192 | + 1 | const index1 = foo.indexOf("1"),␊ |
| 193 | + 2 | index2 = foo.indexOf("2");␊ |
| 194 | + 3 | index1 < 0;␊ |
| 195 | + 4 | index2 >= 0;␊ |
| 196 | + ` |
| 197 | + |
| 198 | +> Output |
| 199 | +
|
| 200 | + `␊ |
| 201 | + 1 | const index1 = foo.indexOf("1"),␊ |
| 202 | + 2 | index2 = foo.indexOf("2");␊ |
| 203 | + 3 | index1 === -1;␊ |
| 204 | + 4 | index2 !== -1;␊ |
| 205 | + ` |
| 206 | + |
| 207 | +> Error 1/2 |
| 208 | +
|
| 209 | + `␊ |
| 210 | + 1 | const index1 = foo.indexOf("1"),␊ |
| 211 | + 2 | index2 = foo.indexOf("2");␊ |
| 212 | + > 3 | index1 < 0;␊ |
| 213 | + | ^^^ Prefer \`=== -1\` over \`< 0\` to check non-existence.␊ |
| 214 | + 4 | index2 >= 0;␊ |
| 215 | + ` |
| 216 | + |
| 217 | +> Error 2/2 |
| 218 | +
|
| 219 | + `␊ |
| 220 | + 1 | const index1 = foo.indexOf("1"),␊ |
| 221 | + 2 | index2 = foo.indexOf("2");␊ |
| 222 | + 3 | index1 < 0;␊ |
| 223 | + > 4 | index2 >= 0;␊ |
| 224 | + | ^^^^ Prefer \`!== -1\` over \`>= 0\` to check existence.␊ |
| 225 | + ` |
| 226 | + |
| 227 | +## invalid(10): const index = foo.indexOf('1'); (( /* comment 1 */ (( /* comment 2 */ index /* comment 3 */ )) /* comment 4 */ < /* comment 5 */ (( /* comment 6 */ 0 /* comment 7 */ )) /* comment 8 */ )); |
| 228 | + |
| 229 | +> Input |
| 230 | +
|
| 231 | + `␊ |
| 232 | + 1 | const index = foo.indexOf('1');␊ |
| 233 | + 2 | ((␊ |
| 234 | + 3 | /* comment 1 */␊ |
| 235 | + 4 | ((␊ |
| 236 | + 5 | /* comment 2 */␊ |
| 237 | + 6 | index␊ |
| 238 | + 7 | /* comment 3 */␊ |
| 239 | + 8 | ))␊ |
| 240 | + 9 | /* comment 4 */␊ |
| 241 | + 10 | <␊ |
| 242 | + 11 | /* comment 5 */␊ |
| 243 | + 12 | ((␊ |
| 244 | + 13 | /* comment 6 */␊ |
| 245 | + 14 | 0␊ |
| 246 | + 15 | /* comment 7 */␊ |
| 247 | + 16 | ))␊ |
| 248 | + 17 | /* comment 8 */␊ |
| 249 | + 18 | ));␊ |
| 250 | + ` |
| 251 | + |
| 252 | +> Output |
| 253 | +
|
| 254 | + `␊ |
| 255 | + 1 | const index = foo.indexOf('1');␊ |
| 256 | + 2 | ((␊ |
| 257 | + 3 | /* comment 1 */␊ |
| 258 | + 4 | ((␊ |
| 259 | + 5 | /* comment 2 */␊ |
| 260 | + 6 | index␊ |
| 261 | + 7 | /* comment 3 */␊ |
| 262 | + 8 | ))␊ |
| 263 | + 9 | /* comment 4 */␊ |
| 264 | + 10 | ===␊ |
| 265 | + 11 | /* comment 5 */␊ |
| 266 | + 12 | ((␊ |
| 267 | + 13 | /* comment 6 */␊ |
| 268 | + 14 | -1␊ |
| 269 | + 15 | /* comment 7 */␊ |
| 270 | + 16 | ))␊ |
| 271 | + 17 | /* comment 8 */␊ |
| 272 | + 18 | ));␊ |
| 273 | + ` |
| 274 | + |
| 275 | +> Error 1/1 |
| 276 | +
|
| 277 | + `␊ |
| 278 | + 1 | const index = foo.indexOf('1');␊ |
| 279 | + 2 | ((␊ |
| 280 | + 3 | /* comment 1 */␊ |
| 281 | + 4 | ((␊ |
| 282 | + 5 | /* comment 2 */␊ |
| 283 | + 6 | index␊ |
| 284 | + 7 | /* comment 3 */␊ |
| 285 | + 8 | ))␊ |
| 286 | + 9 | /* comment 4 */␊ |
| 287 | + > 10 | <␊ |
| 288 | + | ^␊ |
| 289 | + > 11 | /* comment 5 */␊ |
| 290 | + | ^^^^^^^^^^^^^^^^␊ |
| 291 | + > 12 | ((␊ |
| 292 | + | ^^^^^^^^^^^^^^^^␊ |
| 293 | + > 13 | /* comment 6 */␊ |
| 294 | + | ^^^^^^^^^^^^^^^^␊ |
| 295 | + > 14 | 0␊ |
| 296 | + | ^^^^ Prefer \`=== -1\` over \`< 0\` to check non-existence.␊ |
| 297 | + 15 | /* comment 7 */␊ |
| 298 | + 16 | ))␊ |
| 299 | + 17 | /* comment 8 */␊ |
| 300 | + 18 | ));␊ |
| 301 | + ` |
| 302 | + |
| 303 | +## invalid(11): const index = foo.indexOf('1'); (( /* comment 1 */ (( /* comment 2 */ index /* comment 3 */ )) /* comment 4 */ > (( /* comment 5 */ - /* comment 6 */ (( /* comment 7 */ 1 /* comment 8 */ )) /* comment 9 */ )) )); |
| 304 | + |
| 305 | +> Input |
| 306 | +
|
| 307 | + `␊ |
| 308 | + 1 | const index = foo.indexOf('1');␊ |
| 309 | + 2 | ((␊ |
| 310 | + 3 | /* comment 1 */␊ |
| 311 | + 4 | ((␊ |
| 312 | + 5 | /* comment 2 */␊ |
| 313 | + 6 | index␊ |
| 314 | + 7 | /* comment 3 */␊ |
| 315 | + 8 | ))␊ |
| 316 | + 9 | /* comment 4 */␊ |
| 317 | + 10 | >␊ |
| 318 | + 11 | ((␊ |
| 319 | + 12 | /* comment 5 */␊ |
| 320 | + 13 | - /* comment 6 */ (( /* comment 7 */ 1 /* comment 8 */ ))␊ |
| 321 | + 14 | /* comment 9 */␊ |
| 322 | + 15 | ))␊ |
| 323 | + 16 | ));␊ |
| 324 | + ` |
| 325 | + |
| 326 | +> Output |
| 327 | +
|
| 328 | + `␊ |
| 329 | + 1 | const index = foo.indexOf('1');␊ |
| 330 | + 2 | ((␊ |
| 331 | + 3 | /* comment 1 */␊ |
| 332 | + 4 | ((␊ |
| 333 | + 5 | /* comment 2 */␊ |
| 334 | + 6 | index␊ |
| 335 | + 7 | /* comment 3 */␊ |
| 336 | + 8 | ))␊ |
| 337 | + 9 | /* comment 4 */␊ |
| 338 | + 10 | !==␊ |
| 339 | + 11 | ((␊ |
| 340 | + 12 | /* comment 5 */␊ |
| 341 | + 13 | - /* comment 6 */ (( /* comment 7 */ 1 /* comment 8 */ ))␊ |
| 342 | + 14 | /* comment 9 */␊ |
| 343 | + 15 | ))␊ |
| 344 | + 16 | ));␊ |
| 345 | + ` |
| 346 | + |
| 347 | +> Error 1/1 |
| 348 | +
|
| 349 | + `␊ |
| 350 | + 1 | const index = foo.indexOf('1');␊ |
| 351 | + 2 | ((␊ |
| 352 | + 3 | /* comment 1 */␊ |
| 353 | + 4 | ((␊ |
| 354 | + 5 | /* comment 2 */␊ |
| 355 | + 6 | index␊ |
| 356 | + 7 | /* comment 3 */␊ |
| 357 | + 8 | ))␊ |
| 358 | + 9 | /* comment 4 */␊ |
| 359 | + > 10 | >␊ |
| 360 | + | ^␊ |
| 361 | + > 11 | ((␊ |
| 362 | + | ^^^␊ |
| 363 | + > 12 | /* comment 5 */␊ |
| 364 | + | ^^^␊ |
| 365 | + > 13 | - /* comment 6 */ (( /* comment 7 */ 1 /* comment 8 */ ))␊ |
| 366 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer \`!== -1\` over \`> -1\` to check existence.␊ |
| 367 | + 14 | /* comment 9 */␊ |
| 368 | + 15 | ))␊ |
| 369 | + 16 | ));␊ |
| 370 | + ` |
| 371 | + |
| 372 | +## invalid(12): const index = _.indexOf([1, 2, 1, 2], 2); index < 0; |
| 373 | + |
| 374 | +> Input |
| 375 | +
|
| 376 | + `␊ |
| 377 | + 1 | const index = _.indexOf([1, 2, 1, 2], 2); index < 0;␊ |
| 378 | + ` |
| 379 | + |
| 380 | +> Output |
| 381 | +
|
| 382 | + `␊ |
| 383 | + 1 | const index = _.indexOf([1, 2, 1, 2], 2); index === -1;␊ |
| 384 | + ` |
| 385 | + |
| 386 | +> Error 1/1 |
| 387 | +
|
| 388 | + `␊ |
| 389 | + > 1 | const index = _.indexOf([1, 2, 1, 2], 2); index < 0;␊ |
| 390 | + | ^^^ Prefer \`=== -1\` over \`< 0\` to check non-existence.␊ |
| 391 | + ` |
0 commit comments