Skip to content

Commit

Permalink
[Fix] sort-prop-types Passed all test cases typo fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ROSSROSALES committed Oct 7, 2022
1 parent 1a5a9e2 commit eb26aff
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 23 deletions.
2 changes: 2 additions & 0 deletions docs/rules/sort-prop-types.md
Expand Up @@ -2,6 +2,8 @@

💼 This rule is enabled in the following [configs](https://github.com/jsx-eslint/eslint-plugin-react#shareable-configurations): `all`.

🔧 This rule is automatically fixable using the `--fix` [flag](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) on the command line.

Some developers prefer to sort prop type 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.

## Rule Details
Expand Down
34 changes: 17 additions & 17 deletions lib/rules/sort-prop-types.js
Expand Up @@ -8,13 +8,13 @@ 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');
const report = require('../util/report');

// ------------------------------------------------------------------------------
// Rule Definition
// ------------------------------------------------------------------------------

const messages = {
requiredPropsFirst: 'Required prop types must be listed before all other prop types',
callbackPropsLast: 'Callback prop types must be listed after all other prop types',
Expand All @@ -29,7 +29,7 @@ module.exports = {
recommended: false,
url: docsUrl('sort-prop-types'),
},
// fixable: 'code',
fixable: 'code',

messages,

Expand Down Expand Up @@ -106,17 +106,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
);
}

const callbackPropsLastSeen = new WeakSet();
const requiredPropsFirstSeen = new WeakSet();
Expand Down Expand Up @@ -150,7 +150,7 @@ module.exports = {
requiredPropsFirstSeen.add(curr);
report(context, messages.requiredPropsFirst, 'requiredPropsFirst', {
node: curr,
// fix
fix
});
}
return curr;
Expand All @@ -168,7 +168,7 @@ module.exports = {
callbackPropsLastSeen.add(prev);
report(context, messages.callbackPropsLast, 'callbackPropsLast', {
node: prev,
// fix
fix
});
}
return prev;
Expand All @@ -180,7 +180,7 @@ module.exports = {
propsNotSortedSeen.add(curr);
report(context, messages.propsNotSorted, 'propsNotSorted', {
node: curr,
// fix
fix
});
}
return prev;
Expand Down
7 changes: 1 addition & 6 deletions tests/lib/rules/sort-prop-types.js
Expand Up @@ -468,11 +468,6 @@ ruleTester.run('sort-prop-types', rule, {
options: [{ sortShapeProp: true }],
}
)),
//
//
//
//

invalid: parsers.all([].concat(
{
code: `
Expand Down Expand Up @@ -1890,6 +1885,6 @@ ruleTester.run('sort-prop-types', rule, {
line: 4,
},
],
},
}
)),
});

0 comments on commit eb26aff

Please sign in to comment.