@putout/printer
Advanced tools
| import {types} from '@putout/babel'; | ||
| import {createTypeChecker} from '#type-checker'; | ||
| const { | ||
| isForOfStatement, | ||
| isAssignmentPattern, | ||
| } = types; | ||
| const isCoupleOption = (a, {couple}) => couple; | ||
| export function isInsideForOf({parentPath}) { | ||
| return isForOfStatement(parentPath.parentPath.parentPath); | ||
| } | ||
| export function isPrevAssign(path) { | ||
| const prev = path.getPrevSibling(); | ||
| return isAssignmentPattern(prev.node.value); | ||
| } | ||
| export const isCommaAfterProperty = createTypeChecker([ | ||
| ['+', isCoupleOption], | ||
| ['-: key -> -'], | ||
| ['-', isPrevAssign], | ||
| ['-: parentPath', isInsideForOf], | ||
| ['+: node.value.right -> ObjectExpression'], | ||
| ]); | ||
@@ -42,2 +42,3 @@ import {types} from '@putout/babel'; | ||
| const callWithRoot = (fn) => (a, {root}) => fn(root); | ||
| const isExcludedFromChain = createTypeChecker([ | ||
@@ -97,2 +98,1 @@ '+: -> UnaryExpression', | ||
| }; | ||
@@ -8,3 +8,2 @@ import {types} from '@putout/babel'; | ||
| isAssignmentPattern, | ||
| isForOfStatement, | ||
| isFunction, | ||
@@ -42,12 +41,2 @@ isVariableDeclarator, | ||
| export function isInsideForOf({parentPath}) { | ||
| return isForOfStatement(parentPath.parentPath.parentPath); | ||
| } | ||
| export function isPrevAssign(path) { | ||
| const prev = path.getPrevSibling(); | ||
| return isAssignmentPattern(prev.node.value); | ||
| } | ||
| export function isPrevAssignObject(path) { | ||
@@ -54,0 +43,0 @@ const prev = path.getPrevSibling(); |
@@ -1,2 +0,1 @@ | ||
| import {types} from '@putout/babel'; | ||
| import {wrongShorthand} from './wrong-shorthand.js'; | ||
@@ -15,2 +14,3 @@ import {maybeTypeAnnotation} from '../../maybe/maybe-type-annotation.js'; | ||
| } from './has.js'; | ||
| import {isCommaAfterProperty} from './comma.js'; | ||
| import { | ||
@@ -20,10 +20,6 @@ isCoupleProperties, | ||
| isInsideFn, | ||
| isInsideForOf, | ||
| isNextAssignObject, | ||
| isPrevAssign, | ||
| isPrevAssignObject, | ||
| } from './is.js'; | ||
| const {isObjectExpression} = types; | ||
| export const ObjectPattern = { | ||
@@ -102,8 +98,3 @@ print: maybeTypeAnnotation((path, printer, semantics) => { | ||
| maybe.print(couple, ','); | ||
| maybe.print.newline(couple); | ||
| const {right} = valuePath.node; | ||
| if (i && !isPrevAssign(property) && !isInsideForOf(path) && isObjectExpression(right)) { | ||
| if (isCommaAfterProperty(property, {couple})) { | ||
| print(','); | ||
@@ -143,1 +134,2 @@ print.newline(); | ||
| }; | ||
+1
-1
| { | ||
| "name": "@putout/printer", | ||
| "version": "18.7.8", | ||
| "version": "18.7.9", | ||
| "type": "module", | ||
@@ -5,0 +5,0 @@ "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)", |
Sorry, the diff of this file is not supported yet
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
325731
0.07%203
0.5%6809
0.1%