Socket
Socket
Sign inDemoInstall

babel-plugin-knifecycle

Package Overview
Dependencies
4
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.3 to 1.1.0

9

CHANGELOG.md

@@ -0,1 +1,10 @@

# [1.1.0](https://github.com/nfroidure/babel-plugin-knifecycle/compare/v1.0.3...v1.1.0) (2020-01-01)
### Features
* **core:** add support for variable declaration usage ([c88a48b](https://github.com/nfroidure/babel-plugin-knifecycle/commit/c88a48b4bebcd606b51aa6e59e1584eb40d7367d))
## [1.0.3](https://github.com/nfroidure/babel-plugin-knifecycle/compare/v1.0.2...v1.0.3) (2019-02-02)

@@ -2,0 +11,0 @@

19

dist/index.js

@@ -118,7 +118,22 @@ "use strict";

if (!(binding && binding.path.isFunctionDeclaration())) {
if (!(binding && (binding.path.isFunctionDeclaration() || binding.path.isVariableDeclarator()))) {
throw autoHandlerArgumentPath.buildCodeFrameError('Expect the function passed in autoHandler to be defined in the local file.');
}
functionDefinitionPath = binding.path;
if (binding.path.isFunctionDeclaration()) {
functionDefinitionPath = binding.path;
} else {
functionDefinitionPath = binding.path.get('init');
if (!functionDefinitionPath.isFunctionExpression()) {
throw autoHandlerArgumentPath.buildCodeFrameError('Expect the function passed in autoHandler to be defined in the local file.');
}
if (!functionDefinitionPath.get('id').node) {
functionDefinitionPath.get('id').replaceWith({
type: 'Identifier',
name: 'getUser'
});
}
}
} else if (autoHandlerArgumentPath.isFunctionExpression()) {

@@ -125,0 +140,0 @@ functionDefinitionPath = autoHandlerArgumentPath;

@@ -224,2 +224,44 @@ "use strict";

});
it('should work with a function inside a var', () => {
var example = `
import noop from 'noop';
import { autoHandler } from 'knifecycle';
const getUser = async function getUser(
{ mysql: db, log = noop },
{ userId },
) {
return {};
};
export default autoHandler(getUser);
`;
const {
code
} = (0, _core.transform)(example, {
plugins: [_.default]
});
expect(code).toMatchSnapshot();
});
it('should work with an anonymous function inside a var', () => {
var example = `
import noop from 'noop';
import { autoHandler } from 'knifecycle';
const getUser = async function(
{ mysql: db, log = noop },
{ userId },
) {
return {};
};
export default autoHandler(getUser);
`;
const {
code
} = (0, _core.transform)(example, {
plugins: [_.default]
});
expect(code).toMatchSnapshot();
});
it('should fail with anonymous function expressions', () => {

@@ -226,0 +268,0 @@ var example = `

37

package.json
{
"name": "babel-plugin-knifecycle",
"version": "1.0.3",
"version": "1.1.0",
"description": "A Babel plugin to transform Knifecycle auto* functions to their raw equivalent.",

@@ -55,19 +55,18 @@ "keywords": [

"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-object-rest-spread": "^7.2.0",
"@babel/preset-env": "^7.2.3",
"@babel/register": "^7.0.0",
"babel-core": "^7.0.0-0",
"babel-eslint": "^10.0.1",
"commitizen": "^3.0.5",
"conventional-changelog-cli": "^2.0.11",
"coveralls": "^3.0.2",
"cz-conventional-changelog": "^2.1.0",
"eslint": "^5.12.1",
"eslint-plugin-prettier": "^3.0.1",
"jest": "^23.6.0",
"metapak": "^2.0.0",
"metapak-nfroidure": "9.3.1",
"prettier": "^1.16.0"
"@babel/cli": "^7.7.4",
"@babel/core": "^7.7.4",
"@babel/plugin-proposal-object-rest-spread": "^7.7.4",
"@babel/preset-env": "^7.7.4",
"@babel/register": "^7.7.4",
"babel-eslint": "^10.0.3",
"commitizen": "^4.0.3",
"conventional-changelog-cli": "^2.0.28",
"coveralls": "^3.0.9",
"cz-conventional-changelog": "^3.0.2",
"eslint": "^6.7.1",
"eslint-plugin-prettier": "^3.1.1",
"jest": "^24.9.0",
"metapak": "^3.1.6",
"metapak-nfroidure": "9.7.4",
"prettier": "^1.19.1"
},

@@ -171,4 +170,4 @@ "repository": {

"dependencies": {
"knifecycle": "^5.1.3"
"knifecycle": "^8.0.1"
}
}
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