Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

eslint-plugin-react

Package Overview
Dependencies
Maintainers
1
Versions
213
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.5.0 to 3.5.1

15

CHANGELOG.md

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

## [3.5.1] - 2015-10-01
### Fixed
* Fix `no-direct-mutation-state` to report only in React components ([#229][])
* Fix `forbid-prop-types` for arrayOf and instanceOf ([#230][])
### Changed
* Documentation improvements ([#232][] @edge)
[3.5.1]: https://github.com/yannickcr/eslint-plugin-react/compare/v3.5.0...v3.5.1
[#229]: https://github.com/yannickcr/eslint-plugin-react/issues/229
[#230]: https://github.com/yannickcr/eslint-plugin-react/issues/230
[#232]: https://github.com/yannickcr/eslint-plugin-react/pull/232
## [3.5.0] - 2015-09-28

@@ -13,3 +26,3 @@ ### Added

### Fixed
* Fix no-did-mount/update-set-state rules for ES6 classes
* Fix no-did-mount/update-set-state rules, these rules were not working on ES6 classes

@@ -16,0 +29,0 @@ ### Changed

@@ -64,2 +64,8 @@ /**

}
if (
declaration.value.type === 'CallExpression' &&
declaration.value.callee.type === 'MemberExpression'
) {
declaration.value = declaration.value.callee;
}

@@ -66,0 +72,0 @@ if (isForbidden(declaration.value.property.name)) {

@@ -7,2 +7,5 @@ /**

var componentUtil = require('../util/component');
var ComponentList = componentUtil.List;
// ------------------------------------------------------------------------------

@@ -14,2 +17,28 @@ // Rule Definition

var componentList = new ComponentList();
/**
* Checks if the component is valid
* @param {Object} component The component to process
* @returns {Boolean} True if the component is valid, false if not.
*/
function isValid(component) {
var isNotReactComponent = Boolean(component && !component.isReactComponent);
var doNotMutateSetState = Boolean(component && !component.mutateSetState);
return isNotReactComponent || doNotMutateSetState;
}
/**
* Reports undeclared proptypes for a given component
* @param {Object} component The component to process
*/
function reportMutations(component) {
var mutation;
for (var i = 0, j = component.mutations.length; i < j; i++) {
mutation = component.mutations[i];
context.report(mutation, 'Do not mutate state directly. Use setState().');
}
}
// --------------------------------------------------------------------------

@@ -34,4 +63,29 @@ // Public

) {
context.report(node.left.object, 'Do not mutate state directly. Use setState().');
var component = componentList.getByNode(context, node);
var mutations = component && component.mutations || [];
mutations.push(node.left.object);
componentList.set(context, node, {
mutateSetState: true,
mutations: mutations
});
}
},
'Program:exit': function() {
var list = componentList.getList();
for (var component in list) {
if (!list.hasOwnProperty(component) || isValid(list[component])) {
continue;
}
reportMutations(list[component]);
}
},
ReturnStatement: function(node) {
if (!componentUtil.isReactComponent(context, node)) {
return;
}
componentList.set(context, node, {
isReactComponent: true
});
}

@@ -38,0 +92,0 @@ };

2

package.json
{
"name": "eslint-plugin-react",
"version": "3.5.0",
"version": "3.5.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