2.0.0 β’ Published 5 months ago
@putout/operator-parens v2.0.0
@putout/operator-parens 
πPutout operator adds ability to lint parens.
Install
npm i putout @putout/operator-parensAPI
addParens(path: Path): Path
Add parens around expression depending on used printer:
- β
set
node.extra.parenthesized: truewhen@putout/printerused; - β
set add
ParenthesizedExpressionorTSParenthesizedTypewhenbabelused;
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: falsewhen@putout/printerused; - β
remove
ParenthesizedExpressionorTSParenthesizedTypewhenbabelused;
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.parenthesizedwhen@putout/printerused; - β
check if parent node type is
ParenthesizedExpressionorTSParenthesizedTypewhenbabelused;
import {operator} from 'putout';
const {hasParens} = operator;
hasParens(path);License
MIT