Skip to content

Commit

Permalink
Revert "fix: function-paren-newline crash on "new new Foo();" (eslint…
Browse files Browse the repository at this point in the history
…#15850)"

This reverts commit b8b86c2.
  • Loading branch information
srijan-deepsource committed May 30, 2022
1 parent f8a0935 commit 6f00557
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
11 changes: 4 additions & 7 deletions lib/rules/function-paren-newline.js
Expand Up @@ -191,13 +191,10 @@ module.exports = {
function getParenTokens(node) {
switch (node.type) {
case "NewExpression":
if (!node.arguments.length &&
!(
astUtils.isOpeningParenToken(sourceCode.getLastToken(node, { skip: 1 })) &&
astUtils.isClosingParenToken(sourceCode.getLastToken(node)) &&
node.callee.range[1] < node.range[1]
)
) {
if (!node.arguments.length && !(
astUtils.isOpeningParenToken(sourceCode.getLastToken(node, { skip: 1 })) &&
astUtils.isClosingParenToken(sourceCode.getLastToken(node))
)) {

// If the NewExpression does not have parens (e.g. `new Foo`), return null.
return null;
Expand Down
13 changes: 0 additions & 13 deletions tests/lib/rules/function-paren-newline.js
Expand Up @@ -30,7 +30,6 @@ const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 6 } });
ruleTester.run("function-paren-newline", rule, {

valid: [
"new new Foo();",

// multiline option (default)
"function baz(foo, bar) {}",
Expand Down Expand Up @@ -1175,18 +1174,6 @@ ruleTester.run("function-paren-newline", rule, {
options: ["never"],
errors: [LEFT_UNEXPECTED_ERROR]
},
{
code: `
new new C()(
);
`,
output: `
new new C()();
`,
options: ["never"],
errors: [LEFT_UNEXPECTED_ERROR, RIGHT_UNEXPECTED_ERROR]
},

{
code: `
function baz(
Expand Down

0 comments on commit 6f00557

Please sign in to comment.