2.0.0 β€’ Published 5 months ago

@putout/operator-parens v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@putout/operator-parens NPM version

🐊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 or TSParenthesizedType when babel 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 or TSParenthesizedType when babel 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 or TSParenthesizedType when babel used;
import {operator} from 'putout';

const {hasParens} = operator;

hasParens(path);

License

MIT

2.0.0

5 months ago

1.2.0

8 months ago

1.1.0

8 months ago

1.0.0

9 months ago