Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[react-codemod] --no* options automatically set to false #4866

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/react-codemod/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ are using the master version (>0.13.1) of React as it is using
`class` transforms `React.createClass` calls into ES2015 classes.

* `jscodeshift -t react/packages/react-codemod/transforms/class.js <file>`
* If `--no-super-class=true` is specified it will not extend
* If `--no-super-class` is specified it will not extend
`React.Component` if `setState` and `forceUpdate` aren't being called in a
class. We do recommend always extending from `React.Component`, especially
if you are using or planning to use [Flow](http://flowtype.org/). Also make
sure you are not calling `setState` anywhere outside of your component.

These three scripts take an option `--no-explicit-require=true` if you don't have a
These three scripts take an option `--no-explicit-require` if you don't have a
`require('React')` statement in your code files and if you access React as a
global.

Expand Down Expand Up @@ -87,7 +87,7 @@ systems.
* Creates a constructor if necessary. This is necessary if either
`getInitialState` exists in the `React.createClass` spec OR if functions
need to be bound to the instance.
* When `--no-super-class=true` is passed it only optionally extends
* When `--no-super-class` is passed it only optionally extends
`React.Component` when `setState` or `forceUpdate` are used within the
class.

Expand Down
2 changes: 1 addition & 1 deletion packages/react-codemod/test/__tests__/transform-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('Transform Tests', () => {
test('class', 'class-test');

test('class', 'class-test2', {
'no-super-class': true,
'super-class': false
});

test('class', 'class-test3');
Expand Down
4 changes: 2 additions & 2 deletions packages/react-codemod/transforms/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ module.exports = (file, api, options) => {
};

if (
options['no-explicit-require'] || ReactUtils.hasReact(root)
!options['explicit-require'] || ReactUtils.hasReact(root)
) {
const apply = (path, type) =>
path
Expand All @@ -531,7 +531,7 @@ module.exports = (file, api, options) => {
.filter(canConvertToClass)
.forEach(classPath => updateToClass(
classPath,
!options['no-super-class'],
!options['super-class'],
type
));

Expand Down
2 changes: 1 addition & 1 deletion packages/react-codemod/transforms/findDOMNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function getDOMNodeToFindDOMNode(file, api, options) {
};

if (
options['no-explicit-require'] ||
!options['explicit-require'] ||
ReactUtils.hasReact(root)
) {
const didTransform = ReactUtils
Expand Down
2 changes: 1 addition & 1 deletion packages/react-codemod/transforms/pure-render-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function removePureRenderMixin(file, api, options) {
};

if (
options['no-explicit-require'] ||
!options['explicit-require'] ||
ReactUtils.hasReact(root)
) {
const didTransform = ReactUtils
Expand Down