Skip to content

Commit

Permalink
Renamed unsafe_ prefix to UNSAFE_ to make it more noticeable
Browse files Browse the repository at this point in the history
  • Loading branch information
bvaughn committed Jan 17, 2018
1 parent d05f7fb commit 312fce5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jscodeshift -t react-codemod/transforms/React-PropTypes-to-prop-types.js <path>

#### `rename-unsafe-lifecycles`

Adds "unsafe_" prefix for deprecated lifecycle hooks. (For more information about this codemod, see [React RFC #6](https://github.com/reactjs/rfcs/pull/6))
Adds "UNSAFE_" prefix for deprecated lifecycle hooks. (For more information about this codemod, see [React RFC #6](https://github.com/reactjs/rfcs/pull/6))

```sh
jscodeshift -t react-codemod/transforms/rename-unsafe-lifecycles.js <path>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const React = require('React');

class Component extends React.Component {
unsafe_componentWillMount = logger('componentWillMount');
UNSAFE_componentWillMount = logger('componentWillMount');
componentDidMount = logger('componentDidMount');
unsafe_componentWillReceiveProps = logger('componentWillReceiveProps');
UNSAFE_componentWillReceiveProps = logger('componentWillReceiveProps');
shouldComponentUpdate = logger('shouldComponentUpdate');
unsafe_componentWillUpdate = logger('componentWillUpdate');
UNSAFE_componentWillUpdate = logger('componentWillUpdate');
componentDidUpdate = logger('componentDidUpdate');
componentWillUnmount = logger('componentWillUnmount');
render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,39 @@ const MyComponent = createReactClass({
displayName: 'MyComponent',
mixins: [
{
unsafe_componentWillMount() {
UNSAFE_componentWillMount() {
// componentWillMount
},
componentDidMount() {
// componentDidMount
},
unsafe_componentWillUpdate(nextProps, nextState) {
UNSAFE_componentWillUpdate(nextProps, nextState) {
// componentWillUpdate
},
componentDidUpdate(prevProps, prevState) {
// componentDidUpdate
},
unsafe_componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
// componentWillReceiveProps
},
componentWillUnmount() {
// componentWillUnmount
},
},
],
unsafe_componentWillMount() {
UNSAFE_componentWillMount() {
// componentWillMount
},
componentDidMount() {
// componentDidMount
},
unsafe_componentWillUpdate(nextProps, nextState) {
UNSAFE_componentWillUpdate(nextProps, nextState) {
// componentWillUpdate
},
componentDidUpdate(prevProps, prevState) {
// componentDidUpdate
},
unsafe_componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
// componentWillReceiveProps
},
componentWillUnmount() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
const React = require('React');

class ClassComponent extends React.Component {
unsafe_componentWillMount() {
UNSAFE_componentWillMount() {
// componentWillMount
}
componentDidMount() {
// componentDidMount
}
unsafe_componentWillUpdate(nextProps, nextState) {
UNSAFE_componentWillUpdate(nextProps, nextState) {
// componentWillUpdate
}
componentDidUpdate(prevProps, prevState) {
// componentDidUpdate
}
unsafe_componentWillReceiveProps(nextProps) {
UNSAFE_componentWillReceiveProps(nextProps) {
// componentWillReceiveProps
}
componentWillUnmount() {
Expand Down
6 changes: 3 additions & 3 deletions transforms/rename-unsafe-lifecycles.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
'use strict';

const DEPRECATED_APIS = Object.create(null);
DEPRECATED_APIS.componentWillMount = 'unsafe_componentWillMount';
DEPRECATED_APIS.componentWillReceiveProps = 'unsafe_componentWillReceiveProps';
DEPRECATED_APIS.componentWillUpdate = 'unsafe_componentWillUpdate';
DEPRECATED_APIS.componentWillMount = 'UNSAFE_componentWillMount';
DEPRECATED_APIS.componentWillReceiveProps = 'UNSAFE_componentWillReceiveProps';
DEPRECATED_APIS.componentWillUpdate = 'UNSAFE_componentWillUpdate';

export default (file, api, options) => {
const j = api.jscodeshift;
Expand Down

0 comments on commit 312fce5

Please sign in to comment.