Skip to content

Commit 1ae9f20

Browse files
authored
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
1 parent b8769f1 commit 1ae9f20

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

docs/src/rules/no-extra-parens.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ for (a of (b));
6060

6161
typeof (a);
6262

63+
(Object.prototype.toString.call());
64+
6365
(function(){} ? a() : b());
6466

6567
class A {
@@ -82,8 +84,6 @@ Examples of **correct** code for this rule with the default `"all"` option:
8284

8385
(0).toString();
8486

85-
(Object.prototype.toString.call());
86-
8787
({}.toString.call());
8888

8989
(function(){}) ? a() : b();

tests/lib/rules/no-extra-parens.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,11 @@ ruleTester.run("no-extra-parens", rule, {
735735
code: "var foo = (function(){}?.call())",
736736
options: ["all", { enforceForFunctionPrototypeMethods: false }],
737737
parserOptions: { ecmaVersion: 2020 }
738+
},
739+
{
740+
code: "(Object.prototype.toString.call())",
741+
options: ["functions"],
742+
parserOptions: { ecmaVersion: 2020 }
738743
}
739744
],
740745

@@ -3213,6 +3218,13 @@ ruleTester.run("no-extra-parens", rule, {
32133218
options: ["all", { enforceForFunctionPrototypeMethods: true }],
32143219
parserOptions: { ecmaVersion: 2020 },
32153220
errors: [{ messageId: "unexpected" }]
3221+
},
3222+
{
3223+
code: "(Object.prototype.toString.call())",
3224+
output: "Object.prototype.toString.call()",
3225+
options: ["all"],
3226+
parserOptions: { ecmaVersion: 2020 },
3227+
errors: [{ messageId: "unexpected" }]
32163228
}
32173229
]
32183230
});

0 commit comments

Comments
 (0)