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

babel-plugin-react-defaultprops

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-react-defaultprops - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

16

lib/utils/is-valid-value.js

@@ -6,2 +6,5 @@ "use strict";

exports.isValidValue = (node) => {
if (core_1.types.isLiteral(node)) {
return true;
}
if (core_1.types.isAssignmentPattern(node)) {

@@ -13,8 +16,2 @@ return exports.isValidValue(node.right);

}
if (core_1.types.isConditionalExpression(node) ||
core_1.types.isMemberExpression(node) ||
core_1.types.isCallExpression(node) ||
core_1.types.isIdentifier(node) ||
core_1.types.isJSXSpreadAttribute(node))
return false;
if (core_1.types.isJSXExpressionContainer(node)) {

@@ -33,2 +30,3 @@ return exports.isValidValue(node.expression);

}
return true;
}

@@ -42,2 +40,3 @@ if (core_1.types.isArrayExpression(node)) {

}
return true;
}

@@ -48,8 +47,9 @@ if (core_1.types.isObjectExpression(node)) {

if (!exports.isValidValue(prop)) {
return false;
return exports.isValidValue(prop);
}
}
return true;
}
return true;
return false;
};
//# sourceMappingURL=is-valid-value.js.map
{
"name": "babel-plugin-react-defaultprops",
"version": "1.0.6",
"version": "1.0.7",
"description": "A plugin to extract es6 default parameters",

@@ -5,0 +5,0 @@ "source": "src/plugin.ts",

@@ -21,3 +21,3 @@ # babel-plugin-react-defaultprops

module.exports = {
plugins: ['babel-plugin-react-defaultprops'],
plugins: ['babel-plugin-react-defaultprops'],
};

@@ -79,4 +79,2 @@ ```

> Node that the default props with the locale variable as a value in the function body will not be included.
## Utils

@@ -88,2 +86,4 @@

> Does not work in nested component, works only with top level components.
```js

@@ -115,4 +115,2 @@ import React from 'react';

> This function does not work in nested component inside function, works only with top level components.
## Typescript

@@ -119,0 +117,0 @@

@@ -91,2 +91,7 @@ import { isValidValue } from '../is-valid-value';

it('should not conditional value', () => {
expect(isValidValue(getNode('{baz: true?true:false }'))).toBeFalsy();
expect(isValidValue(getNode('{baz: tru||1 }'))).toBeFalsy();
});
describe('jsx', () => {

@@ -93,0 +98,0 @@ it('should allow jsx', () => {

import { types as t } from '@babel/core';
export const isValidValue = (node: t.Node) => {
if (t.isLiteral(node)) {
return true;
}
if (t.isAssignmentPattern(node)) {

@@ -12,11 +16,2 @@ return isValidValue(node.right);

if (
t.isConditionalExpression(node) ||
t.isMemberExpression(node) ||
t.isCallExpression(node) ||
t.isIdentifier(node) ||
t.isJSXSpreadAttribute(node)
)
return false;
if (t.isJSXExpressionContainer(node)) {

@@ -37,2 +32,3 @@ return isValidValue(node.expression);

}
return true;
}

@@ -47,2 +43,3 @@

}
return true;
}

@@ -54,7 +51,8 @@

if (!isValidValue(prop)) {
return false;
return isValidValue(prop);
}
}
return true;
}
return true;
return false;
};

Sorry, the diff of this file is not supported yet

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