@putout/operator-parens
v4.0.0
Published
🐊Putout operator adds ability to work with parens
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
