πPutout plugin adds missing and remove useless parens
npm install @putout/plugin-parens[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-parens.svg?style=flat&longCache=true
[NPMURL]: https://npmjs.org/package/@putout/plugin-parens "npm"
πPutout plugin adds ability to add missing parens. Check out in πPutout Editor.
```
npm i @putout/plugin-parens
- β
add-missing-for-await;
- β
add-missing-for-template;
- β
add-missing-for-assign;
- β
remove-useless-for-await;
- β
remove-useless-for-params;
Short:
`json`
{
"rules": {
"parens/add-missing": "on",
"parens/remove-useless": "on"
}
}
Full:
`json`
{
"rules": {
"parens/add-missing-for-await": "on",
"parens/add-missing-for-template": "on",
"parens/add-missing-for-assign": "on",
"parens/remove-useless-for-await": "on",
"parens/remove-useless-for-params": "on"
}
}
> The JavaScript exception "invalid assignment left-hand side" occurs when there was an unexpected assignment somewhere. It may be triggered when a single = sign was used instead of == or ===.
>
> (c) MDN
To disable use:
`json`
{
"rules": {
"parens/add-missing-for-assign": "off"
}
}
`diff`
-a && b = a;
+a && (b = a);
`ts`
await asyncFn().filter(Boolean);
`js`
(await asyncFn()).filter(Boolean);
> The JavaScript exception "tagged template cannot be used with optional chain" occurs when the tag expression of a tagged template literal is an optional chain, or if there's an optional chain between the tag and the template.
>
> (c) MDN
Checkout in πPutout Editor.
`json`
{
"rules": {
"parens/add-missing-for-template": "off"
}
}
`
getConsoleLog?.();
String?.raw;
String?.raw!;`
`ts
(getConsoleLog?.());
(String?.raw);
(String?.raw)!;`
Checkout in πPutout Editor.
`ts`
const s = (await m());
`ts`
const s = await m();
> Uncaught SyntaxError: Invalid destructuring assignment target
>
> (c) Chrome
Checkout in πPutout Editor.
`
const a = ((b)) => c;
`
`js``
const a = (b) => c;
MIT