Skip to content

Commit

Permalink
Merge pull request #186 from lo1tuma/fix-prefer-arrow-callback
Browse files Browse the repository at this point in the history
Remove invalid test-cases and unreachable code from prefer-arrow-callback
  • Loading branch information
lo1tuma committed Jan 8, 2019
2 parents 9950901 + b19ae5d commit d80a7fd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
16 changes: 3 additions & 13 deletions lib/rules/prefer-arrow-callback.js
Expand Up @@ -187,9 +187,8 @@ module.exports = {
const sourceCode = context.getSourceCode();

/*
* {Array<{this: boolean, super: boolean, meta: boolean}>}
* {Array<{this: boolean, meta: boolean}>}
* - this - A flag which shows there are one or more ThisExpression.
* - super - A flag which shows there are one or more Super.
* - meta - A flag which shows there are one or more MetaProperty.
*/
let stack = [];
Expand All @@ -199,12 +198,12 @@ module.exports = {
* @returns {void}
*/
function enterScope() {
stack.push({ this: false, super: false, meta: false });
stack.push({ this: false, meta: false });
}

/**
* Pops a function scope from the stack.
* @returns {{this: boolean, super: boolean, meta: boolean}} The information of the last scope.
* @returns {{this: boolean, meta: boolean}} The information of the last scope.
*/
function exitScope() {
return stack.pop();
Expand All @@ -226,14 +225,6 @@ module.exports = {
}
},

Super() {
const info = stack[stack.length - 1];

if (info) {
info.super = true;
}
},

MetaProperty() {
const info = stack[stack.length - 1];

Expand Down Expand Up @@ -278,7 +269,6 @@ module.exports = {

if (callbackInfo.isCallback &&
(!allowUnboundThis || !scopeInfo.this || callbackInfo.isLexicalThis) &&
!scopeInfo.super &&
!scopeInfo.meta &&
!callbackInfo.isMochaCallback
) {
Expand Down
3 changes: 0 additions & 3 deletions test/rules/prefer-arrow-callback.js
Expand Up @@ -40,9 +40,6 @@ ruleTester.run('prefer-arrow-callback', rules['prefer-arrow-callback'], {
'foo(function bar() { bar; });',
'foo(function bar() { arguments; });',
'foo(function bar() { arguments; }.bind(this));',
'foo(function bar() { super.a; });',
'foo(function bar() { super.a; }.bind(this));',
'() => super()',
'foo(function bar() { new.target; });',
'foo(function bar() { new.target; }.bind(this));',
'foo(function bar() { this; }.bind(this, somethingElse));',
Expand Down

0 comments on commit d80a7fd

Please sign in to comment.