From 798efa020f416370f499b5a5014667485f1c2aca Mon Sep 17 00:00:00 2001 From: Mathias Schreck Date: Fri, 26 Oct 2018 20:39:22 +0200 Subject: [PATCH] Fix invalid syntax in test case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit new.target is only allowed in functions I’ve also removed the unnecessary if statement in the rule as we can’t test the else branch because it is unreachable. --- lib/rules/prefer-arrow-callback.js | 17 ++--------------- test/rules/prefer-arrow-callback.js | 1 - 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/lib/rules/prefer-arrow-callback.js b/lib/rules/prefer-arrow-callback.js index 08c6a99..4e4d129 100644 --- a/lib/rules/prefer-arrow-callback.js +++ b/lib/rules/prefer-arrow-callback.js @@ -27,17 +27,6 @@ function isFunctionName(variable) { return variable && variable.defs[0].type === 'FunctionName'; } -/** - * Checks whether or not a given MetaProperty node equals to a given value. - * @param {ASTNode} node - A MetaProperty node to check. - * @param {string} metaName - The name of `MetaProperty.meta`. - * @param {string} propertyName - The name of `MetaProperty.property`. - * @returns {boolean} `true` if the node is the specific value. - */ -function checkMetaProperty(node, metaName, propertyName) { - return node.meta.name === metaName && node.property.name === propertyName; -} - /** * Gets the variable object of `arguments` which is defined implicitly. * @param {eslint-scope.Scope} scope - A scope to get. @@ -245,12 +234,10 @@ module.exports = { } }, - MetaProperty(node) { + MetaProperty() { const info = stack[stack.length - 1]; - if (info && checkMetaProperty(node, 'new', 'target')) { - info.meta = true; - } + info.meta = true; }, // To skip nested scopes. diff --git a/test/rules/prefer-arrow-callback.js b/test/rules/prefer-arrow-callback.js index 7aea6da..bdd5351 100644 --- a/test/rules/prefer-arrow-callback.js +++ b/test/rules/prefer-arrow-callback.js @@ -45,7 +45,6 @@ ruleTester.run('prefer-arrow-callback', rules['prefer-arrow-callback'], { '() => super()', 'foo(function bar() { new.target; });', 'foo(function bar() { new.target; }.bind(this));', - '() => new.target', 'foo(function bar() { this; }.bind(this, somethingElse));', // mocha-specific valid test cases 'before(function bar() {});',