Skip to content

Commit 1fa28a8

Browse files
author
Roy Sutton
committed
Comment out tests, add failing tests
1 parent 7b5c352 commit 1fa28a8

File tree

3 files changed

+551
-0
lines changed

3 files changed

+551
-0
lines changed

lib/rules/sort-prop-types.js

+18
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const variableUtil = require('../util/variable');
88
const propsUtil = require('../util/props');
99
const docsUrl = require('../util/docsUrl');
1010
const propWrapperUtil = require('../util/propWrapper');
11+
// const propTypesSortUtil = require('../util/propTypesSort');
1112

1213
// ------------------------------------------------------------------------------
1314
// Rule Definition
@@ -22,6 +23,8 @@ module.exports = {
2223
url: docsUrl('sort-prop-types')
2324
},
2425

26+
// fixable: 'code',
27+
2528
schema: [{
2629
type: 'object',
2730
properties: {
@@ -95,6 +98,18 @@ module.exports = {
9598
return;
9699
}
97100

101+
// function fix(fixer) {
102+
// return propTypesSortUtil.fixPropTypesSort(
103+
// fixer,
104+
// context,
105+
// declarations,
106+
// ignoreCase,
107+
// requiredFirst,
108+
// callbacksLast,
109+
// sortShapeProp
110+
// );
111+
// }
112+
98113
declarations.reduce((prev, curr, idx, decls) => {
99114
if (curr.type === 'ExperimentalSpreadProperty' || curr.type === 'SpreadElement') {
100115
return decls[idx + 1];
@@ -122,6 +137,7 @@ module.exports = {
122137
context.report({
123138
node: curr,
124139
message: 'Required prop types must be listed before all other prop types'
140+
// fix
125141
});
126142
return curr;
127143
}
@@ -137,6 +153,7 @@ module.exports = {
137153
context.report({
138154
node: prev,
139155
message: 'Callback prop types must be listed after all other prop types'
156+
// fix
140157
});
141158
return prev;
142159
}
@@ -146,6 +163,7 @@ module.exports = {
146163
context.report({
147164
node: curr,
148165
message: 'Prop types declarations should be sorted alphabetically'
166+
// fix
149167
});
150168
return prev;
151169
}

tests/lib/rules/jsx-sort-default-props.js

+43
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,49 @@ ruleTester.run('jsx-sort-default-props', rule, {
622622
'};'
623623
].join('\n')
624624
}, {
625+
// Disabled test for comments -- fails
626+
// code: [
627+
// 'class Hello extends React.Component {',
628+
// ' render() {',
629+
// ' return <div>Hello</div>;',
630+
// ' }',
631+
// '}',
632+
// 'Hello.propTypes = {',
633+
// ' "a": PropTypes.string,',
634+
// ' "B": PropTypes.string,',
635+
// '};',
636+
// 'Hello.defaultProps = {',
637+
// ' /* a */',
638+
// ' "a": "a",',
639+
// ' /* B */',
640+
// ' "B": "B",',
641+
// '};'
642+
// ].join('\n'),
643+
// parser: parsers.BABEL_ESLINT,
644+
// errors: [{
645+
// message: ERROR_MESSAGE,
646+
// line: 14,
647+
// column: 3,
648+
// type: 'Property'
649+
// }],
650+
// output: [
651+
// 'class Hello extends React.Component {',
652+
// ' render() {',
653+
// ' return <div>Hello</div>;',
654+
// ' }',
655+
// '}',
656+
// 'Hello.propTypes = {',
657+
// ' "a": PropTypes.string,',
658+
// ' "B": PropTypes.string,',
659+
// '};',
660+
// 'Hello.defaultProps = {',
661+
// ' /* B */',
662+
// ' "B": "B",',
663+
// ' /* a */',
664+
// ' "a": "a",',
665+
// '};'
666+
// ].join('\n')
667+
// }, {
625668
code: [
626669
'class Hello extends React.Component {',
627670
' render() {',

0 commit comments

Comments
 (0)