Skip to content

Commit

Permalink
Comment out tests, add failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Roy Sutton committed Nov 25, 2019
1 parent 7b5c352 commit 1fa28a8
Show file tree
Hide file tree
Showing 3 changed files with 551 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/rules/sort-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +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');

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

// fixable: 'code',

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

// 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') {
return decls[idx + 1];
Expand Down Expand Up @@ -122,6 +137,7 @@ module.exports = {
context.report({
node: curr,
message: 'Required prop types must be listed before all other prop types'
// fix
});
return curr;
}
Expand All @@ -137,6 +153,7 @@ module.exports = {
context.report({
node: prev,
message: 'Callback prop types must be listed after all other prop types'
// fix
});
return prev;
}
Expand All @@ -146,6 +163,7 @@ module.exports = {
context.report({
node: curr,
message: 'Prop types declarations should be sorted alphabetically'
// fix
});
return prev;
}
Expand Down
43 changes: 43 additions & 0 deletions tests/lib/rules/jsx-sort-default-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,49 @@ ruleTester.run('jsx-sort-default-props', rule, {
'};'
].join('\n')
}, {
// Disabled test for comments -- fails
// code: [
// 'class Hello extends React.Component {',
// ' render() {',
// ' return <div>Hello</div>;',
// ' }',
// '}',
// 'Hello.propTypes = {',
// ' "a": PropTypes.string,',
// ' "B": PropTypes.string,',
// '};',
// 'Hello.defaultProps = {',
// ' /* a */',
// ' "a": "a",',
// ' /* B */',
// ' "B": "B",',
// '};'
// ].join('\n'),
// parser: parsers.BABEL_ESLINT,
// errors: [{
// message: ERROR_MESSAGE,
// line: 14,
// column: 3,
// type: 'Property'
// }],
// output: [
// 'class Hello extends React.Component {',
// ' render() {',
// ' return <div>Hello</div>;',
// ' }',
// '}',
// 'Hello.propTypes = {',
// ' "a": PropTypes.string,',
// ' "B": PropTypes.string,',
// '};',
// 'Hello.defaultProps = {',
// ' /* B */',
// ' "B": "B",',
// ' /* a */',
// ' "a": "a",',
// '};'
// ].join('\n')
// }, {
code: [
'class Hello extends React.Component {',
' render() {',
Expand Down
Loading

0 comments on commit 1fa28a8

Please sign in to comment.