eslint-plugin-react
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -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 @@ ================== |
@@ -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", |
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
43426
993