diff --git a/docs/rules/jsx-sort-default-props.md b/docs/rules/jsx-sort-default-props.md
index 251726b9c2..d4b48f8181 100644
--- a/docs/rules/jsx-sort-default-props.md
+++ b/docs/rules/jsx-sort-default-props.md
@@ -2,8 +2,6 @@
Some developers prefer to sort `defaultProps` declarations alphabetically to be able to find necessary declarations easier at a later time. Others feel that it adds complexity and becomes a burden to maintain.
-**Fixable:** This rule is automatically fixable using the `--fix` flag on the command line.
-
## Rule Details
This rule checks all components and verifies that all `defaultProps` declarations are sorted alphabetically. A spread attribute resets the verification. The default configuration of the rule is case-sensitive.
diff --git a/lib/rules/jsx-sort-default-props.js b/lib/rules/jsx-sort-default-props.js
index 76b881c161..88f230ae6d 100644
--- a/lib/rules/jsx-sort-default-props.js
+++ b/lib/rules/jsx-sort-default-props.js
@@ -8,7 +8,7 @@
const variableUtil = require('../util/variable');
const docsUrl = require('../util/docsUrl');
const propWrapperUtil = require('../util/propWrapper');
-const propTypesSortUtil = require('../util/propTypesSort');
+// const propTypesSortUtil = require('../util/propTypesSort');
// ------------------------------------------------------------------------------
// Rule Definition
@@ -23,7 +23,7 @@ module.exports = {
url: docsUrl('jsx-sort-default-props')
},
- fixable: 'code',
+ // fixable: 'code',
schema: [{
type: 'object',
@@ -100,9 +100,9 @@ module.exports = {
* @returns {void}
*/
function checkSorted(declarations) {
- function fix(fixer) {
- return propTypesSortUtil.fixPropTypesSort(fixer, context, declarations, ignoreCase);
- }
+ // function fix(fixer) {
+ // return propTypesSortUtil.fixPropTypesSort(fixer, context, declarations, ignoreCase);
+ // }
declarations.reduce((prev, curr, idx, decls) => {
if (/Spread(?:Property|Element)$/.test(curr.type)) {
@@ -120,8 +120,8 @@ module.exports = {
if (currentPropName < prevPropName) {
context.report({
node: curr,
- message: 'Default prop types declarations should be sorted alphabetically',
- fix
+ message: 'Default prop types declarations should be sorted alphabetically'
+ // fix
});
return prev;
diff --git a/tests/lib/rules/jsx-sort-default-props.js b/tests/lib/rules/jsx-sort-default-props.js
index 550307c265..6a07cde0d0 100644
--- a/tests/lib/rules/jsx-sort-default-props.js
+++ b/tests/lib/rules/jsx-sort-default-props.js
@@ -374,24 +374,24 @@ ruleTester.run('jsx-sort-default-props', rule, {
line: 10,
column: 5,
type: 'Property'
- }],
- output: [
- 'class Component extends React.Component {',
- ' static propTypes = {',
- ' a: PropTypes.any,',
- ' b: PropTypes.any,',
- ' c: PropTypes.any',
- ' };',
- ' static defaultProps = {',
- ' a: "a",',
- ' b: "b",',
- ' c: "c"',
- ' };',
- ' render() {',
- ' return
;',
- ' }',
- '}'
- ].join('\n')
+ }]
+ // output: [
+ // 'class Component extends React.Component {',
+ // ' static propTypes = {',
+ // ' a: PropTypes.any,',
+ // ' b: PropTypes.any,',
+ // ' c: PropTypes.any',
+ // ' };',
+ // ' static defaultProps = {',
+ // ' a: "a",',
+ // ' b: "b",',
+ // ' c: "c"',
+ // ' };',
+ // ' render() {',
+ // ' return ;',
+ // ' }',
+ // '}'
+ // ].join('\n')
}, {
code: [
'class Component extends React.Component {',
@@ -411,24 +411,24 @@ ruleTester.run('jsx-sort-default-props', rule, {
'}'
].join('\n'),
parser: parsers.BABEL_ESLINT,
- errors: 2,
- output: [
- 'class Component extends React.Component {',
- ' static propTypes = {',
- ' a: PropTypes.any,',
- ' b: PropTypes.any,',
- ' c: PropTypes.any',
- ' };',
- ' static defaultProps = {',
- ' a: "a",',
- ' b: "b",',
- ' c: "c"',
- ' };',
- ' render() {',
- ' return ;',
- ' }',
- '}'
- ].join('\n')
+ errors: 2
+ // output: [
+ // 'class Component extends React.Component {',
+ // ' static propTypes = {',
+ // ' a: PropTypes.any,',
+ // ' b: PropTypes.any,',
+ // ' c: PropTypes.any',
+ // ' };',
+ // ' static defaultProps = {',
+ // ' a: "a",',
+ // ' b: "b",',
+ // ' c: "c"',
+ // ' };',
+ // ' render() {',
+ // ' return ;',
+ // ' }',
+ // '}'
+ // ].join('\n')
}, {
code: [
'class Component extends React.Component {',
@@ -454,22 +454,22 @@ ruleTester.run('jsx-sort-default-props', rule, {
line: 8,
column: 5,
type: 'Property'
- }],
- output: [
- 'class Component extends React.Component {',
- ' static propTypes = {',
- ' a: PropTypes.any,',
- ' b: PropTypes.any',
- ' };',
- ' static defaultProps = {',
- ' a: "a",',
- ' Z: "Z",',
- ' };',
- ' render() {',
- ' return ;',
- ' }',
- '}'
- ].join('\n')
+ }]
+ // output: [
+ // 'class Component extends React.Component {',
+ // ' static propTypes = {',
+ // ' a: PropTypes.any,',
+ // ' b: PropTypes.any',
+ // ' };',
+ // ' static defaultProps = {',
+ // ' a: "a",',
+ // ' Z: "Z",',
+ // ' };',
+ // ' render() {',
+ // ' return ;',
+ // ' }',
+ // '}'
+ // ].join('\n')
}, {
code: [
'class Component extends React.Component {',
@@ -492,22 +492,22 @@ ruleTester.run('jsx-sort-default-props', rule, {
line: 8,
column: 5,
type: 'Property'
- }],
- output: [
- 'class Component extends React.Component {',
- ' static propTypes = {',
- ' a: PropTypes.any,',
- ' z: PropTypes.any',
- ' };',
- ' static defaultProps = {',
- ' Z: "Z",',
- ' a: "a",',
- ' };',
- ' render() {',
- ' return ;',
- ' }',
- '}'
- ].join('\n')
+ }]
+ // output: [
+ // 'class Component extends React.Component {',
+ // ' static propTypes = {',
+ // ' a: PropTypes.any,',
+ // ' z: PropTypes.any',
+ // ' };',
+ // ' static defaultProps = {',
+ // ' Z: "Z",',
+ // ' a: "a",',
+ // ' };',
+ // ' render() {',
+ // ' return ;',
+ // ' }',
+ // '}'
+ // ].join('\n')
}, {
code: [
'class Hello extends React.Component {',
@@ -530,22 +530,22 @@ ruleTester.run('jsx-sort-default-props', rule, {
line: 12,
column: 3,
type: 'Property'
- }],
- output: [
- 'class Hello extends React.Component {',
- ' render() {',
- ' return Hello
;',
- ' }',
- '}',
- 'Hello.propTypes = {',
- ' "a": PropTypes.string,',
- ' "b": PropTypes.string',
- '};',
- 'Hello.defaultProps = {',
- ' "a": "a",',
- ' "b": "b"',
- '};'
- ].join('\n')
+ }]
+ // output: [
+ // 'class Hello extends React.Component {',
+ // ' render() {',
+ // ' return Hello
;',
+ // ' }',
+ // '}',
+ // 'Hello.propTypes = {',
+ // ' "a": PropTypes.string,',
+ // ' "b": PropTypes.string',
+ // '};',
+ // 'Hello.defaultProps = {',
+ // ' "a": "a",',
+ // ' "b": "b"',
+ // '};'
+ // ].join('\n')
}, {
code: [
'class Hello extends React.Component {',
@@ -565,24 +565,24 @@ ruleTester.run('jsx-sort-default-props', rule, {
'};'
].join('\n'),
parser: parsers.BABEL_ESLINT,
- errors: 2,
- output: [
- 'class Hello extends React.Component {',
- ' render() {',
- ' return Hello
;',
- ' }',
- '}',
- 'Hello.propTypes = {',
- ' "a": PropTypes.string,',
- ' "b": PropTypes.string,',
- ' "c": PropTypes.string',
- '};',
- 'Hello.defaultProps = {',
- ' "a": "a",',
- ' "b": "b",',
- ' "c": "c"',
- '};'
- ].join('\n')
+ errors: 2
+ // output: [
+ // 'class Hello extends React.Component {',
+ // ' render() {',
+ // ' return Hello
;',
+ // ' }',
+ // '}',
+ // 'Hello.propTypes = {',
+ // ' "a": PropTypes.string,',
+ // ' "b": PropTypes.string,',
+ // ' "c": PropTypes.string',
+ // '};',
+ // 'Hello.defaultProps = {',
+ // ' "a": "a",',
+ // ' "b": "b",',
+ // ' "c": "c"',
+ // '};'
+ // ].join('\n')
}, {
code: [
'class Hello extends React.Component {',
@@ -605,22 +605,22 @@ ruleTester.run('jsx-sort-default-props', rule, {
line: 12,
column: 3,
type: 'Property'
- }],
- output: [
- 'class Hello extends React.Component {',
- ' render() {',
- ' return Hello
;',
- ' }',
- '}',
- 'Hello.propTypes = {',
- ' "a": PropTypes.string,',
- ' "B": PropTypes.string,',
- '};',
- 'Hello.defaultProps = {',
- ' "B": "B",',
- ' "a": "a",',
- '};'
- ].join('\n')
+ }]
+ // output: [
+ // 'class Hello extends React.Component {',
+ // ' render() {',
+ // ' return Hello
;',
+ // ' }',
+ // '}',
+ // 'Hello.propTypes = {',
+ // ' "a": PropTypes.string,',
+ // ' "B": PropTypes.string,',
+ // '};',
+ // 'Hello.defaultProps = {',
+ // ' "B": "B",',
+ // ' "a": "a",',
+ // '};'
+ // ].join('\n')
}, {
// Disabled test for comments -- fails
// code: [
@@ -689,22 +689,22 @@ ruleTester.run('jsx-sort-default-props', rule, {
line: 12,
column: 3,
type: 'Property'
- }],
- output: [
- 'class Hello extends React.Component {',
- ' render() {',
- ' return Hello
;',
- ' }',
- '}',
- 'Hello.propTypes = {',
- ' "a": PropTypes.string,',
- ' "B": PropTypes.string,',
- '};',
- 'Hello.defaultProps = {',
- ' "a": "a",',
- ' "B": "B",',
- '};'
- ].join('\n')
+ }]
+ // output: [
+ // 'class Hello extends React.Component {',
+ // ' render() {',
+ // ' return Hello
;',
+ // ' }',
+ // '}',
+ // 'Hello.propTypes = {',
+ // ' "a": PropTypes.string,',
+ // ' "B": PropTypes.string,',
+ // '};',
+ // 'Hello.defaultProps = {',
+ // ' "a": "a",',
+ // ' "B": "B",',
+ // '};'
+ // ].join('\n')
}, {
code: [
'const First = (props) => ;',
@@ -724,20 +724,20 @@ ruleTester.run('jsx-sort-default-props', rule, {
line: 8,
column: 3,
type: 'Property'
- }],
- output: [
- 'const First = (props) => ;',
- 'const propTypes = {',
- ' z: PropTypes.string,',
- ' a: PropTypes.any,',
- '};',
- 'const defaultProps = {',
- ' a: "a",',
- ' z: "z",',
- '};',
- 'First.propTypes = propTypes;',
- 'First.defaultProps = defaultProps;'
- ].join('\n')
+ }]
+ // output: [
+ // 'const First = (props) => ;',
+ // 'const propTypes = {',
+ // ' z: PropTypes.string,',
+ // ' a: PropTypes.any,',
+ // '};',
+ // 'const defaultProps = {',
+ // ' a: "a",',
+ // ' z: "z",',
+ // '};',
+ // 'First.propTypes = propTypes;',
+ // 'First.defaultProps = defaultProps;'
+ // ].join('\n')
}, {
code: [
'export default class ClassWithSpreadInPropTypes extends BaseClass {',
@@ -759,21 +759,21 @@ ruleTester.run('jsx-sort-default-props', rule, {
line: 9,
column: 5,
type: 'Property'
- }],
- output: [
- 'export default class ClassWithSpreadInPropTypes extends BaseClass {',
- ' static propTypes = {',
- ' b: PropTypes.string,',
- ' ...c.propTypes,',
- ' a: PropTypes.string',
- ' }',
- ' static defaultProps = {',
- ' a: "a",',
- ' b: "b",',
- ' ...c.defaultProps',
- ' }',
- '}'
- ].join('\n')
+ }]
+ // output: [
+ // 'export default class ClassWithSpreadInPropTypes extends BaseClass {',
+ // ' static propTypes = {',
+ // ' b: PropTypes.string,',
+ // ' ...c.propTypes,',
+ // ' a: PropTypes.string',
+ // ' }',
+ // ' static defaultProps = {',
+ // ' a: "a",',
+ // ' b: "b",',
+ // ' ...c.defaultProps',
+ // ' }',
+ // '}'
+ // ].join('\n')
}, {
code: [
'export default class ClassWithSpreadInPropTypes extends BaseClass {',
@@ -796,27 +796,27 @@ ruleTester.run('jsx-sort-default-props', rule, {
'}'
].join('\n'),
parser: parsers.BABEL_ESLINT,
- errors: 2,
- output: [
- 'export default class ClassWithSpreadInPropTypes extends BaseClass {',
- ' static propTypes = {',
- ' a: PropTypes.string,',
- ' b: PropTypes.string,',
- ' c: PropTypes.string,',
- ' d: PropTypes.string,',
- ' e: PropTypes.string,',
- ' f: PropTypes.string',
- ' }',
- ' static defaultProps = {',
- ' a: "a",',
- ' b: "b",',
- ' ...c.defaultProps,',
- ' e: "e",',
- ' f: "f",',
- ' ...d.defaultProps',
- ' }',
- '}'
- ].join('\n')
+ errors: 2
+ // output: [
+ // 'export default class ClassWithSpreadInPropTypes extends BaseClass {',
+ // ' static propTypes = {',
+ // ' a: PropTypes.string,',
+ // ' b: PropTypes.string,',
+ // ' c: PropTypes.string,',
+ // ' d: PropTypes.string,',
+ // ' e: PropTypes.string,',
+ // ' f: PropTypes.string',
+ // ' }',
+ // ' static defaultProps = {',
+ // ' a: "a",',
+ // ' b: "b",',
+ // ' ...c.defaultProps,',
+ // ' e: "e",',
+ // ' f: "f",',
+ // ' ...d.defaultProps',
+ // ' }',
+ // '}'
+ // ].join('\n')
}, {
code: [
'const defaults = {',
@@ -843,25 +843,25 @@ ruleTester.run('jsx-sort-default-props', rule, {
line: 15,
column: 3,
type: 'Property'
- }],
- output: [
- 'const defaults = {',
- ' b: "b"',
- '};',
- 'const types = {',
- ' a: PropTypes.string,',
- ' b: PropTypes.string,',
- ' c: PropTypes.string',
- '};',
- 'function StatelessComponentWithSpreadInPropTypes({ a, b, c }) {',
- ' return {a}{b}{c}
;',
- '}',
- 'StatelessComponentWithSpreadInPropTypes.propTypes = types;',
- 'StatelessComponentWithSpreadInPropTypes.defaultProps = {',
- ' a: "a",',
- ' c: "c",',
- ' ...defaults,',
- '};'
- ].join('\n')
+ }]
+ // output: [
+ // 'const defaults = {',
+ // ' b: "b"',
+ // '};',
+ // 'const types = {',
+ // ' a: PropTypes.string,',
+ // ' b: PropTypes.string,',
+ // ' c: PropTypes.string',
+ // '};',
+ // 'function StatelessComponentWithSpreadInPropTypes({ a, b, c }) {',
+ // ' return {a}{b}{c}
;',
+ // '}',
+ // 'StatelessComponentWithSpreadInPropTypes.propTypes = types;',
+ // 'StatelessComponentWithSpreadInPropTypes.defaultProps = {',
+ // ' a: "a",',
+ // ' c: "c",',
+ // ' ...defaults,',
+ // '};'
+ // ].join('\n')
}]
});