From 7b136136c4e39fd33d38f53fd8a7b3f93ee4182c Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 19 Nov 2022 15:50:12 +0530 Subject: [PATCH 1/2] docs: update correct code examples for `no-extra-parens` rule --- docs/src/rules/no-extra-parens.md | 4 ++-- tests/lib/rules/no-extra-parens.js | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/src/rules/no-extra-parens.md b/docs/src/rules/no-extra-parens.md index a71f941a940..8e5bb714cbd 100644 --- a/docs/src/rules/no-extra-parens.md +++ b/docs/src/rules/no-extra-parens.md @@ -60,6 +60,8 @@ for (a of (b)); typeof (a); +(Object.prototype.toString.call()); + (function(){} ? a() : b()); class A { @@ -82,8 +84,6 @@ Examples of **correct** code for this rule with the default `"all"` option: (0).toString(); -(Object.prototype.toString.call()); - ({}.toString.call()); (function(){}) ? a() : b(); diff --git a/tests/lib/rules/no-extra-parens.js b/tests/lib/rules/no-extra-parens.js index 557b641cf50..c8ae715a680 100644 --- a/tests/lib/rules/no-extra-parens.js +++ b/tests/lib/rules/no-extra-parens.js @@ -3213,6 +3213,13 @@ ruleTester.run("no-extra-parens", rule, { options: ["all", { enforceForFunctionPrototypeMethods: true }], parserOptions: { ecmaVersion: 2020 }, errors: [{ messageId: "unexpected" }] + }, + { + code: "(Object.prototype.toString.call())", + output: "Object.prototype.toString.call()", + options: ["all"], + parserOptions: { ecmaVersion: 2020 }, + errors: [{ messageId: "unexpected" }] } ] }); From a5c0d6975be2c667cf4abb5592c6628e8c201360 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 19 Nov 2022 15:59:33 +0530 Subject: [PATCH 2/2] chore: add another test case --- tests/lib/rules/no-extra-parens.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/lib/rules/no-extra-parens.js b/tests/lib/rules/no-extra-parens.js index c8ae715a680..96ae9f5bddf 100644 --- a/tests/lib/rules/no-extra-parens.js +++ b/tests/lib/rules/no-extra-parens.js @@ -735,6 +735,11 @@ ruleTester.run("no-extra-parens", rule, { code: "var foo = (function(){}?.call())", options: ["all", { enforceForFunctionPrototypeMethods: false }], parserOptions: { ecmaVersion: 2020 } + }, + { + code: "(Object.prototype.toString.call())", + options: ["functions"], + parserOptions: { ecmaVersion: 2020 } } ],