Skip to content

Commit

Permalink
feat: resurrect prefer-arrow-callback
Browse files Browse the repository at this point in the history
it's --fix'able, which helps when decaf'ing code
  • Loading branch information
dbushong committed Mar 20, 2018
1 parent 5a17c3f commit 7de330c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions examples/eslint/node4/prefer-arrow-callback.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

function a() {}

// uncomplicated callback: use arrow
const b = a().then(() => {
const c = 42;
return c;
});

// uses this? use function
const d = a().then(function() {
this.stuff();
});

// uses arguments? use function
const e = a().then(function() {
return arguments;
});

module.exports = [b, d, e];
3 changes: 3 additions & 0 deletions lib/rules/conventions.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,7 @@ module.exports = {

// See: https://eslint.org/docs/rules/prefer-template
'prefer-template': 'error',

// See: https://eslint.org/docs/rules/prefer-arrow-callback
'prefer-arrow-callback': 'error',
};

0 comments on commit 7de330c

Please sign in to comment.