From 1ae9f2067442434c6ccc6b41703624b302d17c67 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 20 Nov 2022 02:32:56 +0530 Subject: [PATCH] docs: update correct code examples for `no-extra-parens` rule (#16560) * docs: update correct code examples for `no-extra-parens` rule * chore: add another test case --- docs/src/rules/no-extra-parens.md | 4 ++-- tests/lib/rules/no-extra-parens.js | 12 ++++++++++++ 2 files changed, 14 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..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 } } ], @@ -3213,6 +3218,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" }] } ] });