@putout/operator-parens

1.2.0 • Public • Published

@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

Package Sidebar

Install

npm i @putout/operator-parens

Weekly Downloads

2,651

Version

1.2.0

License

MIT

Unpacked Size

5.45 kB

Total Files

4

Last publish

Collaborators

  • coderaiser