[tslint]Expected a 'for-of' loop instead of a 'for' loop with this simple iteration (prefer-for-of) [tslint]Expected a 'for-of' loop instead of a 'for' loop with this simple iteration (prefer-for-of) javascript javascript

[tslint]Expected a 'for-of' loop instead of a 'for' loop with this simple iteration (prefer-for-of)


It is asking you to use format like the following. The of keyword loops over the objects in the array instead of looping over the indexes of the array. I'm assuming it is triggering because you are only using the index as a way of getting to the value in the array (which can be cleaned up using the of syntax).

for (let row of this.rows) {    if (!row.selected) {        this.selectAllChecked = false;        break;    }}

As a note, you can accomplish the same thing using the following one-liner:

this.selectAllChecked = this.rows.every(row => row.selected);


In tslint.json we can add inside the rules,

"rules": {"prefer-for-of": false}this will get resolve the issue