Socket
Socket
Sign inDemoInstall

eslint-plugin-react

Package Overview
Dependencies
Maintainers
1
Versions
208
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 2.7.1 to 3.0.0

lib/rules/jsx-no-duplicate-props.js

14

History.md

@@ -0,1 +1,15 @@

3.0.0 / 2015-07-21
==================
* add jsx-no-duplicate-props rule ([#161][] @hummlas)
* add allowMultiline option to the jsx-curly-spacing rule ([#156][] @mathieumg)
* breaking in jsx-curly-spacing braces spanning multiple lines are now allowed with never option ([#156][] @mathieumg)
* fix multiple var and destructuring handling in props-types ([#159][])
* fix crash when retrieving propType name ([#163][])
[#161]: https://github.com/yannickcr/eslint-plugin-react/pull/161
[#156]: https://github.com/yannickcr/eslint-plugin-react/pull/156
[#159]: https://github.com/yannickcr/eslint-plugin-react/issues/159
[#163]: https://github.com/yannickcr/eslint-plugin-react/issues/163
2.7.1 / 2015-07-16

@@ -2,0 +16,0 @@ ==================

6

index.js

@@ -24,3 +24,4 @@ 'use strict';

'sort-comp': require('./lib/rules/sort-comp'),
'require-extension': require('./lib/rules/require-extension')
'require-extension': require('./lib/rules/require-extension'),
'jsx-no-duplicate-props': require('./lib/rules/jsx-no-duplicate-props')
},

@@ -47,4 +48,5 @@ rulesConfig: {

'sort-comp': 0,
'require-extension': 0
'require-extension': 0,
'jsx-no-duplicate-props': 0
}
};

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

var spaced = context.options[0] === 'always';
var multiline = context.options[1] ? context.options[1].allowMultiline : true;

@@ -20,5 +21,15 @@ // --------------------------------------------------------------------------

/**
* Determines whether two adjacent tokens are have whitespace between them.
* Determines whether two adjacent tokens have a newline between them.
* @param {Object} left - The left token object.
* @param {Object} right - The right token object.
* @returns {boolean} Whether or not there is a newline between the tokens.
*/
function isMultiline(left, right) {
return left.loc.start.line !== right.loc.start.line;
}
/**
* Determines whether two adjacent tokens have whitespace between them.
* @param {Object} left - The left token object.
* @param {Object} right - The right token object.
* @returns {boolean} Whether or not there is space between the tokens.

@@ -31,2 +42,24 @@ */

/**
* Reports that there shouldn't be a newline after the first token
* @param {ASTNode} node - The node to report in the event of an error.
* @param {Token} token - The token to use for the report.
* @returns {void}
*/
function reportNoBeginningNewline(node, token) {
context.report(node, token.loc.start,
'There should be no newline after \'' + token.value + '\'');
}
/**
* Reports that there shouldn't be a newline before the last token
* @param {ASTNode} node - The node to report in the event of an error.
* @param {Token} token - The token to use for the report.
* @returns {void}
*/
function reportNoEndingNewline(node, token) {
context.report(node, token.loc.start,
'There should be no newline before \'' + token.value + '\'');
}
/**
* Reports that there shouldn't be a space after the first token

@@ -85,12 +118,24 @@ * @param {ASTNode} node - The node to report in the event of an error.

function validateBraceSpacing(node, first, second, penultimate, last) {
if (spaced && !isSpaced(first, second)) {
reportRequiredBeginningSpace(node, first);
if (spaced) {
if (!isSpaced(first, second)) {
reportRequiredBeginningSpace(node, first);
} else if (!multiline && isMultiline(first, second)) {
reportNoBeginningNewline(node, first);
}
if (!isSpaced(penultimate, last)) {
reportRequiredEndingSpace(node, last);
} else if (!multiline && isMultiline(penultimate, last)) {
reportNoEndingNewline(node, last);
}
return;
}
if (!spaced && isSpaced(first, second)) {
// "never" setting if we get here.
if (isSpaced(first, second) && !(multiline && isMultiline(first, second))) {
reportNoBeginningSpace(node, first);
}
if (spaced && !isSpaced(penultimate, last)) {
reportRequiredEndingSpace(node, last);
}
if (!spaced && isSpaced(penultimate, last)) {
if (isSpaced(penultimate, last) && !(multiline && isMultiline(penultimate, last))) {
reportNoEndingSpace(node, last);

@@ -118,2 +163,10 @@ }

enum: ['always', 'never']
}, {
type: 'object',
properties: {
allowMultiline: {
type: 'boolean'
}
},
additionalProperties: false
}];

@@ -355,8 +355,8 @@ /**

} else if (
node.parent.parent.declarations &&
node.parent.parent.declarations[0].id.properties &&
getKeyValue(node.parent.parent.declarations[0].id.properties[0])
node.parent.id &&
node.parent.id.properties &&
getKeyValue(node.parent.id.properties[0])
) {
type = 'destructuring';
properties = node.parent.parent.declarations[0].id.properties;
properties = node.parent.id.properties;
}

@@ -465,3 +465,3 @@ break;

}
if (propTypes) {
if (propTypes && propTypes.property) {
curDeclaredPropTypes[propTypes.property.name] =

@@ -468,0 +468,0 @@ buildReactDeclarationTypes(propTypes.parent.right);

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

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

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

"react/jsx-boolean-value": 1,
"react/jsx-no-duplicate-props": 1,
"react/jsx-no-undef": 1,

@@ -74,2 +75,3 @@ "react/jsx-quotes": 1,

* [jsx-curly-spacing](docs/rules/jsx-curly-spacing.md): Enforce or disallow spaces inside of curly braces in JSX attributes
* [jsx-no-duplicate-props](docs/rules/jsx-no-duplicate-props.md): Prevent duplicate props in JSX
* [jsx-no-undef](docs/rules/jsx-no-undef.md): Disallow undeclared variables in JSX

@@ -76,0 +78,0 @@ * [jsx-quotes](docs/rules/jsx-quotes.md): Enforce quote style for JSX attributes

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