@putout/operator-parens 
🐊Putout operator adds ability to lint parens.
Install
npm i putout @putout/operator-parens
API
addParens(path: Path): Path
Add parens around expression depending on used printer
:
- ✅ set
node.extra.parenthesized: true
when@putout/printer
used; - ✅ set add
ParenthesizedExpression
orTSParenthesizedType
whenbabel
used;
import {operator} from 'putout';
const {addParens} = operator;
addParens(path);
removeParens(path: Path): Path
Remove parens around expression depending on used printer
:
- ✅ set
node.extra.parenthesized: false
when@putout/printer
used; - ✅ remove
ParenthesizedExpression
orTSParenthesizedType
whenbabel
used;
import {operator} from 'putout';
const {removeParens} = operator;
removeParens(path);
hasParens(path: Path): Boolean
Check if path
has parens around expression depending on used printer
:
- ✅ checks
node.extra.parenthesized
when@putout/printer
used; - ✅ check if parent node type is
ParenthesizedExpression
orTSParenthesizedType
whenbabel
used;
import {operator} from 'putout';
const {hasParens} = operator;
hasParens(path);
License
MIT