Skip to content

Commit

Permalink
Update lint
Browse files Browse the repository at this point in the history
  • Loading branch information
xotahal committed Oct 29, 2018
1 parent 577414f commit 32ce96b
Show file tree
Hide file tree
Showing 16 changed files with 188 additions and 116 deletions.
63 changes: 63 additions & 0 deletions .eslintrc
@@ -0,0 +1,63 @@
{
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true,
"es6": true,
"jest": true
},
"parserOptions": {
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"extends": ["airbnb", "prettier"],
"plugins": ["import", "react", "prettier", "react-native"],
"rules": {
"react/prop-types": "off",
"coma-dangle": "always",
"curly": ["error", "all"],
"import/order": [
"error",
{
"groups": [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index"
]
}
],
"no-use-before-define": "off",
"prettier/prettier": "error",
"lines-between-class-members": ["error", "never"],
"react/jsx-wrap-multilines": [
"error",
{ "declaration": false, "assignment": false }
],
"react/jsx-one-expression-per-line": "off",
"react/default-props-match-prop-types": [
"error",
{ "allowRequiredDefaults": true }
],
"react/jsx-filename-extension": [
"error",
{ "extensions": [".js", ".jsx"] }
],
"react/require-default-props": "off"
},
"settings": {
"import/resolver": {
"babel-module": {
"root": ["./"],
"extensions": [".js", ".ios.js", ".android.js"],
"alias": {
"src": "./src"
}
}
}
}
}
4 changes: 4 additions & 0 deletions .prettierrc
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -2,7 +2,7 @@
export { default as SharedElement } from './src/SharedElement';
export { default as SharedElementRenderer } from './src/SharedElementRenderer';
// Attentions
export { default as Shake } from './src/Shake'
export { default as Shake } from './src/Shake';
// Available Animations
export { default as AnimatedNumber } from './src/AnimatedNumber';
export { default as AnimatedText } from './src/AnimatedText';
Expand Down
26 changes: 16 additions & 10 deletions package.json
Expand Up @@ -29,21 +29,27 @@
"url": "https://github.com/xotahal/react-native-motion/issues"
},
"homepage": "https://github.com/xotahal/react-native-motion",
"peerDependencies": {
"react": "*",
"react-native": "*"
},
"dependencies": {
"prop-types": "^15.5.10"
},
"devDependencies": {
"babel-core": "^6.25.0",
"babel-eslint": "8.2.2",
"babel-core": "^6.26.3",
"babel-eslint": "10.0.1",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react-native": "4.0.0",
"eslint": "4.19.0",
"eslint-config-airbnb": "16.1.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "6.0.3",
"eslint-plugin-react": "^7.1.0",
"react": "16.2.0",
"react-native": "0.52.0"
"babel-preset-react-native": "4.0.1",
"eslint": "5.8.0",
"eslint-config-airbnb": "17.1.0",
"eslint-config-prettier": "^3.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "6.1.2",
"eslint-plugin-prettier": "^3.0.0",
"eslint-plugin-react": "^7.11.1",
"eslint-plugin-react-native": "^3.5.0",
"prettier": "^1.14.3"
}
}
9 changes: 6 additions & 3 deletions src/AnimatedNumber.js
Expand Up @@ -3,7 +3,7 @@ import { Animated } from 'react-native';
import PropTypes from 'prop-types';

const propTypes = {
type: PropTypes.string,
type: PropTypes.string, // eslint-disable-line react/no-unused-prop-types
};
const defaultProps = {
type: 'timing',
Expand All @@ -23,7 +23,9 @@ class AnimatedNumber extends React.PureComponent {
};
}
componentWillReceiveProps(nextProps) {
if (this.props.value !== nextProps.value) {
const { value } = this.props;

if (value !== nextProps.value) {
this.move(nextProps);
}
}
Expand All @@ -34,8 +36,9 @@ class AnimatedNumber extends React.PureComponent {
};
move = props => {
const { value, style, type, ...rest } = props;
const { animatedValue } = this.state;

Animated[type](this.state.animatedValue, {
Animated[type](animatedValue, {
toValue: value,
...rest,
}).start();
Expand Down
12 changes: 8 additions & 4 deletions src/AnimatedText.js
Expand Up @@ -3,7 +3,8 @@ import { Animated } from 'react-native';
import PropTypes from 'prop-types';

const propTypes = {
type: PropTypes.string,
type: PropTypes.string, // eslint-disable-line react/no-unused-prop-types
duration: PropTypes.number, // eslint-disable-line react/no-unused-prop-types
};
const defaultProps = {
type: 'timing',
Expand All @@ -28,7 +29,9 @@ class AnimatedText extends React.PureComponent {
};
}
componentWillReceiveProps(nextProps) {
if (this.props.value !== nextProps.value) {
const { value } = this.props;

if (value !== nextProps.value) {
this.change(nextProps);
}
}
Expand All @@ -43,8 +46,9 @@ class AnimatedText extends React.PureComponent {
};
change = props => {
const { value, style, type, ...rest } = props;
const { animatedValue } = this.state;

Animated[type](this.state.animatedValue, {
Animated[type](animatedValue, {
toValue: 0,
...rest,
}).start(() => {
Expand All @@ -53,7 +57,7 @@ class AnimatedText extends React.PureComponent {
originLength: value.length,
});

Animated[type](this.state.animatedValue, {
Animated[type](animatedValue, {
toValue: 1,
...rest,
}).start();
Expand Down
12 changes: 8 additions & 4 deletions src/Opacity.js
@@ -1,5 +1,5 @@
import React, { PureComponent } from 'react';
import { Animated, InteractionManager } from 'react-native';
import { Animated } from 'react-native';
import PropTypes from 'prop-types';

const propTypes = {
Expand All @@ -20,23 +20,27 @@ class Opacity extends PureComponent {
};
}
componentWillReceiveProps(nextProps) {
if (this.props.value !== nextProps.value) {
const { value } = this.props;

if (value !== nextProps.value) {
this.move(nextProps);
}
}
move = props => {
const { value, style, type, ...rest } = props;
const { opacityValue } = this.state;

Animated[type](this.state.opacityValue, {
Animated[type](opacityValue, {
toValue: value,
...rest,
}).start();
};
render() {
const { style, children, ...rest } = this.props;
const { opacityValue } = this.state;

const animatedStyle = {
opacity: this.state.opacityValue,
opacity: opacityValue,
};

return (
Expand Down
12 changes: 8 additions & 4 deletions src/Scale.js
Expand Up @@ -3,9 +3,9 @@ import { Animated, InteractionManager } from 'react-native';
import PropTypes from 'prop-types';

const propTypes = {
type: PropTypes.string,
type: PropTypes.string, // eslint-disable-line react/no-unused-prop-types
animateOnDidMount: PropTypes.bool,
useNativeDriver: PropTypes.bool,
useNativeDriver: PropTypes.bool, // eslint-disable-line react/no-unused-prop-types
};
const defaultProps = {
type: 'timing',
Expand All @@ -24,14 +24,18 @@ class Scale extends PureComponent {
};
}
componentDidMount() {
if (this.props.animateOnDidMount) {
const { animateOnDidMount } = this.props;

if (animateOnDidMount) {
InteractionManager.runAfterInteractions().then(() => {
this.move(this.props);
});
}
}
componentWillReceiveProps(nextProps) {
if (this.props.value !== nextProps.value) {
const { value } = this.props;

if (value !== nextProps.value) {
this.move(nextProps);
}
}
Expand Down
16 changes: 10 additions & 6 deletions src/ScaleAndOpacity.js
Expand Up @@ -3,12 +3,12 @@ import { Animated, InteractionManager } from 'react-native';
import PropTypes from 'prop-types';

const propTypes = {
type: PropTypes.string,
type: PropTypes.string, // eslint-disable-line react/no-unused-prop-types
opacityMin: PropTypes.number,
scaleMin: PropTypes.number,
duration: PropTypes.number,
duration: PropTypes.number, // eslint-disable-line react/no-unused-prop-types
animateOnDidMount: PropTypes.bool,
delay: PropTypes.number,
delay: PropTypes.number, // eslint-disable-line react/no-unused-prop-types
};
const defaultProps = {
type: 'timing',
Expand All @@ -30,17 +30,21 @@ class ScaleAndOpacity extends PureComponent {
};
}
componentDidMount() {
if (this.props.animateOnDidMount) {
const { animateOnDidMount } = this.props;

if (animateOnDidMount) {
InteractionManager.runAfterInteractions().then(() => {
this.show(this.props);
});
}
}
componentWillReceiveProps(nextProps) {
if (!this.props.isHidden && nextProps.isHidden) {
const { isHidden } = this.props;

if (!isHidden && nextProps.isHidden) {
this.hide(nextProps);
}
if (this.props.isHidden && !nextProps.isHidden) {
if (isHidden && !nextProps.isHidden) {
this.show(nextProps);
}
}
Expand Down
11 changes: 6 additions & 5 deletions src/Shake.js
@@ -1,5 +1,5 @@
import React, { PureComponent } from 'react';
import { Animated, InteractionManager } from 'react-native';
import { Animated } from 'react-native';
import PropTypes from 'prop-types';

const propTypes = {
Expand All @@ -13,8 +13,6 @@ class Shake extends PureComponent {
constructor(props) {
super(props);

const { value } = props;

this.currentValue = 0;

this.state = {
Expand All @@ -23,14 +21,17 @@ class Shake extends PureComponent {
}
// componentDidMount
componentWillReceiveProps(nextProps) {
if (this.props.value !== nextProps.value) {
const { value } = this.props;

if (value !== nextProps.value) {
this.move(nextProps);
}
}
move = props => {
const { value, style, type, ...rest } = props;
const { animatedValue } = this.state;

Animated[type](this.state.animatedValue, {
Animated[type](animatedValue, {
toValue: this.currentValue === 0 ? 1 : 0,
...rest,
}).start(() => {
Expand Down

0 comments on commit 32ce96b

Please sign in to comment.