babel-plugin-treat
Advanced tools
Comparing version 1.0.4 to 1.1.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [1.1.0](https://github.com/seek-oss/treat/tree/master/packages/babel-plugin-treat/compare/v1.0.4...v1.1.0) (2019-09-16) | ||
### Features | ||
* **babel-plugin:** Support anonymous calls in arrays/objects ([#57](https://github.com/seek-oss/treat/tree/master/packages/babel-plugin-treat/issues/57)) ([ec52adb](https://github.com/seek-oss/treat/tree/master/packages/babel-plugin-treat/commit/ec52adb)) | ||
## [1.0.4](https://github.com/seek-oss/treat/tree/master/packages/babel-plugin-treat/compare/v1.0.3...v1.0.4) (2019-08-06) | ||
@@ -8,0 +19,0 @@ |
43
index.js
@@ -18,2 +18,26 @@ const { dirname, basename } = require('path'); | ||
const getDebugIdent = (t, path, fileIdentifier) => { | ||
const { parent } = path; | ||
if ( | ||
t.isObjectProperty(parent) || | ||
t.isReturnStatement(parent) || | ||
t.isArrayExpression(parent) || | ||
t.isSpreadElement(parent) | ||
) { | ||
const names = []; | ||
path.findParent(({ node: parentNode }) => { | ||
const name = extractName(t, parentNode, fileIdentifier); | ||
if (name) { | ||
names.unshift(name); | ||
} | ||
}); | ||
return names.join('_'); | ||
} else { | ||
return extractName(t, parent, fileIdentifier); | ||
} | ||
}; | ||
module.exports = function({ types: t }) { | ||
@@ -51,22 +75,7 @@ return { | ||
) { | ||
const { parent, node } = path; | ||
const { node } = path; | ||
if (node.arguments.length === 1) { | ||
let debugIdent; | ||
const debugIdent = getDebugIdent(t, path, this.fileIdentifier); | ||
if (t.isObjectProperty(parent) || t.isReturnStatement(parent)) { | ||
const names = []; | ||
path.findParent(({ node: parentNode }) => { | ||
const name = extractName(t, parentNode); | ||
if (name) { | ||
names.unshift(name); | ||
} | ||
}); | ||
debugIdent = names.join('_'); | ||
} else { | ||
debugIdent = extractName(t, parent, this.fileIdentifier); | ||
} | ||
if (debugIdent) { | ||
@@ -73,0 +82,0 @@ node.arguments.push(t.stringLiteral(debugIdent)); |
{ | ||
"name": "babel-plugin-treat", | ||
"description": "Babel plugin for treat", | ||
"version": "1.0.4", | ||
"version": "1.1.0", | ||
"main": "index.js", | ||
@@ -12,3 +12,3 @@ "author": "SEEK", | ||
], | ||
"gitHead": "f2af678997d1b69750c73ec79ab277e87c74e5ad" | ||
"gitHead": "61f94e3c0253f20ee44256c011f7733e4337f51e" | ||
} |
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
5727
75