Socket
Socket
Sign inDemoInstall

code-red

Package Overview
Dependencies
6
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.29 to 0.0.30

4

CHANGELOG.md
# code-red changelog
## 0.0.30
* Wrap `await` argument in parens if necessary ([#24](https://github.com/Rich-Harris/code-red/issues/24))
## 0.0.29

@@ -4,0 +8,0 @@

31

dist/code-red.js

@@ -68,5 +68,2 @@ (function (global, factory) {

// Enables parenthesis regardless of precedence
const NEEDS_PARENTHESES = 17;
const EXPRESSIONS_PRECEDENCE = {

@@ -84,6 +81,7 @@ ArrayExpression: 20,

NewExpression: 19,
ArrowFunctionExpression: NEEDS_PARENTHESES,
ClassExpression: NEEDS_PARENTHESES,
FunctionExpression: NEEDS_PARENTHESES,
ObjectExpression: NEEDS_PARENTHESES, // TODO this results in e.g. `o = o || {}` => `o = o || ({})`
AwaitExpression: 17,
ArrowFunctionExpression: 17,
ClassExpression: 17,
FunctionExpression: 17,
ObjectExpression: 17,
UpdateExpression: 16,

@@ -95,3 +93,2 @@ UnaryExpression: 15,

AssignmentExpression: 3,
AwaitExpression: 2,
YieldExpression: 2,

@@ -103,7 +100,2 @@ RestElement: 1

const precedence = EXPRESSIONS_PRECEDENCE[node.type];
if (precedence === NEEDS_PARENTHESES) {
return true;
}
const parent_precedence = EXPRESSIONS_PRECEDENCE[parent.type];

@@ -294,6 +286,5 @@

if (
precedence === NEEDS_PARENTHESES ||
(precedence === 3 && (node.expression ).left.type === 'ObjectPattern')
precedence === 3 && (node.expression ).left.type === 'ObjectPattern'
) {
// Should always have parentheses or is an AssignmentExpression to an ObjectPattern
// is an AssignmentExpression to an ObjectPattern
return [

@@ -821,3 +812,9 @@ c('('),

if (node.argument) {
return [c('await '), ...handle(node.argument, state)];
const precedence = EXPRESSIONS_PRECEDENCE[node.argument.type];
if (precedence && (precedence < EXPRESSIONS_PRECEDENCE.AwaitExpression)) {
return [c('await ('), ...handle(node.argument, state), c(')')];
} else {
return [c('await '), ...handle(node.argument, state)];
}
}

@@ -824,0 +821,0 @@

{
"name": "code-red",
"description": "code-red",
"version": "0.0.29",
"version": "0.0.30",
"repository": "Rich-Harris/code-red",

@@ -6,0 +6,0 @@ "main": "dist/code-red.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc