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.15.0 to 3.16.0

lib/rules/jsx-equals-spacing.js

23

CHANGELOG.md

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

## [3.16.0] - 2016-01-24
### Added
* Add `jsx-equals-spacing` rule ([#394][] @ryym)
* Add auto fix for `wrap-multiline`
* Add auto fix for `jsx-boolean-value`
* Add auto fix for `no-unknown-property`
* Add auto fix for `jsx-curly-spacing` ([#407][] @ewendel)
* Add `requiredFirst` option to `jsx-sort-prop-types` ([#392][] @chrislaskey)
* Add `ignoreRefs` option to `jsx-no-bind` ([#330][] @silvenon)
### Fixed
* Ignore `ref` in `jsx-handler-names` (again) ([#396][])
### Changed
* Update dependencies
[3.16.0]: https://github.com/yannickcr/eslint-plugin-react/compare/v3.15.0...v3.16.0
[#394]: https://github.com/yannickcr/eslint-plugin-react/issues/394
[#407]: https://github.com/yannickcr/eslint-plugin-react/pull/407
[#392]: https://github.com/yannickcr/eslint-plugin-react/pull/392
[#330]: https://github.com/yannickcr/eslint-plugin-react/issues/330
[#396]: https://github.com/yannickcr/eslint-plugin-react/issues/396
## [3.15.0] - 2016-01-12

@@ -8,0 +31,0 @@ ### Added

2

index.js

@@ -26,2 +26,3 @@ 'use strict';

'jsx-curly-spacing': require('./lib/rules/jsx-curly-spacing'),
'jsx-equals-spacing': require('./lib/rules/jsx-equals-spacing'),
'jsx-sort-props': require('./lib/rules/jsx-sort-props'),

@@ -66,2 +67,3 @@ 'jsx-sort-prop-types': require('./lib/rules/jsx-sort-prop-types'),

'jsx-curly-spacing': 0,
'jsx-equals-spacing': 0,
'jsx-sort-props': 0,

@@ -68,0 +70,0 @@ 'jsx-sort-prop-types': 0,

@@ -23,3 +23,9 @@ /**

if (node.value === null) {
context.report(node, ALWAYS_MESSAGE);
context.report({
node: node,
message: ALWAYS_MESSAGE,
fix: function(fixer) {
return fixer.insertTextAfter(node, '={true}');
}
});
}

@@ -29,3 +35,9 @@ break;

if (node.value && node.value.type === 'JSXExpressionContainer' && node.value.expression.value === true) {
context.report(node, NEVER_MESSAGE);
context.report({
node: node,
message: NEVER_MESSAGE,
fix: function(fixer) {
return fixer.removeRange([node.name.range[1], node.value.range[1]]);
}
});
}

@@ -32,0 +44,0 @@ break;

/**
* @fileoverview Enforce or disallow spaces inside of curly braces in JSX attributes.
* @author Jamund Ferguson, Brandyn Bennett, Michael Ficarra, Vignesh Anand, Jamund Ferguson, Yannick Croissant
* @author Jamund Ferguson
* @author Brandyn Bennett
* @author Michael Ficarra
* @author Vignesh Anand
* @author Jamund Ferguson
* @author Yannick Croissant
* @author Erik Wendel
*/

@@ -46,4 +52,11 @@ 'use strict';

function reportNoBeginningNewline(node, token) {
context.report(node, token.loc.start,
'There should be no newline after \'' + token.value + '\'');
context.report({
node: node,
loc: token.loc.start,
message: 'There should be no newline after \'' + token.value + '\'',
fix: function(fixer) {
var nextToken = context.getSourceCode().getTokenAfter(token);
return fixer.replaceTextRange([token.range[1], nextToken.range[0]], spaced ? ' ' : '');
}
});
}

@@ -58,4 +71,11 @@

function reportNoEndingNewline(node, token) {
context.report(node, token.loc.start,
'There should be no newline before \'' + token.value + '\'');
context.report({
node: node,
loc: token.loc.start,
message: 'There should be no newline before \'' + token.value + '\'',
fix: function(fixer) {
var previousToken = context.getSourceCode().getTokenBefore(token);
return fixer.replaceTextRange([previousToken.range[1], token.range[0]], spaced ? ' ' : '');
}
});
}

@@ -70,4 +90,11 @@

function reportNoBeginningSpace(node, token) {
context.report(node, token.loc.start,
'There should be no space after \'' + token.value + '\'');
context.report({
node: node,
loc: token.loc.start,
message: 'There should be no space after \'' + token.value + '\'',
fix: function(fixer) {
var nextToken = context.getSourceCode().getTokenAfter(token);
return fixer.removeRange([token.range[1], nextToken.range[0]]);
}
});
}

@@ -82,4 +109,11 @@

function reportNoEndingSpace(node, token) {
context.report(node, token.loc.start,
'There should be no space before \'' + token.value + '\'');
context.report({
node: node,
loc: token.loc.start,
message: 'There should be no space before \'' + token.value + '\'',
fix: function(fixer) {
var previousToken = context.getSourceCode().getTokenBefore(token);
return fixer.removeRange([previousToken.range[1], token.range[0]]);
}
});
}

@@ -94,4 +128,10 @@

function reportRequiredBeginningSpace(node, token) {
context.report(node, token.loc.start,
'A space is required after \'' + token.value + '\'');
context.report({
node: node,
loc: token.loc.start,
message: 'A space is required after \'' + token.value + '\'',
fix: function(fixer) {
return fixer.insertTextAfter(token, ' ');
}
});
}

@@ -106,4 +146,10 @@

function reportRequiredEndingSpace(node, token) {
context.report(node, token.loc.start,
'A space is required before \'' + token.value + '\'');
context.report({
node: node,
loc: token.loc.start,
message: 'A space is required before \'' + token.value + '\'',
fix: function(fixer) {
return fixer.insertTextBefore(token, ' ');
}
});
}

@@ -110,0 +156,0 @@

@@ -30,2 +30,6 @@ /**

if (propKey === 'ref') {
return;
}
var propIsEventHandler = PROP_EVENT_HANDLER_REGEX.test(propKey);

@@ -32,0 +36,0 @@ var propFnIsNamedCorrectly = EVENT_HANDLER_REGEX.test(propValue);

@@ -17,3 +17,4 @@ /**

JSXAttribute: function(node) {
if (!node.value || !node.value.expression) {
var isRef = configuration.ignoreRefs && node.name.name === 'ref';
if (isRef || !node.value || !node.value.expression) {
return;

@@ -49,2 +50,6 @@ }

type: 'boolean'
},
ignoreRefs: {
default: false,
type: 'boolean'
}

@@ -51,0 +56,0 @@ },

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

var configuration = context.options[0] || {};
var requiredFirst = configuration.requiredFirst || false;
var callbacksLast = configuration.callbacksLast || false;

@@ -42,2 +43,6 @@ var ignoreCase = configuration.ignoreCase || false;

function getValueName(node) {
return node.value.property.name;
}
function isCallbackPropName(propName) {

@@ -47,2 +52,6 @@ return /^on[A-Z]/.test(propName);

function isRequiredProp(node) {
return getValueName(node) === 'isRequired';
}
/**

@@ -57,2 +66,4 @@ * Checks if propTypes declarations are sorted

var currentPropName = getKey(curr);
var previousIsRequired = isRequiredProp(prev);
var currentIsRequired = isRequiredProp(curr);
var previousIsCallback = isCallbackPropName(prevPropName);

@@ -66,2 +77,14 @@ var currentIsCallback = isCallbackPropName(currentPropName);

if (requiredFirst) {
if (previousIsRequired && !currentIsRequired) {
// Transition between required and non-required. Don't compare for alphabetical.
return curr;
}
if (!previousIsRequired && currentIsRequired) {
// Encountered a non-required prop after a required prop
context.report(curr, 'Required prop types must be listed before all other prop types');
return curr;
}
}
if (callbacksLast) {

@@ -125,2 +148,5 @@ if (!previousIsCallback && currentIsCallback) {

properties: {
requiredFirst: {
type: 'boolean'
},
callbacksLast: {

@@ -127,0 +153,0 @@ type: 'boolean'

13

lib/rules/no-unknown-property.js

@@ -119,5 +119,12 @@ /**

}
context.report(node, UNKNOWN_MESSAGE, {
name: name,
standardName: standardName
context.report({
node: node,
message: UNKNOWN_MESSAGE,
data: {
name: name,
standardName: standardName
},
fix: function(fixer) {
return fixer.replaceText(node.name, standardName);
}
});

@@ -124,0 +131,0 @@ }

@@ -23,2 +23,4 @@ /**

var sourceCode = context.getSourceCode();
function isParenthesised(node) {

@@ -43,3 +45,9 @@ var previousToken = context.getTokenBefore(node);

if (!isParenthesised(node) && isMultilines(node)) {
context.report(node, 'Missing parentheses around multilines JSX');
context.report({
node: node,
message: 'Missing parentheses around multilines JSX',
fix: function(fixer) {
return fixer.replaceText(node, '(' + sourceCode.getText(node) + ')');
}
});
}

@@ -46,0 +54,0 @@ }

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

@@ -28,3 +28,3 @@ "description": "React specific linting rules for ESLint",

"coveralls": "2.11.6",
"eslint": "2.0.0-beta.1",
"eslint": "2.0.0-beta.2",
"istanbul": "0.4.2",

@@ -31,0 +31,0 @@ "mocha": "2.3.4"

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

"react/jsx-curly-spacing": 1,
"react/jsx-equals-spacing": 1,
"react/jsx-handler-names": 1,

@@ -121,5 +122,6 @@ "react/jsx-indent-props": 1,

* [forbid-prop-types](docs/rules/forbid-prop-types.md): Forbid certain propTypes
* [jsx-boolean-value](docs/rules/jsx-boolean-value.md): Enforce boolean attributes notation in JSX
* [jsx-boolean-value](docs/rules/jsx-boolean-value.md): Enforce boolean attributes notation in JSX (fixable)
* [jsx-closing-bracket-location](docs/rules/jsx-closing-bracket-location.md): Validate closing bracket location in JSX
* [jsx-curly-spacing](docs/rules/jsx-curly-spacing.md): Enforce or disallow spaces inside of curly braces in JSX attributes
* [jsx-curly-spacing](docs/rules/jsx-curly-spacing.md): Enforce or disallow spaces inside of curly braces in JSX attributes (fixable)
* [jsx-equals-spacing](docs/rules/jsx-equals-spacing.md): Enforce or disallow spaces around equal signs in JSX attributes
* [jsx-handler-names](docs/rules/jsx-handler-names.md): Enforce event handler naming conventions in JSX

@@ -149,3 +151,3 @@ * [jsx-indent-props](docs/rules/jsx-indent-props.md): Validate props indentation in JSX

* [no-string-refs](docs/rules/no-string-refs.md): Prevent using string references in `ref` attribute.
* [no-unknown-property](docs/rules/no-unknown-property.md): Prevent usage of unknown DOM property
* [no-unknown-property](docs/rules/no-unknown-property.md): Prevent usage of unknown DOM property (fixable)
* [prefer-es6-class](docs/rules/prefer-es6-class.md): Enforce ES5 or ES6 class for React Components

@@ -157,3 +159,3 @@ * [prop-types](docs/rules/prop-types.md): Prevent missing props validation in a React component definition

* [sort-comp](docs/rules/sort-comp.md): Enforce component methods order
* [wrap-multilines](docs/rules/wrap-multilines.md): Prevent missing parentheses around multilines JSX
* [wrap-multilines](docs/rules/wrap-multilines.md): Prevent missing parentheses around multilines JSX (fixable)

@@ -160,0 +162,0 @@ ## React Native

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