Skip to content

Commit

Permalink
docs: add new allowParensAfterCommentPattern option to the `no-extr…
Browse files Browse the repository at this point in the history
…a-parens` rule
  • Loading branch information
snitin315 committed Nov 20, 2022
1 parent 9cf3e20 commit 58dff4d
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion docs/src/rules/no-extra-parens.md
Expand Up @@ -38,7 +38,7 @@ This rule has an object option for exceptions to the `"all"` option:
* `"enforceForSequenceExpressions": false` allows extra parentheses around sequence expressions
* `"enforceForNewInMemberExpressions": false` allows extra parentheses around `new` expressions in member expressions
* `"enforceForFunctionPrototypeMethods": false` allows extra parentheses around immediate `.call` and `.apply` method calls on function expressions and around function expressions in the same context.
* `"allowParensAfterComment": true` allows extra parentheses preceded by a comment that matches a regular expression
* `"allowParensAfterCommentPattern": true` allows extra parentheses preceded by a comment that matches a regular expression.

### all

Expand Down Expand Up @@ -323,6 +323,32 @@ const quux = (function () {}.apply());

:::

### allowParensAfterCommentPattern

Examples of **correct** code for this rule with the `"all"` and `{ "allowParensAfterCommentPattern": "@type" }` options:

::: correct

```js
/* eslint no-extra-parens: ["error", "all", { "enforceForFunctionPrototypeMethods": false }] */

const span = /**@type {HTMLSpanElement}*/(event.currentTarget);

if (/** @type {Foo | Bar} */(options).baz) console.log('Lint free');

foo(/** @type {Bar} */ (bar), options, {
name: "name",
path: "path",
});

if (foo) {
/** @type {Bar} */
(bar).prop = false;
}
```

:::

### functions

Examples of **incorrect** code for this rule with the `"functions"` option:
Expand Down

0 comments on commit 58dff4d

Please sign in to comment.