diff --git a/CHANGELOG.md b/CHANGELOG.md index 323faa6e96..bb51d93572 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,34 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com). +## [6.2.0] - 2016-08-28 +### Added +* Adds `no-unused-prop-types` rule ([#226][] @EvNaverniouk) +* Add `style-prop-object` rule ([#715][] @petersendidit) +* Add auto fix for `self-closing-comp` ([#770][] @pl12133) +* Add support for `typeAnnotations` in `sort-comp` ([#235][] @dozoisch) +* Add support for `PureComponent` in `prefer-stateless-function` ([#781][] @tiemevanveen) + +## Fixed +* Fix `jsx-uses-vars` to work better with `prefer-const`. You'll need to upgrade to ESLint 3.4.0 to completely fix the compatibility issue ([#716][]) +* Fix `require-render-return` crash ([#784][]) +* Fix related components detection in `prop-types` ([#735][]) +* Fix component detection to ignore functions expression without a parent component + +### Changed +* Update dependencies +* Documentation improvements (@lencioni) + +[6.2.0]: https://github.com/yannickcr/eslint-plugin-react/compare/v6.1.2...v6.2.0 +[#226]: https://github.com/yannickcr/eslint-plugin-react/issues/226 +[#715]: https://github.com/yannickcr/eslint-plugin-react/issues/715 +[#770]: https://github.com/yannickcr/eslint-plugin-react/pull/770 +[#235]: https://github.com/yannickcr/eslint-plugin-react/issues/235 +[#781]: https://github.com/yannickcr/eslint-plugin-react/pull/781 +[#716]: https://github.com/yannickcr/eslint-plugin-react/issues/716 +[#784]: https://github.com/yannickcr/eslint-plugin-react/issues/784 +[#735]: https://github.com/yannickcr/eslint-plugin-react/issues/735 + ## [6.1.2] - 2016-08-17 ### Fixed * Fix nested spread handling in `no-danger-with-children` ([#771][] @petersendidit) diff --git a/docs/rules/sort-prop-types.md b/docs/rules/sort-prop-types.md index c665328e52..ccc1c74ae5 100644 --- a/docs/rules/sort-prop-types.md +++ b/docs/rules/sort-prop-types.md @@ -80,6 +80,7 @@ class Component extends React.Component { "callbacksLast": , "ignoreCase": , "requiredFirst": , + "noSortAlphabetically": , }] ... ``` @@ -120,6 +121,21 @@ var Component = React.createClass({ }); ``` +### `noSortAlphabetically` + +When `true`, prop types will not be sorted alphabetically + +```js +var Component = React.createClass({ + propTypes: { + b: React.PropTypes.bool, + a: React.PropTypes.number, + z: React.PropTypes.string, + }, +... +}); +``` + ## When not to use This rule is a formatting preference and not following it won't negatively affect the quality of your code. If alphabetizing props declarations isn't a part of your coding standards, then you can leave this rule off. diff --git a/lib/rules/sort-prop-types.js b/lib/rules/sort-prop-types.js index b3c04f5482..db32fc8891 100644 --- a/lib/rules/sort-prop-types.js +++ b/lib/rules/sort-prop-types.js @@ -26,6 +26,9 @@ module.exports = { }, ignoreCase: { type: 'boolean' + }, + noSortAlphabetically: { + type: 'boolean' } }, additionalProperties: false @@ -39,6 +42,7 @@ module.exports = { var requiredFirst = configuration.requiredFirst || false; var callbacksLast = configuration.callbacksLast || false; var ignoreCase = configuration.ignoreCase || false; + var noSortAlphabetically = configuration.noSortAlphabetically || false; /** * Checks if node is `propTypes` declaration @@ -130,12 +134,14 @@ module.exports = { } } - if (currentPropName < prevPropName) { - context.report({ - node: curr, - message: 'Prop types declarations should be sorted alphabetically' - }); - return prev; + if (!noSortAlphabetically) { + if (currentPropName < prevPropName) { + context.report({ + node: curr, + message: 'Prop types declarations should be sorted alphabetically' + }); + return prev; + } } return curr; diff --git a/package.json b/package.json index 14bda149bf..2062dd76cc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-react", - "version": "6.1.2", + "version": "6.2.0", "author": "Yannick Croissant ", "description": "React specific linting rules for ESLint", "main": "index.js", diff --git a/tests/lib/rules/sort-prop-types.js b/tests/lib/rules/sort-prop-types.js index d18b8aa144..b5937e366e 100644 --- a/tests/lib/rules/sort-prop-types.js +++ b/tests/lib/rules/sort-prop-types.js @@ -323,6 +323,53 @@ ruleTester.run('sort-prop-types', rule, { '}' ].join('\n'), parser: 'babel-eslint' + }, { + code: [ + 'export default class ClassWithSpreadInPropTypes extends BaseClass {', + ' static propTypes = {', + ' z: PropTypes.string,', + ' b: PropTypes.func,', + ' a: PropTypes.string,', + ' }', + '}' + ].join('\n'), + options: [{ + noSortAlphabetically: true + }], + parser: 'babel-eslint' + }, { + code: [ + 'export default class ClassWithSpreadInPropTypes extends BaseClass {', + ' static propTypes = {', + ' z: PropTypes.string.isRequired,', + ' b: PropTypes.func,', + ' a: PropTypes.string,', + ' }', + '}' + ].join('\n'), + options: [{ + noSortAlphabetically: true, + requiredFirst: true + }], + parser: 'babel-eslint' + }, { + code: [ + 'export default class ClassWithSpreadInPropTypes extends BaseClass {', + ' static propTypes = {', + ' l: PropTypes.bool.isRequired,', + ' k: PropTypes.string.isRequired,', + ' g: PropTypes.string,', + ' b: PropTypes.bool,', + ' a: PropTypes.func,', + ' }', + '}' + ].join('\n'), + options: [{ + noSortAlphabetically: true, + requiredFirst: true, + callbacksLast: true + }], + parser: 'babel-eslint' }], invalid: [{