eslint-plugin-react
Advanced tools
Comparing version 2.0.2 to 2.1.0
@@ -0,1 +1,16 @@ | ||
2.1.0 / 2015-04-06 | ||
================== | ||
* update jsx-sort-props to reset the alphabetical verification on spread ([#47][] @zertosh) | ||
* update jsx-uses-vars to be enabled by default ([#49][] @banderson) | ||
* add jsx-boolean-value rule ([#11][]) | ||
* add support for static methods in display-name and prop-types ([#48][]) | ||
* fix describing comment for hasSpreadOperator() method ([#53][] @AlexKVal) | ||
[#47]: https://github.com/yannickcr/eslint-plugin-react/pull/47 | ||
[#49]: https://github.com/yannickcr/eslint-plugin-react/pull/49 | ||
[#11]: https://github.com/yannickcr/eslint-plugin-react/issues/11 | ||
[#48]: https://github.com/yannickcr/eslint-plugin-react/issues/48 | ||
[#53]: https://github.com/yannickcr/eslint-plugin-react/pull/53 | ||
2.0.2 / 2015-03-31 | ||
@@ -2,0 +17,0 @@ ================== |
@@ -18,3 +18,4 @@ 'use strict'; | ||
'no-unknown-property': require('./lib/rules/no-unknown-property'), | ||
'jsx-sort-props': require('./lib/rules/jsx-sort-props') | ||
'jsx-sort-props': require('./lib/rules/jsx-sort-props'), | ||
'jsx-boolean-value': require('./lib/rules/jsx-boolean-value') | ||
}, | ||
@@ -31,8 +32,9 @@ rulesConfig: { | ||
'react-in-jsx-scope': 0, | ||
'jsx-uses-vars': 0, | ||
'jsx-uses-vars': 1, | ||
'jsx-no-undef': 0, | ||
'jsx-quotes': 0, | ||
'no-unknown-property': 0, | ||
'jsx-sort-props': 0 | ||
'jsx-sort-props': 0, | ||
'jsx-boolean-value': 0 | ||
} | ||
}; |
@@ -86,2 +86,9 @@ /** | ||
MethodDefinition: function(node) { | ||
if (!isDisplayNameDeclaration(node.key)) { | ||
return; | ||
} | ||
markDisplayNameAsDeclared(node); | ||
}, | ||
ObjectExpression: function(node) { | ||
@@ -88,0 +95,0 @@ // Search for the displayName declaration |
@@ -18,7 +18,7 @@ /** | ||
JSXOpeningElement: function(node) { | ||
var attributes = node.attributes.filter(function(decl) { | ||
return decl.type === 'JSXAttribute'; | ||
}); | ||
node.attributes.reduce(function(memo, decl, idx, attrs) { | ||
if (decl.type === 'JSXSpreadAttribute') { | ||
return attrs[idx + 1]; | ||
} | ||
attributes.reduce(function(memo, decl) { | ||
var lastPropName = memo.name.name; | ||
@@ -38,5 +38,5 @@ var currenPropName = decl.name.name; | ||
return decl; | ||
}, attributes[0]); | ||
}, node.attributes[0]); | ||
} | ||
}; | ||
}; |
@@ -7,2 +7,4 @@ /** | ||
var variableUtil = require('../util/variable'); | ||
// ------------------------------------------------------------------------------ | ||
@@ -25,3 +27,3 @@ // Rule Definition | ||
JSXOpeningElement: function() { | ||
context.markVariableAsUsed(id); | ||
variableUtil.markVariableAsUsed(context, id); | ||
}, | ||
@@ -28,0 +30,0 @@ |
@@ -5,5 +5,6 @@ /** | ||
*/ | ||
'use strict'; | ||
var variableUtil = require('../util/variable'); | ||
// ------------------------------------------------------------------------------ | ||
@@ -17,9 +18,10 @@ // Rule Definition | ||
JSXExpressionContainer: function(node) { | ||
if (node.expression.type === 'Identifier') { | ||
context.markVariableAsUsed(node.expression.name); | ||
if (node.expression.type !== 'Identifier') { | ||
return; | ||
} | ||
variableUtil.markVariableAsUsed(context, node.expression.name); | ||
}, | ||
JSXIdentifier: function(node) { | ||
context.markVariableAsUsed(node.name); | ||
variableUtil.markVariableAsUsed(context, node.name); | ||
} | ||
@@ -26,0 +28,0 @@ |
@@ -85,6 +85,5 @@ /** | ||
/** | ||
* Checks if the prop is declared | ||
* @param {String} name Name of the prop to check. | ||
* @param {Object} component The component to process | ||
* @returns {Boolean} True if the prop is declared, false if not. | ||
* Checks if the prop has spread operator. | ||
* @param {ASTNode} node The AST node being marked. | ||
* @returns {Boolean} True if the prop has spread operator, false if not. | ||
*/ | ||
@@ -224,2 +223,17 @@ function hasSpreadOperator(node) { | ||
MethodDefinition: function(node) { | ||
if (!isPropTypesDeclaration(node.key)) { | ||
return; | ||
} | ||
var i = node.value.body.body.length - 1; | ||
for (; i >= 0; i--) { | ||
if (node.value.body.body[i].type === 'ReturnStatement') { | ||
break; | ||
} | ||
} | ||
markPropTypesAsDeclared(node, node.value.body.body[i].argument); | ||
}, | ||
ObjectExpression: function(node) { | ||
@@ -226,0 +240,0 @@ // Search for the displayName declaration |
@@ -7,2 +7,4 @@ /** | ||
var variableUtil = require('../util/variable'); | ||
// ----------------------------------------------------------------------------- | ||
@@ -19,32 +21,7 @@ // Rule Definition | ||
function findVariable(variables, name) { | ||
var i, len; | ||
for (i = 0, len = variables.length; i < len; i++) { | ||
if (variables[i].name === name) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
function variablesInScope() { | ||
var scope = context.getScope(), | ||
variables = scope.variables; | ||
while (scope.type !== 'global') { | ||
scope = scope.upper; | ||
variables = scope.variables.concat(variables); | ||
} | ||
if (scope.childScopes.length) { | ||
variables = scope.childScopes[0].variables.concat(variables); | ||
} | ||
return variables; | ||
} | ||
return { | ||
JSXOpeningElement: function(node) { | ||
var variables = variablesInScope(); | ||
if (findVariable(variables, id)) { | ||
var variables = variableUtil.variablesInScope(context); | ||
if (variableUtil.findVariable(variables, id)) { | ||
return; | ||
@@ -51,0 +28,0 @@ } |
{ | ||
"name": "eslint-plugin-react", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"author": "Yannick Croissant <yannick.croissant+npm@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description": "React specific linting rules for ESLint", |
@@ -46,2 +46,3 @@ ESLint-plugin-React | ||
"react/display-name": 1, | ||
"react/jsx-boolean-value": 1, | ||
"react/jsx-quotes": 1, | ||
@@ -67,2 +68,3 @@ "react/jsx-no-undef": 1, | ||
* [display-name](docs/rules/display-name.md): Prevent missing displayName in a React component definition | ||
* [jsx-boolean-value](docs/rules/jsx-boolean-value.md): Enforce boolean attributes notation in JSX | ||
* [jsx-quotes](docs/rules/jsx-quotes.md): Enforce quote style for JSX attributes | ||
@@ -69,0 +71,0 @@ * [jsx-no-undef](docs/rules/jsx-no-undef.md): Disallow undeclared variables in JSX |
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
49686
22
1149
115