@putout/operator-parens
v3.0.0
Published
šPutout operator adds ability to work with parens
Downloads
11,977
Maintainers
Readme
@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
