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

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.6.2 to 3.6.3

11

CHANGELOG.md

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

## [3.6.3] - 2015-10-20
### Fixed
* Fix `display-name` for stateless components ([#256][])
* Fix `prop-types` props validation in constructor ([#259][])
* Fix typo in README ([#261][] @chiedojohn)
[3.6.3]: https://github.com/yannickcr/eslint-plugin-react/compare/v3.6.2...v3.6.3
[#256]: https://github.com/yannickcr/eslint-plugin-react/issues/256
[#259]: https://github.com/yannickcr/eslint-plugin-react/issues/259
[#261]: https://github.com/yannickcr/eslint-plugin-react/pull/261
## [3.6.2] - 2015-10-18

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

48

lib/rules/display-name.js

@@ -78,3 +78,3 @@ /**

function hasTranspilerName(node) {
var namedAssignment = (
var namedObjectAssignment = (
node.type === 'ObjectExpression' &&

@@ -89,3 +89,3 @@ node.parent &&

);
var namedDeclaration = (
var namedObjectDeclaration = (
node.type === 'ObjectExpression' &&

@@ -101,3 +101,19 @@ node.parent &&

if (namedAssignment || namedDeclaration || namedClass) {
var namedFunctionDeclaration = (
(node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression') &&
node.id &&
node.id.name
);
var namedFunctionExpression = (
(node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression') &&
node.parent &&
(node.parent.type === 'VariableDeclarator' || node.parent.method === true)
);
if (
namedObjectAssignment || namedObjectDeclaration ||
namedClass ||
namedFunctionDeclaration || namedFunctionExpression
) {
return true;

@@ -125,3 +141,3 @@ }

}
var component = componentList.getByName(node.object.name);
var component = componentList.getByName(context.getSource(node.object));
if (!component) {

@@ -133,2 +149,26 @@ return;

FunctionExpression: function(node) {
componentList.set(context, node);
if (!acceptTranspilerName || !hasTranspilerName(node)) {
return;
}
markDisplayNameAsDeclared(node);
},
FunctionDeclaration: function(node) {
componentList.set(context, node);
if (!acceptTranspilerName || !hasTranspilerName(node)) {
return;
}
markDisplayNameAsDeclared(node);
},
ArrowFunctionExpression: function(node) {
componentList.set(context, node);
if (!acceptTranspilerName || !hasTranspilerName(node)) {
return;
}
markDisplayNameAsDeclared(node);
},
MethodDefinition: function(node) {

@@ -135,0 +175,0 @@ if (!isDisplayNameDeclaration(node.key)) {

9

lib/rules/prop-types.js

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

function getPropertyName(node) {
if (componentUtil.getNode(context, node) && !inConstructor()) {
if (node.object.name === 'props') {
return void 0;
}
var directProp = /^props\./.test(context.getSource(node));
if (directProp && componentUtil.getNode(context, node) && !inConstructor(node)) {
return void 0;
}
if (!directProp) {
node = node.parent;

@@ -340,0 +341,0 @@ }

@@ -75,3 +75,13 @@ /**

function getIdentifiers(node) {
var name = node.id && node.id.name || DEFAULT_COMPONENT_NAME;
var name = [];
var loopNode = node;
var namePart = [];
while (loopNode) {
namePart = (loopNode.id && loopNode.id.name) || (loopNode.key && loopNode.key.name);
if (namePart) {
name.unshift(namePart);
}
loopNode = loopNode.parent;
}
name = name.join('.') || DEFAULT_COMPONENT_NAME;
var id = name + ':' + node.loc.start.line + ':' + node.loc.start.column;

@@ -102,3 +112,3 @@

var identifiers = getIdentifiers(ancestors[i]);
if (list && list[identifiers.id]) {
if (list && list[identifiers.id] && list[identifiers.id].isComponent) {
return ancestors[i];

@@ -141,3 +151,3 @@ }

return this._list[identifiers.id] || null;
return this._list[identifiers.id] && this._list[identifiers.id].isComponent ? this._list[identifiers.id] : null;
};

@@ -152,3 +162,7 @@

for (var component in this._list) {
if (this._list.hasOwnProperty(component) && this._list[component].name === name) {
if (
this._list.hasOwnProperty(component) &&
this._list[component].name === name &&
this._list[component].isComponent
) {
return this._list[component];

@@ -165,3 +179,10 @@ }

List.prototype.getList = function() {
return this._list;
var components = {};
for (var component in this._list) {
if (!this._list.hasOwnProperty(component) || this._list[component].isComponent !== true) {
continue;
}
components[component] = this._list[component];
}
return components;
};

@@ -178,11 +199,14 @@

var componentNode = getNode(context, node, this._list);
if (!componentNode) {
return null;
var isComponent = false;
if (componentNode) {
node = componentNode;
isComponent = true;
}
var identifiers = getIdentifiers(componentNode);
var identifiers = getIdentifiers(node);
var component = util._extend({
name: identifiers.name,
node: componentNode
node: node,
isComponent: isComponent
}, customProperties || {});

@@ -189,0 +213,0 @@

{
"name": "eslint-plugin-react",
"version": "3.6.2",
"version": "3.6.3",
"author": "Yannick Croissant <yannick.croissant+npm@gmail.com>",

@@ -5,0 +5,0 @@ "description": "React specific linting rules for ESLint",

@@ -71,2 +71,3 @@ ESLint-plugin-React

"react/no-unknown-property": 1,
"react/prefer-es6-class": 1,
"react/prop-types": 1,

@@ -77,4 +78,3 @@ "react/react-in-jsx-scope": 1,

"react/sort-comp": 1,
"react/wrap-multilines": 1,
"prefer-es6-class": 1,
"react/wrap-multilines": 1
}

@@ -108,2 +108,3 @@ }

* [no-unknown-property](docs/rules/no-unknown-property.md): Prevent usage of unknown DOM property
* [prefer-es6-class](docs/rules/prefer-es6-class.md): Prefer es6 class instead of createClass for React Components
* [prop-types](docs/rules/prop-types.md): Prevent missing props validation in a React component definition

@@ -115,3 +116,2 @@ * [react-in-jsx-scope](docs/rules/react-in-jsx-scope.md): Prevent missing `React` when using JSX

* [wrap-multilines](docs/rules/wrap-multilines.md): Prevent missing parentheses around multilines JSX
* [prefer-es6-class](docs/rules/prefer-es6-class.md): Prefer es6 class instead of createClass for React Components

@@ -118,0 +118,0 @@ ## To Do

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