Socket
Socket
Sign inDemoInstall

eslint-plugin-react

Package Overview
Dependencies
Maintainers
1
Versions
212
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-react - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

6

History.md

@@ -0,1 +1,7 @@

2.0.1 / 2015-03-30
==================
* fix props detection when used in an object ([#41][])
[#41]: https://github.com/yannickcr/eslint-plugin-react/issues/41
2.0.0 / 2015-03-29

@@ -2,0 +8,0 @@ ==================

42

lib/util/component.js

@@ -40,2 +40,21 @@ /**

/**
* Detect if the node is a component definition
* @param {ASTNode} node The AST node being checked.
* @returns {Boolean} True the node is a component definition, false if not.
*/
function isComponentDefinition(node) {
var isES6Component = node.type === 'ClassDeclaration';
var isES5Component = Boolean(
node.type === 'ObjectExpression' &&
node.parent &&
node.parent.callee &&
node.parent.callee.object &&
node.parent.callee.property &&
node.parent.callee.object.name === 'React' &&
node.parent.callee.property.name === 'createClass'
);
return isES5Component || isES6Component;
}
/**
* Get the React component ASTNode from any child ASTNode

@@ -47,20 +66,14 @@ * @param {Object} context The current rule context.

function getNode(context, node) {
var componentNode;
var componentNode = null;
var ancestors = context.getAncestors().reverse();
if (node.type === 'ClassDeclaration' || node.type === 'ObjectExpression') {
componentNode = node;
} else {
var ancestors = context.getAncestors().reverse();
for (var i = 0, j = ancestors.length; i < j; i++) {
if (ancestors[i].type === 'ClassDeclaration' || ancestors[i].type === 'ObjectExpression') {
componentNode = ancestors[i];
break;
}
ancestors.unshift(node);
for (var i = 0, j = ancestors.length; i < j; i++) {
if (isComponentDefinition(ancestors[i])) {
componentNode = ancestors[i];
break;
}
}
if (!componentNode) {
return null;
}
return componentNode;

@@ -193,4 +206,5 @@ }

getNode: getNode,
isComponentDefinition: isComponentDefinition,
getIdentifiers: getIdentifiers,
List: List
};
{
"name": "eslint-plugin-react",
"version": "2.0.0",
"version": "2.0.1",
"author": "Yannick Croissant <yannick.croissant+npm@gmail.com>",

@@ -5,0 +5,0 @@ "description": "React specific linting rules for ESLint",

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