1.2.0 • Published 5 years ago

eslint-plugin-no-arrow-this v1.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

eslint-plugin-no-arrow-this

Proposal

This is a eslint plugin for warning "this" keyword inside of arrow functions. The key is about to get rid of using this in sort of global context.

For example, you have a code with regular function:

(function () {
  var me = this;
  console.log(me);
}.bind(123))();

And then, somehow, may be after re-factoring, you will change that regular function to arrow function:

(() => {
  var me = this;
  console.log(me);
}).bind(123)();

So, starting from that pont me no longer follows to the binded context, and receives global or window instead.

This plugin will help you to find this conditions.

Example .eslintrc configuration

installation

$ npm i eslint-plugin-no-arrow-this

typical config for everything

"plugins": [
  // ... other plugins
  "eslint-plugin-no-arrow-this"
],
// ... other stuff
"rules": {
  // ... other rules
  "no-arrow-this/no-arrow-this": "warn"
}

So far here you will receive warning on eslint.

How to check ONLY global~window context mess

  "no-arrow-this/no-arrow-this": ["warn", {
    onlyGlobals : true
  }]

to play with this rule

on astexplorer.net

1.2.0

5 years ago

1.1.9

6 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago