ESLint rule plugin 4 warning "this" keyword inside of arrow functions
npm install eslint-plugin-no-arrow-thisThis 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:
``javascript`
(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:
`javascript
(() => {
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.
bash
$ npm i eslint-plugin-no-arrow-this
`$3
`javascript
"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.$3
`javascript
"no-arrow-this/no-arrow-this": ["warn", {
onlyGlobals : true
}]
``