@putout/printer
Advanced tools
@@ -14,2 +14,3 @@ import {types} from '@putout/babel'; | ||
| isLabeledStatement, | ||
| isTryStatement, | ||
| } = types; | ||
@@ -29,2 +30,8 @@ | ||
| export const isNextTry = (path) => { | ||
| return isTryStatement(path.getNextSibling()); | ||
| }; | ||
| export const isPrevTry = (path) => isTryStatement(path.getPrevSibling()); | ||
| export const isPrev = (path) => { | ||
@@ -31,0 +38,0 @@ const next = path.getPrevSibling(); |
@@ -7,2 +7,3 @@ import {types} from '@putout/babel'; | ||
| isLast, | ||
| isPrevTry, | ||
| } from '#is'; | ||
@@ -19,2 +20,5 @@ import {hasPrevNewline} from '../../mark.js'; | ||
| beforeIf(path) { | ||
| if (isPrevTry(path)) | ||
| return true; | ||
| return !hasPrevNewline(path) && isBodyLength(path) || isPrevBody(path); | ||
@@ -21,0 +25,0 @@ }, |
@@ -1,5 +0,8 @@ | ||
| import {isNext} from '#is'; | ||
| import {types} from '@putout/babel'; | ||
| import {isNext, isNextTry} from '#is'; | ||
| const {isExpressionStatement} = types; | ||
| export const TryStatement = { | ||
| print(path, {print}) { | ||
| print(path, {print, maybe}) { | ||
| const finalizer = path.get('finalizer'); | ||
@@ -17,12 +20,18 @@ print.indent(); | ||
| print(finalizer); | ||
| print.newline(); | ||
| maybe.print.newline(!isNext(path)); | ||
| } | ||
| }, | ||
| afterSatisfy: () => [isNext], | ||
| after(path, {maybe, print}) { | ||
| maybe.print.newline(!path.node.finalizer); | ||
| print.breakline(); | ||
| after(path, {print}) { | ||
| print.newline(); | ||
| if (isNextExpression(path) || isNextTry(path)) | ||
| print.breakline(); | ||
| }, | ||
| }; | ||
| const isNextExpression = (path) => { | ||
| return isExpressionStatement(path.getNextSibling()); | ||
| }; | ||
| export const CatchClause = (path, {print, maybe}) => { | ||
@@ -29,0 +38,0 @@ const param = path.get('param'); |
+1
-1
| { | ||
| "name": "@putout/printer", | ||
| "version": "17.5.0", | ||
| "version": "17.6.0", | ||
| "type": "module", | ||
@@ -5,0 +5,0 @@ "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)", |
Sorry, the diff of this file is too big to display
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
295503
0.2%6200
0.23%