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

jsx-ast-utils

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsx-ast-utils - npm Package Compare versions

Comparing version 1.3.1 to 1.3.2

__tests__/helper.js

5

CHANGELOG.md

@@ -0,1 +1,6 @@

1.3.2 / 2016-10-11
==================
- [fix] Add support for `UpdateExpression`.
1.3.1 / 2016-07-13

@@ -2,0 +7,0 @@ ==================

2

lib/elementType.js

@@ -11,3 +11,3 @@ 'use strict';

function elementType() {
var node = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var node = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var name = node.name;

@@ -14,0 +14,0 @@

@@ -24,7 +24,7 @@ 'use strict';

function getProp() {
var props = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
var prop = arguments.length <= 1 || arguments[1] === undefined ? '' : arguments[1];
var options = arguments.length <= 2 || arguments[2] === undefined ? DEFAULT_OPTIONS : arguments[2];
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var prop = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_OPTIONS;
var nodeProp = undefined;
var nodeProp = void 0;
var propToFind = options.ignoreCase ? prop.toUpperCase() : prop;

@@ -31,0 +31,0 @@

@@ -26,5 +26,5 @@ 'use strict';

function hasProp() {
var props = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
var prop = arguments.length <= 1 || arguments[1] === undefined ? '' : arguments[1];
var options = arguments.length <= 2 || arguments[2] === undefined ? DEFAULT_OPTIONS : arguments[2];
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var prop = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_OPTIONS;

@@ -50,5 +50,5 @@ var propToCheck = options.ignoreCase ? prop.toUpperCase() : prop;

function hasAnyProp() {
var nodeProps = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
var props = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1];
var options = arguments.length <= 2 || arguments[2] === undefined ? DEFAULT_OPTIONS : arguments[2];
var nodeProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_OPTIONS;

@@ -67,5 +67,5 @@ var propsToCheck = typeof props === 'string' ? props.split(' ') : props;

function hasEveryProp() {
var nodeProps = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
var props = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1];
var options = arguments.length <= 2 || arguments[2] === undefined ? DEFAULT_OPTIONS : arguments[2];
var nodeProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_OPTIONS;

@@ -72,0 +72,0 @@ var propsToCheck = typeof props === 'string' ? props.split(' ') : props;

@@ -11,3 +11,3 @@ 'use strict';

function propName() {
var prop = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var prop = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

@@ -14,0 +14,0 @@ if (!prop.type || prop.type !== 'JSXAttribute') {

@@ -48,7 +48,7 @@ 'use strict';

case '<<':
return leftVal << rightVal;
return leftVal << rightVal; // eslint-disable-line no-bitwise
case '>>':
return leftVal >> rightVal;
return leftVal >> rightVal; // eslint-disable-line no-bitwise
case '>>>':
return leftVal >>> rightVal;
return leftVal >>> rightVal; // eslint-disable-line no-bitwise
case '+':

@@ -65,7 +65,7 @@ return leftVal + rightVal;

case '|':
return leftVal | rightVal;
return leftVal | rightVal; // eslint-disable-line no-bitwise
case '^':
return leftVal ^ rightVal;
return leftVal ^ rightVal; // eslint-disable-line no-bitwise
case '&':
return leftVal & rightVal;
return leftVal & rightVal; // eslint-disable-line no-bitwise
case 'in':

@@ -72,0 +72,0 @@ try {

@@ -30,3 +30,3 @@ "use strict";

if (JS_RESERVED.hasOwnProperty(name)) {
if (Object.hasOwnProperty.call(JS_RESERVED, name)) {
return JS_RESERVED[name];

@@ -33,0 +33,0 @@ }

@@ -73,2 +73,6 @@ 'use strict';

var _UpdateExpression = require('./UpdateExpression');
var _UpdateExpression2 = _interopRequireDefault(_UpdateExpression);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -93,3 +97,4 @@

ObjectExpression: _ObjectExpression2.default,
NewExpression: _NewExpression2.default
NewExpression: _NewExpression2.default,
UpdateExpression: _UpdateExpression2.default
};

@@ -124,2 +129,6 @@

},
UpdateExpression: function UpdateExpression(value) {
var extractedVal = TYPES.UpdateExpression.call(undefined, value);
return extractedVal === undefined ? null : extractedVal;
},
ThisExpression: noop,

@@ -126,0 +135,0 @@ ConditionalExpression: noop,

@@ -8,2 +8,6 @@ 'use strict';

var _objectAssign = require('object-assign');
var _objectAssign2 = _interopRequireDefault(_objectAssign);
var _index = require('./index');

@@ -13,6 +17,2 @@

var _objectAssign = require('object-assign');
var _objectAssign2 = _interopRequireDefault(_objectAssign);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -19,0 +19,0 @@

@@ -35,3 +35,3 @@ 'use strict';

case '~':
return ~(0, _index2.default)(argument);
return ~(0, _index2.default)(argument); // eslint-disable-line no-bitwise
case 'delete':

@@ -38,0 +38,0 @@ // I believe delete statements evaluate to true.

{
"name": "jsx-ast-utils",
"version": "1.3.1",
"version": "1.3.2",
"description": "AST utility module for statically analyzing JSX",

@@ -9,23 +9,24 @@ "main": "lib/index.js",

"prepublish": "npm run lint && npm run test && npm run build",
"coveralls": "cat ./reports/coverage/lcov.info | coveralls",
"coveralls": "cat ./reports/lcov.info | coveralls",
"lint": "eslint --config .eslintrc .",
"lint:fix": "npm run lint -- --fix",
"pretest": "npm run lint",
"test": "istanbul cover -x '**/lib/**' --dir reports/coverage node_modules/mocha/bin/_mocha tests/**/*.js -- --compilers js:babel-core/register --reporter dot"
"test": "jest --coverage"
},
"devDependencies": {
"acorn-jsx": "^3.0.1",
"babel-cli": "^6.6.0",
"babel-core": "^6.6.0",
"babel-eslint": "^6.0.0",
"babel-preset-es2015": "^6.6.0",
"babel-cli": "^6.14.0",
"babel-core": "^6.14.0",
"babel-eslint": "^7.0.0",
"babel-jest": "^16.0.0",
"babel-polyfill": "^6.16.0",
"babel-preset-es2015": "^6.14.0",
"coveralls": "^2.11.8",
"eslint": "^2.11.1",
"eslint-config-airbnb-base": "^3.0.1",
"eslint-plugin-import": "^1.8.1",
"istanbul": "^1.0.0-alpha.2",
"mocha": "^2.4.5",
"eslint": "^3.0.0",
"eslint-config-airbnb-base": "^8.0.0",
"eslint-plugin-import": "^1.16.0",
"jest": "^16.0.1",
"rimraf": "^2.5.2"
},
"engines": {
"node": ">=0.10.0"
"node": ">=4.0"
},

@@ -45,4 +46,15 @@ "keywords": [

"dependencies": {
"acorn-jsx": "^3.0.1",
"object-assign": "^4.1.0"
},
"jest": {
"coverageReporters": [
"lcov"
],
"coverageDirectory": "reports",
"testPathIgnorePatterns": [
"/node_modules/",
"helper.js"
]
}
}

@@ -13,6 +13,6 @@ import propName from './propName';

export default function getProp(props = [], prop = '', options = DEFAULT_OPTIONS) {
let nodeProp = undefined;
let nodeProp;
const propToFind = options.ignoreCase ? prop.toUpperCase() : prop;
const hasProp = props.some(attribute => {
const hasProp = props.some((attribute) => {
// If the props contain a spread prop, then skip.

@@ -19,0 +19,0 @@ if (attribute.type === 'JSXSpreadAttribute') {

@@ -15,3 +15,3 @@ import propName from './propName';

return props.some(attribute => {
return props.some((attribute) => {
// If the props contain a spread prop, then refer to strict param.

@@ -18,0 +18,0 @@ if (attribute.type === 'JSXSpreadAttribute') {

@@ -35,7 +35,7 @@ import getValue from './index';

case '<<':
return leftVal << rightVal;
return leftVal << rightVal; // eslint-disable-line no-bitwise
case '>>':
return leftVal >> rightVal;
return leftVal >> rightVal; // eslint-disable-line no-bitwise
case '>>>':
return leftVal >>> rightVal;
return leftVal >>> rightVal; // eslint-disable-line no-bitwise
case '+':

@@ -52,7 +52,7 @@ return leftVal + rightVal;

case '|':
return leftVal | rightVal;
return leftVal | rightVal; // eslint-disable-line no-bitwise
case '^':
return leftVal ^ rightVal;
return leftVal ^ rightVal; // eslint-disable-line no-bitwise
case '&':
return leftVal & rightVal;
return leftVal & rightVal; // eslint-disable-line no-bitwise
case 'in':

@@ -59,0 +59,0 @@ try {

@@ -23,3 +23,3 @@ const JS_RESERVED = {

if (JS_RESERVED.hasOwnProperty(name)) {
if (Object.hasOwnProperty.call(JS_RESERVED, name)) {
return JS_RESERVED[name];

@@ -26,0 +26,0 @@ }

@@ -17,2 +17,3 @@ import assign from 'object-assign';

import NewExpression from './NewExpression';
import UpdateExpression from './UpdateExpression';

@@ -37,2 +38,3 @@ // Composition map of types to their extractor functions.

NewExpression,
UpdateExpression,
};

@@ -44,3 +46,3 @@

const LITERAL_TYPES = assign({}, TYPES, {
Literal: value => {
Literal: (value) => {
const extractedVal = TYPES.Literal.call(undefined, value);

@@ -52,3 +54,3 @@ const isNull = extractedVal === null;

},
Identifier: value => {
Identifier: (value) => {
const isUndefined = TYPES.Identifier.call(undefined, value) === undefined;

@@ -63,6 +65,10 @@ return isUndefined ? undefined : null;

CallExpression: noop,
UnaryExpression: value => {
UnaryExpression: (value) => {
const extractedVal = TYPES.UnaryExpression.call(undefined, value);
return extractedVal === undefined ? null : extractedVal;
},
UpdateExpression: (value) => {
const extractedVal = TYPES.UpdateExpression.call(undefined, value);
return extractedVal === undefined ? null : extractedVal;
},
ThisExpression: noop,

@@ -69,0 +75,0 @@ ConditionalExpression: noop,

@@ -0,3 +1,3 @@

import assign from 'object-assign';
import getValue from './index';
import assign from 'object-assign';

@@ -4,0 +4,0 @@ /**

@@ -22,3 +22,3 @@ import getValue from './index';

case '~':
return ~getValue(argument);
return ~getValue(argument); // eslint-disable-line no-bitwise
case 'delete':

@@ -25,0 +25,0 @@ // I believe delete statements evaluate to true.

Sorry, the diff of this file is not supported yet

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