Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove invalid test-cases and unreachable code from prefer-arrow-callback #186

Merged
merged 1 commit into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions lib/rules/prefer-arrow-callback.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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