Socket
Socket
Sign inDemoInstall

eslint-plugin-react

Package Overview
Dependencies
Maintainers
1
Versions
210
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 3.11.2 to 3.11.3

13

CHANGELOG.md

@@ -6,2 +6,15 @@ # Change Log

## [3.11.3] - 2015-12-05
### Fixed
* Fix crash in `prop-types` when reassigning props ([#345][])
* Fix `jsx-handler-names` for stateless components ([#346][])
### Changed
* Update `jsx-handler-names` error messages to be less specific ([#348][] @jakemmarsh)
[3.11.3]: https://github.com/yannickcr/eslint-plugin-react/compare/v3.11.2...v3.11.3
[#345]: https://github.com/yannickcr/eslint-plugin-react/issues/345
[#346]: https://github.com/yannickcr/eslint-plugin-react/issues/346
[#348]: https://github.com/yannickcr/eslint-plugin-react/pull/348
## [3.11.2] - 2015-12-01

@@ -8,0 +21,0 @@ ### Fixed

33

lib/rules/jsx-handler-names.js

@@ -17,28 +17,6 @@ /**

var EVENT_HANDLER_REGEX = new RegExp('^((this\.props\.' + eventHandlerPropPrefix + ')'
var EVENT_HANDLER_REGEX = new RegExp('^((props\.' + eventHandlerPropPrefix + ')'
+ '|((.*\.)?' + eventHandlerPrefix + ')).+$');
var PROP_EVENT_HANDLER_REGEX = new RegExp('^' + eventHandlerPropPrefix + '.+$');
/**
* Get full prop value for a handler, i.e. `this.props.<name>`
* @param {Object} node.value.expression for JSXAttribute
* @return {String} Full prop value
*/
function rebuildPropValue(valueNode) {
var valueNodeObject = valueNode.object;
var subObjectType = valueNodeObject.object ? valueNodeObject.object.type : '';
var propertyName = valueNodeObject.property && valueNodeObject.property.name ? valueNodeObject.property.name : '';
var propValue = valueNode.property && valueNode.property.name ? valueNode.property.name : '';
if (propertyName.length) {
propValue = propertyName + '.' + propValue;
}
if (subObjectType === 'ThisExpression') {
propValue = 'this.' + propValue;
}
return propValue;
}
return {

@@ -51,19 +29,16 @@ JSXAttribute: function(node) {

var propKey = typeof node.name === 'object' ? node.name.name : node.name;
var propValue = rebuildPropValue(node.value.expression);
var propValue = context.getSource(node.value.expression).replace(/^this\./, '');
var propIsEventHandler = PROP_EVENT_HANDLER_REGEX.test(propKey);
var propFnIsNamedCorrectly = EVENT_HANDLER_REGEX.test(propValue);
var eventName;
if (propIsEventHandler && !propFnIsNamedCorrectly) {
eventName = propKey.split(eventHandlerPropPrefix)[1];
context.report(
node,
'Handler function for ' + propKey + ' prop key must be named ' + eventHandlerPrefix + eventName
'Handler function for ' + propKey + ' prop key must begin with \'' + eventHandlerPrefix + '\''
);
} else if (propFnIsNamedCorrectly && !propIsEventHandler) {
eventName = propValue.split(eventHandlerPrefix)[1];
context.report(
node,
'Prop key for ' + propValue + ' must be named ' + eventHandlerPropPrefix + eventName
'Prop key for ' + propValue + ' must begin with \'' + eventHandlerPropPrefix + '\''
);

@@ -70,0 +45,0 @@ }

@@ -569,6 +569,7 @@ /**

VariableDeclarator: function(node) {
var destructuring = node.init && node.id && node.id.type === 'ObjectPattern';
// let {props: {firstname}} = this
var thisDestructuring = node.init && node.init.type === 'ThisExpression' && node.id.type === 'ObjectPattern';
var thisDestructuring = destructuring && node.init.type === 'ThisExpression';
// let {firstname} = props
var statelessDestructuring = node.init && node.init.name === 'props' && utils.getParentStatelessComponent();
var statelessDestructuring = destructuring && node.init.name === 'props' && utils.getParentStatelessComponent();

@@ -575,0 +576,0 @@ if (!thisDestructuring && !statelessDestructuring) {

@@ -10,2 +10,3 @@ /**

*
* @param {Object} context The current rule context.
* @param {String} name The name of the variable to mark as used.

@@ -12,0 +13,0 @@ * @returns {Boolean} True if the variable was found and marked as used, false if not.

{
"name": "eslint-plugin-react",
"version": "3.11.2",
"version": "3.11.3",
"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