Skip to content
This repository has been archived by the owner on Mar 30, 2018. It is now read-only.

Commit

Permalink
stricter eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Aug 7, 2016
1 parent 078abf0 commit 2614d97
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 16 deletions.
22 changes: 22 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,28 @@ rules:
react/no-direct-mutation-state: error
react/no-string-refs: error
react/jsx-handler-names: error
react/jsx-boolean-value:
- error
- never
react/sort-comp: error
react/jsx-no-bind:
- error
- ignoreRefs: true
allowArrowFunctions: false
allowBind: false
react/jsx-no-duplicate-props: error
react/jsx-key:
- error
react/sort-prop-types:
- error
- ignoreCase: true
callbacksLast: true
requiredFirst: true
react/jsx-sort-props:
- error
- callbacksLast: true
shorthandFirst: true
ignoreCase: true
react/react-in-jsx-scope: off
react/jsx-uses-react: off
react/jsx-filename-extension: off
Expand Down
4 changes: 2 additions & 2 deletions src/Button.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import classNames from 'classnames'
import cx from 'classnames'
import { Component, PropTypes } from 'react'

export default class Button extends Component {
Expand Down Expand Up @@ -54,7 +54,7 @@ export default class Button extends Component {
className: customClassName,
...other,
} = this.props
const className = classNames('uk-button', customClassName, {
const className = cx('uk-button', customClassName, {
'uk-button-primary': primary,
'uk-button-success': success,
'uk-button-danger': danger,
Expand Down
4 changes: 2 additions & 2 deletions src/Dropdown.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import classNames from 'classnames'
import cx from 'classnames'
import { Component, PropTypes } from 'react'

export default class Dropdown extends Component {
Expand Down Expand Up @@ -46,7 +46,7 @@ export default class Dropdown extends Component {
this.setState({ isOpen: !this.state.isOpen })
}
render() {
const className = classNames('uk-button-dropdown', {
const className = cx('uk-button-dropdown', {
'uk-open': this.state.isOpen,
})
return (
Expand Down
4 changes: 2 additions & 2 deletions src/Select/CreateOption.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import classNames from 'classnames'
import cx from 'classnames'
import { PropTypes } from 'react'

const CreateOption = ({ isFocused, addLabelText, children }) => (
<li className={classNames({ 'uk-active': isFocused })}>
<li className={cx({ 'uk-active': isFocused })}>
<a>
{addLabelText}&nbsp;
<span className="uk-text-bold">
Expand Down
4 changes: 2 additions & 2 deletions src/Select/Option.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import classNames from 'classnames'
import cx from 'classnames'
import { Component, PropTypes } from 'react'

export default class Option extends Component {
Expand Down Expand Up @@ -62,7 +62,7 @@ export default class Option extends Component {

render() {
const { option, instancePrefix, optionIndex } = this.props
let className = classNames(this.props.className, option.className)
let className = cx(this.props.className, option.className)
return option.disabled ? (
<li
className={className}
Expand Down
4 changes: 2 additions & 2 deletions src/Select/Value.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import classNames from 'classnames'
import cx from 'classnames'
import { Component, PropTypes } from 'react'

export default class Value extends Component {
Expand Down Expand Up @@ -91,7 +91,7 @@ export default class Value extends Component {
render() {
return (
<div
className={classNames('uk-component-select__value', this.props.value.className)}
className={cx('uk-component-select__value', this.props.value.className)}
style={this.props.value.style}
title={this.props.value.title}
>
Expand Down
10 changes: 5 additions & 5 deletions src/Select/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import classNames from 'classnames'
import cx from 'classnames'
import Input from 'react-input-autosize'
import ReactDOM from 'react-dom'
import { Component, PropTypes } from 'react'
Expand Down Expand Up @@ -730,10 +730,10 @@ export default class Select extends Component {
if (this.props.inputRenderer) {
return this.props.inputRenderer()
} else {
let className = classNames('uk-component-select__input', this.props.inputProps.className)
let className = cx('uk-component-select__input', this.props.inputProps.className)
const isOpen = !!this.state.isOpen

const ariaOwns = classNames({
const ariaOwns = cx({
[this._instancePrefix + '-list']: isOpen,
[this._instancePrefix + '-backspace-remove-message']: this.props.multi &&
!this.props.disabled &&
Expand Down Expand Up @@ -883,7 +883,7 @@ export default class Select extends Component {
let isSelected = valueArray && valueArray.indexOf(option) > -1
let isFocused = option === focusedOption
let optionRef = isFocused ? 'focused' : null
let optionClass = classNames(this.props.optionClassName, {
let optionClass = cx(this.props.optionClassName, {
'Select-option': true,
'is-selected': isSelected,
'uk-active': isFocused,
Expand Down Expand Up @@ -1013,7 +1013,7 @@ export default class Select extends Component {
} else {
focusedOption = this._focusedOption = null
}
let className = classNames('uk-autocomplete uk-component-select', this.props.className, {
let className = cx('uk-autocomplete uk-component-select', this.props.className, {
'uk-component-select--multi': this.props.multi,
'uk-component-select--single': !this.props.multi,
'uk-component-select--disabled': this.props.disabled,
Expand Down
2 changes: 1 addition & 1 deletion test/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('<Button />', () => {
expect(wrapper.hasClass('uk-active')).toBe(true)
})

it('toggles classNames based on props', () => {
it('toggles css class names based on props', () => {
const wrapper = shallow(<Button primary />)

expect(wrapper.hasClass('uk-button-primary')).toBe(true)
Expand Down

0 comments on commit 2614d97

Please sign in to comment.