Files

Return to Package Diff Home.
Brought to you by Intrinsic.

Package Diff: eslint-plugin-react @ 6.10.0 .. 6.10.3

CHANGELOG.md

@@ -3,6 +3,33 @@
This project adheres to [Semantic Versioning](http://semver.org/).
This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com).
+## [6.10.3] - 2017-03-20
+### Fixed
+* Revert [#1057][] due to issues with [`jsx-indent`][] ([#1117][])
+
+[6.10.3]: https://github.com/yannickcr/eslint-plugin-react/compare/v6.10.2...v6.10.3
+
+## [6.10.2] - 2017-03-19
+### Fixed
+* Fix [`jsx-indent`][] indentation calculation with nested JSX ([#1117][])
+
+[6.10.2]: https://github.com/yannickcr/eslint-plugin-react/compare/v6.10.1...v6.10.2
+[#1117]: https://github.com/yannickcr/eslint-plugin-react/issues/1117
+
+## [6.10.1] - 2017-03-19
+### Fixed
+* Fix [`jsx-indent`][] auto fix with tabs ([#1057][] @kentcdodds @webOS101)
+* Fix [`jsx-indent`][] crash ([#1061][] @iancmyers)
+* Fix [`void-dom-elements-no-children`][] crash and fix it to only checks for a createElement call from
+React ([#1073][] @jomasti)
+* Fix component detection that caused a false positive in [`no-multi-comp`][] ([#1088][] @benstepp)
+
+[6.10.1]: https://github.com/yannickcr/eslint-plugin-react/compare/v6.10.0...v6.10.1
+[#1057]: https://github.com/yannickcr/eslint-plugin-react/issues/1057
+[#1061]: https://github.com/yannickcr/eslint-plugin-react/issues/1061
+[#1073]: https://github.com/yannickcr/eslint-plugin-react/issues/1073
+[#1088]: https://github.com/yannickcr/eslint-plugin-react/issues/1088
+
## [6.10.0] - 2017-02-16
### Added
* Add [`forbid-foreign-prop-types`][] rule ([#696][] @iancmyers)
@@ -70,7 +97,7 @@
* Fix [`jsx-indent`][] with multiline jsx in ternaries ([#966][])
* Fix component detection to ignore async functions ([#989][] @taion)
* Fix [`jsx-curly-spacing`][] autofix to not delete comments ([#648][])
-* FIx auto-enabling of `eslint-plugin-react` in exported configurations ([#984][] @jamischarles)
+* Fix auto-enabling of `eslint-plugin-react` in exported configurations ([#984][] @jamischarles)
### Changed
* Update dependencies

lib/rules/jsx-indent.js

@@ -233,7 +233,7 @@
do {
prevToken = sourceCode.getTokenBefore(prevToken);
} while (prevToken.type === 'Punctuator');
- prevToken = sourceCode.getNodeByRangeIndex(prevToken.start);
+ prevToken = sourceCode.getNodeByRangeIndex(prevToken.range[0]);
while (prevToken.parent && prevToken.parent.type !== 'ConditionalExpression') {
prevToken = prevToken.parent;
}

lib/rules/void-dom-elements-no-children.js

@@ -8,6 +8,8 @@
var find = require('array.prototype.find');
var has = require('has');
+var Components = require('../util/Components');
+
// ------------------------------------------------------------------------------
// Helpers
// ------------------------------------------------------------------------------
@@ -55,7 +57,7 @@
schema: []
},
- create: function(context) {
+ create: Components.detect(function(context, components, utils) {
return {
JSXElement: function(node) {
var elementName = node.openingElement.name.name;
@@ -93,11 +95,11 @@
},
CallExpression: function(node) {
- if (node.callee.type !== 'MemberExpression') {
+ if (node.callee.type !== 'MemberExpression' && node.callee.type !== 'Identifier') {
return;
}
- if (node.callee.property.name !== 'createElement') {
+ if (!utils.hasDestructuredReactCreateElement() && !utils.isReactCreateElement(node)) {
return;
}
@@ -109,6 +111,10 @@
return;
}
+ if (args.length < 2) {
+ return;
+ }
+
var firstChild = args[2];
if (firstChild) {
// e.g. React.createElement('br', undefined, 'Foo')
@@ -137,5 +143,5 @@
}
}
};
- }
+ })
};

lib/util/Components.js

@@ -214,6 +214,51 @@
},
/**
+ * Check if createElement is destructured from React import
+ *
+ * @returns {Boolean} True if createElement is destructured from React
+ */
+ hasDestructuredReactCreateElement: function() {
+ var variables = variableUtil.variablesInScope(context);
+ var variable = variableUtil.getVariable(variables, 'createElement');
+ if (variable) {
+ var map = variable.scope.set;
+ if (map.has('React')) {
+ return true;
+ }
+ }
+ return false;
+ },
+
+ /**
+ * Checks to see if node is called within React.createElement
+ *
+ * @param {ASTNode} node The AST node being checked.
+ * @returns {Boolean} True if React.createElement called
+ */
+ isReactCreateElement: function(node) {
+ var calledOnReact = (
+ node &&
+ node.callee &&
+ node.callee.object &&
+ node.callee.object.name === 'React' &&
+ node.callee.property &&
+ node.callee.property.name === 'createElement'
+ );
+
+ var calledDirectly = (
+ node &&
+ node.callee &&
+ node.callee.name === 'createElement'
+ );
+
+ if (this.hasDestructuredReactCreateElement()) {
+ return calledDirectly || calledOnReact;
+ }
+ return calledOnReact;
+ },
+
+ /**
* Check if the node is returning JSX
*
* @param {ASTNode} ASTnode The AST node being checked
@@ -256,26 +301,7 @@
node[property] &&
node[property].type === 'JSXElement'
;
- var destructuredReactCreateElement = function () {
- var variables = variableUtil.variablesInScope(context);
- var variable = variableUtil.getVariable(variables, 'createElement');
- if (variable) {
- var map = variable.scope.set;
- if (map.has('React')) {
- return true;
- }
- }
- return false;
- };
- var returnsReactCreateElement =
- destructuredReactCreateElement() ||
- node[property] &&
- node[property].callee &&
- node[property].callee.object &&
- node[property].callee.object.name === 'React' &&
- node[property].callee.property &&
- node[property].callee.property.name === 'createElement'
- ;
+ var returnsReactCreateElement = this.isReactCreateElement(node[property]);
return Boolean(
returnsConditionalJSX ||

package.json

@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-react",
- "version": "6.10.0",
+ "version": "6.10.3",
"author": "Yannick Croissant <yannick.croissant+npm@gmail.com>",
"description": "React specific linting rules for ESLint",
"main": "index.js",