Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-const-enum

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-const-enum - npm Package Compare versions

Comparing version 0.0.5 to 1.0.0

13

lib/const-object.js

@@ -18,3 +18,2 @@ "use strict";

path.replaceWith(_core.types.variableDeclaration('const', [_core.types.variableDeclarator(_core.types.identifier(path.node.id.name), _core.types.objectExpression(TSEnumMembersToObjectProperties(path.get('members'))))]));
path.skip();
}

@@ -31,3 +30,2 @@ }

return memberPaths.map(tsEnumMemberPath => {
const tsEnumMember = tsEnumMemberPath.node;
const keyNode = computeKeyNodeFromIdPath(tsEnumMemberPath.get('id'));

@@ -101,7 +99,7 @@ const key = getKeyFromKeyNode(keyNode);

} else {
throw initializerPath.buildCodeFrameError('Enum initializer must be a string literal or numeric expression.');
throw initializerPath.buildCodeFrameError('const enum member initializers can only contain literal values and other computed enum values.');
}
} else {
if (currentValue === null) {
throw tsEnumMemberPath.buildCodeFrameError('Enum member must have initializer..');
throw tsEnumMemberPath.buildCodeFrameError('Enum member must have initializer.');
}

@@ -136,6 +134,9 @@

const isNumericUnaryExpression = node => _core.types.isUnaryExpression(node) && new Set(['+', '-', '~']).has(node.operator);
const UNARY_OPERATORS = new Set(['+', '-', '~']);
const BINARY_OPERATORS = new Set(['+', '-', '/', '%', '*', '**', '&', '|', '>>', '>>>', '<<', '^']);
const isNumericBinaryExpression = node => _core.types.isBinaryExpression(node) && new Set(['+', '-', '/', '%', '*', '**', '&', '|', '>>', '>>>', '<<', '^']).has(node.operator);
const isNumericUnaryExpression = node => _core.types.isUnaryExpression(node) && UNARY_OPERATORS.has(node.operator);
const isNumericBinaryExpression = node => _core.types.isBinaryExpression(node) && BINARY_OPERATORS.has(node.operator);
const validateConstEnumMemberAccess = (path, value) => {

@@ -142,0 +143,0 @@ if (value === undefined) {

{
"name": "babel-plugin-const-enum",
"version": "0.0.5",
"version": "1.0.0",
"description": "Transform TypeScript `const` enums",

@@ -37,5 +37,5 @@ "repository": "https://github.com/dosentmatter/babel-plugin-const-enum",

"@babel/preset-env": "^7.5.0",
"babel-jest": "^24.8.0",
"jest": "^24.8.0",
"prettier": "^1.18.2"
"babel-jest": "^25.2.6",
"jest": "^25.2.7",
"prettier": "^2.0.4"
},

@@ -42,0 +42,0 @@ "files": [

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc