Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dharfr/eslint-plugin-no-for-of-loops
An eslint plugin to prevent for..of loops usage in your code base.
https://github.com/dharfr/eslint-plugin-no-for-of-loops
eslint eslint-plugin loops
Last synced: 24 days ago
JSON representation
An eslint plugin to prevent for..of loops usage in your code base.
- Host: GitHub
- URL: https://github.com/dharfr/eslint-plugin-no-for-of-loops
- Owner: dharFr
- License: mit
- Created: 2017-05-04T12:19:13.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-02-28T02:03:07.000Z (over 4 years ago)
- Last Synced: 2024-10-14T20:22:28.340Z (24 days ago)
- Topics: eslint, eslint-plugin, loops
- Language: JavaScript
- Homepage:
- Size: 20.5 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eslint-plugin-no-for-of-loops
An [eslint](http://eslint.org/) plugin to prevent `for (...of)` loops usage in your code base.
[![Build Status](https://travis-ci.org/dharFr/eslint-plugin-no-for-of-loops.svg?branch=master)](https://travis-ci.org/dharFr/eslint-plugin-no-for-of-loops)
[![npm](https://img.shields.io/npm/v/eslint-plugin-no-for-of-loops.svg)](https://www.npmjs.com/package/eslint-plugin-no-for-of-loops)
[![Greenkeeper badge](https://badges.greenkeeper.io/dharFr/eslint-plugin-no-for-of-loops.svg)](https://greenkeeper.io/)## Installation
``` sh
npm install --save-dev eslint-plugin-no-for-of-loops
```## Usage
In your `.eslintrc`:``` javascript
{
"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](https://github.com/babel/babel/issues/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](http://kangax.github.io/compat-table/es6/#test-for..of_loops) and [Symbol](http://kangax.github.io/compat-table/es6/#test-Symbol) compatibily tables for more details.
## Disabling the rule
Want to disable the rule anyway? Your call :```javascript
// 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](https://github.com/buildo/eslint-plugin-no-loops). Kudos!