Skip to content

Commit

Permalink
[eslint] enforce no-string-refs
Browse files Browse the repository at this point in the history
For #3436
  • Loading branch information
oliviertassinari committed Jul 24, 2016
1 parent a2a9ddb commit a998653
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Expand Up @@ -47,6 +47,8 @@ module.exports = {
'react/jsx-no-duplicate-props': 'error',
'react/no-danger': 'error',
'react/no-direct-mutation-state': 'error',
'react/no-set-state': 'off',
'react/no-string-refs': 'error',
'react/prefer-stateless-function': 'off', // wishlist, one day
'react/sort-comp': [2, {
order: [
Expand All @@ -60,7 +62,6 @@ module.exports = {
'render'
],
}],
'react/no-set-state': 'off',
'material-ui/docgen-ignore-before-comment': 'error',
'mocha/handle-done-callback': 'error',
'mocha/no-exclusive-tests': 'error',
Expand Down
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -31,6 +31,7 @@
"clean:build": "rimraf build",
"docs:start": "(cd docs/site; npm start)",
"lint": "eslint src docs/site/src test/integration && echo \"eslint: no lint errors\"",
"lint:find-rules": "eslint-find-rules -u .eslintrc.js",
"prebuild": "npm run clean:build",
"test": "cross-env NODE_ENV=test babel-node test/index.js",
"test:watch": "cross-env NODE_ENV=test babel-node test/watch.js",
Expand Down Expand Up @@ -88,6 +89,7 @@
"enzyme": "^2.2.0",
"eslint": "^2.13.1",
"eslint-config-airbnb": "^9.0.1",
"eslint-find-rules": "^1.11.1",
"eslint-plugin-babel": "^3.2.0",
"eslint-plugin-flowtype": "^2.3.1",
"eslint-plugin-import": "^1.10.3",
Expand Down
10 changes: 7 additions & 3 deletions src/internal/Transition.js
Expand Up @@ -273,8 +273,12 @@ class Transition extends Component {
return null;
}

const { children, className, ...childProps } = this.props;
Object.keys(Transition.propTypes).forEach((key) => delete childProps[key]);
const {
children,
className,
...other,
} = this.props;
Object.keys(Transition.propTypes).forEach((key) => delete other[key]);

let transitionClassName;
if (status === EXITED) {
Expand All @@ -291,7 +295,7 @@ class Transition extends Component {
return React.cloneElement(
child,
{
...childProps,
...other,
className: ClassNames(
child.props.className,
className,
Expand Down
10 changes: 8 additions & 2 deletions src/internal/Transition.spec.js
Expand Up @@ -252,8 +252,10 @@ describe('<Transition>', () => {
});
}

transition = null;

getStatus() {
return this.refs.transition.state.status;
return this.transition.state.status;
}

render() {
Expand All @@ -264,7 +266,11 @@ describe('<Transition>', () => {

return (
<Transition
ref="transition"
ref={(c) => {
if (c !== null) {
this.transition = c;
}
}}
unmountOnExit
in={this.state.in}
timeout={10}
Expand Down

0 comments on commit a998653

Please sign in to comment.