babel-plugin-transform-isnil
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -0,1 +1,11 @@ | ||
v1.0.1 | ||
--- | ||
Install dependencies. | ||
v1.0.0 | ||
--- | ||
This greatly simplifies the logic of the plugin + adds eval tests to make sure the code actually runs! | ||
Special Thanks @shnhrrsn | ||
v0.0.7 | ||
@@ -18,3 +28,3 @@ --- | ||
``` | ||
**after** | ||
@@ -21,0 +31,0 @@ |
{ | ||
"name": "babel-plugin-transform-isnil", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "replace the comparing of null or undefined with isNil", | ||
@@ -33,3 +33,7 @@ "main": "src", | ||
"xo": "^0.18.2" | ||
}, | ||
"dependencies": { | ||
"babel-template": "^6.26.0", | ||
"babel-types": "^6.26.0" | ||
} | ||
} |
@@ -6,3 +6,5 @@ 'use strict' | ||
const isNilWrapper = template('(function (val) { return val === null || typeof val === \'undefined\' })') | ||
const isNilWrapper = template( | ||
'(function (val) { return val === null || typeof val === \'undefined\' })' | ||
) | ||
@@ -13,3 +15,3 @@ function addIsNilHelper() { | ||
let declar = this.declarations[name] | ||
const declar = this.declarations[name] | ||
if (declar) { | ||
@@ -24,7 +26,7 @@ return declar | ||
let generator = this.get('helperGenerator') | ||
let runtime = this.get('helpersNamespace') | ||
const generator = this.get('helperGenerator') | ||
const runtime = this.get('helpersNamespace') | ||
if (generator) { | ||
let res = generator(name) | ||
const res = generator(name) | ||
@@ -38,4 +40,7 @@ if (res) { | ||
let ref = isNilWrapper().expression | ||
let uid = this.declarations[name] = this.scope.generateUidIdentifier(name) | ||
const ref = isNilWrapper().expression | ||
/* eslint no-multi-assign: [0] */ | ||
const uid = (this.declarations[name] = this.scope.generateUidIdentifier( | ||
name | ||
)) | ||
@@ -59,3 +64,6 @@ ref._compact = true | ||
if (property.name !== 'isNil' || path.container.type === 'CallExpression') { | ||
if ( | ||
property.name !== 'isNil' || | ||
path.container.type === 'CallExpression' | ||
) { | ||
return | ||
@@ -65,6 +73,5 @@ } | ||
const isNilWrapper = addIsNilHelper.call(state.file).name | ||
path.replaceWith(t.callExpression( | ||
t.identifier(isNilWrapper), | ||
[node.object] | ||
)) | ||
path.replaceWith( | ||
t.callExpression(t.identifier(isNilWrapper), [node.object]) | ||
) | ||
} | ||
@@ -71,0 +78,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
61
0
129335
2
+ Addedbabel-template@^6.26.0
+ Addedbabel-types@^6.26.0
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedbabel-code-frame@6.26.0(transitive)
+ Addedbabel-messages@6.23.0(transitive)
+ Addedbabel-runtime@6.26.0(transitive)
+ Addedbabel-template@6.26.0(transitive)
+ Addedbabel-traverse@6.26.0(transitive)
+ Addedbabel-types@6.26.0(transitive)
+ Addedbabylon@6.18.0(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedcore-js@2.6.12(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedesutils@2.0.3(transitive)
+ Addedglobals@9.18.0(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedinvariant@2.2.4(transitive)
+ Addedjs-tokens@3.0.2(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedloose-envify@1.4.0(transitive)
+ Addedms@2.0.0(transitive)
+ Addedregenerator-runtime@0.11.1(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.0(transitive)
+ Addedto-fast-properties@1.0.3(transitive)