Skip to content

Commit

Permalink
docs: update correct code examples for no-extra-parens rule (#16560)
Browse files Browse the repository at this point in the history
* docs: update correct code examples for `no-extra-parens` rule

* chore: add another test case
  • Loading branch information
snitin315 committed Nov 19, 2022
1 parent b8769f1 commit 1ae9f20
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/src/rules/no-extra-parens.md
Expand Up @@ -60,6 +60,8 @@ for (a of (b));

typeof (a);

(Object.prototype.toString.call());

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

class A {
Expand All @@ -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();
Expand Down
12 changes: 12 additions & 0 deletions tests/lib/rules/no-extra-parens.js
Expand Up @@ -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 }
}
],

Expand Down Expand Up @@ -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" }]
}
]
});

0 comments on commit 1ae9f20

Please sign in to comment.