Skip to content

Commit

Permalink
fix: pre commit hook
Browse files Browse the repository at this point in the history
  • Loading branch information
lijinke666 committed Sep 5, 2018
1 parent 93ae216 commit fc1afc2
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 54 deletions.
16 changes: 8 additions & 8 deletions components/backTop/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import cls from 'classnames';
import React, { PureComponent } from "react";
import PropTypes from "prop-types";
import cls from "classnames";

import { UpIcon } from '../icon';
import './styles.less';
import { UpIcon } from "../icon";
import "./styles.less";

const scrollToTop = () => {
const c = document.documentElement.scrollTop || document.body.scrollTop;
Expand All @@ -24,7 +24,7 @@ export default class BackTop extends PureComponent {
onClick: PropTypes.func
};
static defaultProps = {
prefixCls: 'cuke-back-top',
prefixCls: "cuke-back-top",
visibilityHeight: 400,
onClick: () => {}
};
Expand Down Expand Up @@ -72,9 +72,9 @@ export default class BackTop extends PureComponent {
}
};
componentDidMount() {
window.addEventListener('scroll', this.bindScroll);
window.addEventListener("scroll", this.bindScroll);
}
componentWillUnmount() {
window.removeEventListener('scroll', this.bindScroll);
window.removeEventListener("scroll", this.bindScroll);
}
}
2 changes: 1 addition & 1 deletion components/dropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default class Dropdown extends PureComponent {
disabled,
trigger,
animate,
onVisibleChange, //eslint-disable-line
onVisibleChange, //eslint-disable-line
...attr
} = this.props;

Expand Down
10 changes: 5 additions & 5 deletions components/radio/Radio.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React, { PureComponent } from 'react';
import cls from 'classnames';
import PropTypes from 'prop-types';
import React, { PureComponent } from "react";
import cls from "classnames";
import PropTypes from "prop-types";

export default class Radio extends PureComponent {
state = {
checked: this.props.checked || this.props.defaultChecked
};
static defaultProps = {
prefixCls: 'cuke-radio',
prefixCls: "cuke-radio",
defaultChecked: false,
checked: false,
disabled: false
Expand All @@ -30,7 +30,7 @@ export default class Radio extends PureComponent {
this.setState({
checked: true
});
if(this.props.onChange){
if (this.props.onChange) {
this.props.onChange(e);
}
};
Expand Down
10 changes: 5 additions & 5 deletions components/radio/RadioGroup.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React, { PureComponent } from 'react';
import Radio from './Radio';
import PropTypes from 'prop-types';
import cls from 'classnames';
import React, { PureComponent } from "react";
import Radio from "./Radio";
import PropTypes from "prop-types";
import cls from "classnames";

export default class RadioGroup extends PureComponent {
state = {
value: this.props.value || this.props.defaultValue
};
static defaultProps = {
prefixCls: 'cuke-radio-group',
prefixCls: "cuke-radio-group",
onChange: () => {}
};

Expand Down
24 changes: 12 additions & 12 deletions components/radio/__tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react';
import { render, shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import Radio from '../index';
import React from "react";
import { render, shallow } from "enzyme";
import toJson from "enzyme-to-json";
import Radio from "../index";

describe('<Radio/>', () => {
it('should render Radio', () => {
describe("<Radio/>", () => {
it("should render Radio", () => {
const wrapper = render(
<div>
<Radio>黄瓜 ui</Radio>
Expand All @@ -15,10 +15,10 @@ describe('<Radio/>', () => {
expect(toJson(wrapper)).toMatchSnapshot();
});

it('should render RadioGroup', () => {
it("should render RadioGroup", () => {
const wrapper = render(
<div>
<Radio.Group value={'小红'}>
<Radio.Group value={"小红"}>
<Radio value="小红">小红</Radio>
<Radio value="小明">小明</Radio>
<Radio value="小美">小美</Radio>
Expand All @@ -44,20 +44,20 @@ describe('<Radio/>', () => {
// wrapper.find('input').simulate('change');
// expect(onChange).toHaveBeenCalled();
// });
it('should can trigger change event', () => {
it("should can trigger change event", () => {
const onChange = jest.fn();
const wrapper = shallow(<Radio onChange={onChange}>黄瓜 ui</Radio>);
wrapper.find('input').simulate('change');
wrapper.find("input").simulate("change");
expect(onChange).toHaveBeenCalled();
});
it('should can not trigger change event', () => {
it("should can not trigger change event", () => {
const onChange = jest.fn();
const wrapper = shallow(
<Radio onChange={onChange} disabled>
黄瓜 ui
</Radio>
);
wrapper.find('input').simulate('click');
wrapper.find("input").simulate("click");
expect(onChange).not.toHaveBeenCalled();
});
});
16 changes: 8 additions & 8 deletions components/radio/styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@prefixCls : cuke-radio;
.@{prefixCls} {
font-size: @font-size;
color:@font-color;
color: @font-color;
outline: none;
display: inline-block;
line-height: 1;
Expand All @@ -22,10 +22,10 @@
box-sizing: border-box;
padding: 0;
position: absolute;
top:0;
left:0;
bottom:0;
right:0;
top: 0;
left: 0;
bottom: 0;
right: 0;
opacity: 0;
z-index: 1;
}
Expand Down Expand Up @@ -54,7 +54,7 @@

&::after {
opacity: 1;
transform: scale(1)
transform: scale(1);
}
}
}
Expand All @@ -81,7 +81,7 @@
left: 2px;
opacity: 0;
transition: all @default-transition;
transform: scale(0)
transform: scale(0);
}
}
}
Expand All @@ -90,7 +90,7 @@
color: @font-color;
font-size: @font-size;
box-sizing: border-box;
margin:0;
margin: 0;
padding: 0;
display: inline-block;
position: relative;
Expand Down
2 changes: 1 addition & 1 deletion components/styles/vars.less
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,4 @@
@cuke-radio-width : 14px;
@cuke-radio-height : @cuke-radio-width;
@cuke-radio-offset-right: 6px;
@cuke-radio-group-offset-right: 20px;
@cuke-radio-group-offset-right: 20px;
6 changes: 3 additions & 3 deletions components/tabs/TabPane.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { PureComponent } from 'react';
import cls from 'classnames';
import React, { PureComponent } from "react";
import cls from "classnames";

class BreadcrumbItem extends PureComponent {
static defaultProps = {
prefixCls: 'cuke-tabs-panel'
prefixCls: "cuke-tabs-panel"
};

render() {
Expand Down
16 changes: 8 additions & 8 deletions components/tabs/Tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ export default class Tabs extends PureComponent {
}
}

componentWillReceiveProps({activeKey}) {
const _activeKey = ~~(activeKey)
if(_activeKey !== this.props.activeKey) {
this.setState({activeKey:_activeKey})
componentWillReceiveProps({ activeKey }) {
const _activeKey = ~~activeKey;
if (_activeKey !== this.props.activeKey) {
this.setState({ activeKey: _activeKey });
}
}
}

setActiveLineStyle = () => {
const activeElement = this.activeTab;
Expand All @@ -69,8 +69,8 @@ export default class Tabs extends PureComponent {
type,
tabBarExtraContent,
children,
activeKey : _activeKey, //eslint-disable-line
defaultActiveKey, //eslint-disable-line
activeKey: _activeKey, //eslint-disable-line
defaultActiveKey, //eslint-disable-line
...attr
} = this.props;

Expand All @@ -90,7 +90,7 @@ export default class Tabs extends PureComponent {
({ props: { tab, disabled } }, index) => {
const key = (index + 1) >> 0;
const bindActiveRef =
activeKey === key ? { ref: node => (this[`activeTab`] = node) } : {};
activeKey === key ? { ref: node => (this[`activeTab`] = node) } : {};
return (
<div
key={index}
Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"clean": "rimraf dist lib",
"dev": "start-storybook -p 8080 -c .storybook",
"upgrade": "yarn upgrade",
"precommit": "lint-staged",
"stylelint:fix": "stylelint 'components/**/*.less' --syntax less --fix",
"eslint:fix": "eslint ./components --fix",
"lint": "prettier --write \"components/**/*.js\" && yarn eslint:fix && yarn stylelint:fix",
Expand All @@ -32,8 +31,13 @@
"build:lib": "babel components -d lib",
"build:umd": "webpack --config ./scripts/build.umd.js"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"components/**/*.{js}": [
"components/**/*.js": [
"prettier --write",
"eslint --fix",
"git add"
Expand Down Expand Up @@ -132,7 +136,6 @@
"postcss-cli": "^4.1.1",
"postcss-loader": "2.1.3",
"power-assert": "^1.5.0",
"pre-commit": "^1.2.2",
"prettier": "^1.12.1",
"progress-bar-webpack-plugin": "^1.11.0",
"react": "^16.4.2",
Expand Down

0 comments on commit fc1afc2

Please sign in to comment.