@putout/plugin-convert-for-in-to-for-of

    2.0.0 • Public • Published

    @putout/plugin-convert-for-in-to-for-of NPM version Dependency Status

    putout plugin adds ability to convert for to for-of loop.

    Install

    npm i @putout/plugin-convert-for-in-to-for-of -D
    

    Rule

    Rule convert-for-in-to-for-of is enabled by default, to disable add to .putout.json:

    {
        "rules": {
            "convert-for-in-to-for-of/positive": "off",
            "convert-for-in-to-for-of/negative":"off"
        }
    }

    ❌ Incorrect code example

    for (const item in object) {
        if (object.hasOwnProperty(item)) {
            log(item);
        }
    }
     
    for (const item in object) {
        if (!object.hasOwnProperty(item))
            continue;
        
        log(item);
    }

    ✅ Correct code Example

    for (const item of Object.keys(object)) {
        log(item);
    }

    License

    MIT

    Install

    npm i @putout/plugin-convert-for-in-to-for-of

    DownloadsWeekly Downloads

    1,751

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    5.93 kB

    Total Files

    6

    Last publish

    Collaborators

    • avatar