Skip to content

Commit

Permalink
revert OtherClass.getDefaultProps() -> OtherClass.defaultProps (faceb…
Browse files Browse the repository at this point in the history
  • Loading branch information
keyz authored Jul 8, 2016
1 parent e331df0 commit 228489a
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 79 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ jscodeshift -t react-codemod/transforms/sort-comp.js <path>
- Add `return;` after the assignment when the return statement is part of a control flow statement (not a direct child of `getInitialState()`'s body) and not in an inner function declaration
4. Transform all non-lifecycle methods and fields to class property initializers (like `onClick = () => {};`). All your Flow annotations will be preserved
- It's actually not necessary to transform all methods to arrow functions (i.e., to bind them), but this behavior is the same as `createClass()` and we can make sure that we won't accidentally break stuff
5. Rewrite `AnotherClass.getDefaultProps()` to `AnotherClass.defaultProps`
4. Generate Flow annotations from `propTypes` and put it on the class (this only happens when there's `/* @flow */` in your code and `options['flow']` is `true`)
- Flow actually understands `propTypes` in `createClass` calls but not ES6 class components. Here the transformation logic is identical to [how](https://github.com/facebook/flow/blob/master/src/typing/statement.ml#L3526) Flow treats `propTypes`
- Notice that Flow treats an optional propType as non-nullable
Expand Down
27 changes: 0 additions & 27 deletions transforms/__testfixtures__/class-access-default-props1.input.js

This file was deleted.

29 changes: 0 additions & 29 deletions transforms/__testfixtures__/class-access-default-props1.output.js

This file was deleted.

4 changes: 0 additions & 4 deletions transforms/__tests__/class-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ defineTest(__dirname, 'class', {
...pureMixinAlternativeOption,
...enableFlowOption,
}, 'class-top-comment');
defineTest(__dirname, 'class', {
...pureMixinAlternativeOption,
...enableFlowOption,
}, 'class-access-default-props1');
defineTest(__dirname, 'class', enableFlowOption, 'class-initial-state');
defineTest(__dirname, 'class', enableFlowOption, 'class-property-field');
defineTest(__dirname, 'class', enableFlowOption, 'class-flow1');
Expand Down
18 changes: 0 additions & 18 deletions transforms/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -1029,22 +1029,6 @@ module.exports = (file, api, options) => {
);
});

// convert `OtherClass.getDefaultProps()` to `OtherClass.defaultProps`
const updateOtherDefaultPropsAccess = (classPath) => {
j(classPath)
.find(j.CallExpression, {
callee: {
type: 'MemberExpression',
property: { name: 'getDefaultProps' },
},
})
.forEach(path => j(path).replaceWith(
j.memberExpression(
path.value.callee.object,
j.identifier('defaultProps')
)));
};

const updateToClass = (classPath) => {
const specPath = ReactUtils.directlyGetCreateClassSpec(classPath);
const name = ReactUtils.directlyGetComponentName(classPath);
Expand Down Expand Up @@ -1088,8 +1072,6 @@ module.exports = (file, api, options) => {
comments
)
);

updateOtherDefaultPropsAccess(path);
};

if (
Expand Down

0 comments on commit 228489a

Please sign in to comment.