diff --git a/.eslintrc b/.eslintrc index 0b3c8a7150..797d1908ba 100644 --- a/.eslintrc +++ b/.eslintrc @@ -6,6 +6,7 @@ "node": true }, "rules": { + "arrow-parens": "off", "no-plusplus": "off", "react/require-default-props": "off", "react/jsx-filename-extension": ["error", { "extensions": [".js"] }], diff --git a/package.json b/package.json index 6399d0b8fe..943baf1c93 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,9 @@ "build:umd:min": "cross-env MINIFY=1 webpack --config webpack.build.js", "build": "npm run clean && npm run build:commonjs", "bundle": "mkdir -p dist && npm run build:umd && npm run build:umd:min", + "format": "prettier --write --single-quote --print-width 100 --trailing-comma all \"src/**/*.js\"", "lint": "eslint src", + "precommit": "lint-staged", "preversion": "npm run lint && npm test && npm run build && npm run bundle && git add dist/ && git commit -m 'publish: Distribution'", "prepublish": "npm run build", "test": "jest", @@ -59,7 +61,10 @@ "eslint-plugin-import": "^2.2.0", "eslint-plugin-jsx-a11y": "^4.0.0", "eslint-plugin-react": "^6.2.1", + "husky": "^0.13.3", "jest-cli": "^19.0.2", + "lint-staged": "^3.4.0", + "prettier": "^1.2.2", "react": "^15.0.0", "react-addons-test-utils": "^15.0.0", "react-dom": "^15.0.0", @@ -79,5 +84,11 @@ "roots": [ "src" ] + }, + "lint-staged": { + "src/**/*.js": [ + "prettier --single-quote --print-width 100 --trailing-comma all --write", + "git add" + ] } } diff --git a/src/components/Tab.js b/src/components/Tab.js index 9c0c23de38..b338d02be0 100644 --- a/src/components/Tab.js +++ b/src/components/Tab.js @@ -3,7 +3,6 @@ import React, { Component } from 'react'; import cx from 'classnames'; export default class Tab extends Component { - static defaultProps = { className: 'ReactTabs__Tab', disabledClassName: 'ReactTabs__Tab--disabled', @@ -15,11 +14,7 @@ export default class Tab extends Component { }; static propTypes = { - children: PropTypes.oneOfType([ - PropTypes.array, - PropTypes.object, - PropTypes.string, - ]), + children: PropTypes.oneOfType([PropTypes.array, PropTypes.object, PropTypes.string]), className: PropTypes.oneOfType([PropTypes.string, PropTypes.array, PropTypes.object]), disabled: PropTypes.bool, disabledClassName: PropTypes.string, // private @@ -57,19 +52,20 @@ export default class Tab extends Component { selected, selectedClassName, tabRef, - ...attributes } = this.props; + ...attributes + } = this.props; return (
  • { this.node = node; if (tabRef) tabRef(node); }} + className={cx(className, { + [selectedClassName]: selected, + [disabledClassName]: disabled, + })} + ref={node => { + this.node = node; + if (tabRef) tabRef(node); + }} role="tab" id={id} aria-selected={selected ? 'true' : 'false'} diff --git a/src/components/TabList.js b/src/components/TabList.js index 0628c8243f..da779e9bf5 100644 --- a/src/components/TabList.js +++ b/src/components/TabList.js @@ -3,31 +3,20 @@ import React, { Component } from 'react'; import cx from 'classnames'; export default class TabList extends Component { - static defaultProps = { className: 'ReactTabs__TabList', }; static propTypes = { - children: PropTypes.oneOfType([ - PropTypes.object, - PropTypes.array, - ]), + children: PropTypes.oneOfType([PropTypes.object, PropTypes.array]), className: PropTypes.oneOfType([PropTypes.string, PropTypes.array, PropTypes.object]), }; render() { - const { - children, - className, - ...attributes } = this.props; + const { children, className, ...attributes } = this.props; return ( -