N00b's Programming Machine

    eslint-plugin-no-for-of-loops

    1.0.1 • Public • Published

    eslint-plugin-no-for-of-loops

    An eslint plugin to prevent for (...of) loops usage in your code base.

    Build Status npm Greenkeeper badge

    Installation

    npm install --save-dev eslint-plugin-no-for-of-loops

    Usage

    In your .eslintrc:

    {
      "plugins": [
        "no-for-of-loops"
      ],
      "rules": {
        "no-for-of-loops/no-for-of-loops": 2
      }
    }

    Rule

    Disallow use of for (..of) loops.

    Why

    Using for (...of) loops requires Symbol and iterator polyfills to work on older browsers (see babel/babel#1534). Depending on your browsers target (for example, Android 4.4 in-app Webview is capped to Chrome 33), you might not want to include those polyfills to save a few kilobytes.

    See for..of and Symbol compatibily tables for more details.

    Disabling the rule

    Want to disable the rule anyway? Your call :

    // eslint-disable-next-line no-for-of-loops/no-for-of-loops
    for (let i of iterable) {
      // ...
    }

    Credits

    This project was initialy forked form eslint-plugin-no-loops. Kudos!

    Install

    npm i eslint-plugin-no-for-of-loops

    DownloadsWeekly Downloads

    5,571

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    5.03 kB

    Total Files

    7

    Last publish

    Collaborators

    • dhar