Skip to content

Commit

Permalink
[Fix] sort-prop-types, jsx-sort-default-props: disable broken aut…
Browse files Browse the repository at this point in the history
…ofix

See #1940.
  • Loading branch information
Roy Sutton authored and ljharb committed Nov 23, 2019
1 parent 8093565 commit 78d2ab6
Show file tree
Hide file tree
Showing 6 changed files with 789 additions and 717 deletions.
2 changes: 0 additions & 2 deletions docs/rules/jsx-sort-default-props.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 0 additions & 3 deletions docs/rules/sort-prop-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

Some developers prefer to sort propTypes declarations alphabetically to be able to find necessary declaration easier at the later time. Others feel that it adds complexity and becomes 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 propTypes declarations are sorted alphabetically. A spread attribute resets the verification. The default configuration of the rule is case-sensitive.
Expand Down
14 changes: 7 additions & 7 deletions lib/rules/jsx-sort-default-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,7 +23,7 @@ module.exports = {
url: docsUrl('jsx-sort-default-props')
},

fixable: 'code',
// fixable: 'code',

schema: [{
type: 'object',
Expand Down Expand Up @@ -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)) {
Expand All @@ -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;
Expand Down
38 changes: 19 additions & 19 deletions lib/rules/sort-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const variableUtil = require('../util/variable');
const propsUtil = require('../util/props');
const docsUrl = require('../util/docsUrl');
const propWrapperUtil = require('../util/propWrapper');
const propTypesSortUtil = require('../util/propTypesSort');
// const propTypesSortUtil = require('../util/propTypesSort');

// ------------------------------------------------------------------------------
// Rule Definition
Expand All @@ -23,7 +23,7 @@ module.exports = {
url: docsUrl('sort-prop-types')
},

fixable: 'code',
// fixable: 'code',

schema: [{
type: 'object',
Expand Down Expand Up @@ -98,17 +98,17 @@ module.exports = {
return;
}

function fix(fixer) {
return propTypesSortUtil.fixPropTypesSort(
fixer,
context,
declarations,
ignoreCase,
requiredFirst,
callbacksLast,
sortShapeProp
);
}
// function fix(fixer) {
// return propTypesSortUtil.fixPropTypesSort(
// fixer,
// context,
// declarations,
// ignoreCase,
// requiredFirst,
// callbacksLast,
// sortShapeProp
// );
// }

declarations.reduce((prev, curr, idx, decls) => {
if (curr.type === 'ExperimentalSpreadProperty' || curr.type === 'SpreadElement') {
Expand Down Expand Up @@ -136,8 +136,8 @@ module.exports = {
// Encountered a non-required prop after a required prop
context.report({
node: curr,
message: 'Required prop types must be listed before all other prop types',
fix
message: 'Required prop types must be listed before all other prop types'
// fix
});
return curr;
}
Expand All @@ -152,8 +152,8 @@ module.exports = {
// Encountered a non-callback prop after a callback prop
context.report({
node: prev,
message: 'Callback prop types must be listed after all other prop types',
fix
message: 'Callback prop types must be listed after all other prop types'
// fix
});
return prev;
}
Expand All @@ -162,8 +162,8 @@ module.exports = {
if (!noSortAlphabetically && currentPropName < prevPropName) {
context.report({
node: curr,
message: 'Prop types declarations should be sorted alphabetically',
fix
message: 'Prop types declarations should be sorted alphabetically'
// fix
});
return prev;
}
Expand Down
Loading

0 comments on commit 78d2ab6

Please sign in to comment.