question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rule for function expressions to be arrow functions or not

See original GitHub issue

With ES6 arrow functions, it would be useful to have a rule that allows you to configure some consistency in function expressions. For example you could specify whether you want to use standard functions

someFunc(function() { doStuff(); });

Or use ES6 arrow functions.

someFunc(() => { doStuff(); });

And it would warn when it finds one in the wrong style. Of course since generators can’t be arrow functions this rule wouldn’t apply to them, they’d still look like

someFunc(function *() { yield doStuff(); });

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
IanVScommented, Aug 19, 2015

I am 👎 as arrow functions are not a blind replacement for all function expressions (lexical binding of this, super, and arguments). See some discussion in https://github.com/eslint/eslint/issues/3357 as well as commentary about when it may or may not be appropriate to use arrows in https://github.com/getify/You-Dont-Know-JS/blob/master/es6 & beyond/ch2.md#arrow-functions.

0reactions
gyandeepscommented, Aug 20, 2015

@rightaway I think we are going to close this issue for now. Feel free to create a plugin and use it. We can always check back in future if things change. Thanks. Resources: http://eslint.org/docs/developer-guide/working-with-plugins

Read more comments on GitHub >

github_iconTop Results From Across the Web

Arrow function expressions - JavaScript - MDN Web Docs
Although the arrow in an arrow function is not an operator, arrow functions have special parsing rules that interact differently with operator ...
Read more >
Understanding Arrow Functions in JavaScript | DigitalOcean
Like traditional function expressions, arrow functions are not hoisted, and so you cannot call them before you declare them.
Read more >
Arrow Function => Return Rules - Medium
Arrow functions with curly brackets are the only way to get multiple statements or expressions inside the function body. The return statement ...
Read more >
only-arrow-functions - Rule
Disallows traditional (non-arrow) function expressions. Note that non-arrow functions are allowed if 'this' appears somewhere in its body (as such functions ...
Read more >
Arrow function expressions - JavaScript
Although the arrow in an arrow function is not an operator, arrow functions have special parsing rules that interact differently with operator precedence ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found