Skip to content

Commit

Permalink
fix(infotip): adds some eslint fixes for infotip (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
priley86 authored and jeff-phillips-18 committed Feb 22, 2018
1 parent 92cd286 commit 9dd5baf
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 59 deletions.
1 change: 1 addition & 0 deletions src/components/InfoTip/InfoTip.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class InfoTip extends React.Component {
case KEY_CODES.ESCAPE_KEY:
return this.setState({ open: false });
default:
return null;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/InfoTip/InfoTip.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ const stories = storiesOf('InfoTip', module);
stories.addDecorator(
defaultTemplate({
title: 'InfoTip',
documentationLink: DOCUMENTATION_URL.PATTERNFLY_ORG_WIDGETS + '#info-tip'
documentationLink: `${DOCUMENTATION_URL.PATTERNFLY_ORG_WIDGETS}#info-tip`
})
);

stories.addWithInfo('InfoTip', '', () => (
<nav className="navbar navbar-default navbar-pf" role="navigation">
<nav className="navbar navbar-default navbar-pf">
<div className="navbar-header">
<button
type="button"
Expand Down
24 changes: 12 additions & 12 deletions src/components/InfoTip/InfoTip.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ const component = renderer.create(
);

test('InfoTip is a instance', () => {
var instance = component.getInstance();
const instance = component.getInstance();
expect(instance).toBeTruthy();
});

test('InfoTip handleEnterKeyDown', () => {
var instance = component.getInstance();
var event = {
const instance = component.getInstance();
const event = {
preventDefault() {},
key: 'Enter',
keyCode: 13,
Expand All @@ -124,8 +124,8 @@ test('InfoTip handleEnterKeyDown', () => {
});

test('InfoTip handleTabKeyDown', () => {
var instance = component.getInstance();
var event = {
const instance = component.getInstance();
const event = {
stopPropagation() {},
nativeEvent: {
stopImmediatePropagation() {}
Expand All @@ -146,8 +146,8 @@ test('InfoTip handleTabKeyDown', () => {
});

test('InfoTip handleClick', () => {
var instance = component.getInstance();
var event = {
const instance = component.getInstance();
const event = {
preventDefault() {}
};
instance.state.open = false;
Expand All @@ -162,7 +162,7 @@ test('InfoTip handleClick', () => {
});

test('InfoTip handleBackFocus', () => {
var instance = component.getInstance();
const instance = component.getInstance();
instance.state.open = true;

// Should close the menu
Expand All @@ -175,8 +175,8 @@ test('InfoTip handleBackFocus', () => {
});

test('InfoTip handleKeyDown', () => {
var instance = component.getInstance();
var eventEnterKey = {
const instance = component.getInstance();
const eventEnterKey = {
preventDefault() {},
key: 'Enter',
keyCode: 13,
Expand All @@ -186,7 +186,7 @@ test('InfoTip handleKeyDown', () => {
instance.handleKeyDown(eventEnterKey);
expect(instance.state.open).toBeFalsy();

var eventTabKey = {
const eventTabKey = {
stopPropagation() {},
nativeEvent: {
stopImmediatePropagation() {}
Expand All @@ -202,7 +202,7 @@ test('InfoTip handleKeyDown', () => {
expect(instance.state.open).toBeFalsy();
expect(instance.state.footerFocused).toBeFalsy();

var eventEscKey = {
const eventEscKey = {
stopPropagation() {},
nativeEvent: {
stopImmediatePropagation() {}
Expand Down
17 changes: 8 additions & 9 deletions src/components/InfoTip/InfoTipMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ import React from 'react';
import ClassNames from 'classnames';
import PropTypes from 'prop-types';

// eslint-disable-next-line react/prefer-stateless-function
class InfoTipMenu extends React.Component {
render() {
const {
children,
className,
bsRole,
rootCloseEvent,
labelledBy,
pullRight,
bsClass,
labelledBy, // eslint-disable-line react/prop-types
pullRight, // eslint-disable-line react/prop-types
bsClass, // eslint-disable-line react/prop-types
...props
} = this.props;

Expand All @@ -24,7 +25,6 @@ class InfoTipMenu extends React.Component {
return (
<div className={infoTipMenuClass} style={{ padding: '' }} {...props}>
<div className="arrow" />

{children}
</div>
);
Expand All @@ -35,12 +35,11 @@ InfoTipMenu.propTypes = {
className: PropTypes.string,
children: PropTypes.node.isRequired,
bsRole: PropTypes.string,
rootCloseEvent: PropTypes.oneOf(['click', 'mousedown']),
labelledBy: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
pullRight: PropTypes.bool,
bsClass: PropTypes.string
rootCloseEvent: PropTypes.oneOf(['click', 'mousedown'])
};
InfoTipMenu.defaultProps = {
bsRole: 'menu'
bsRole: 'menu',
className: '',
rootCloseEvent: 'click'
};
export default InfoTipMenu;
26 changes: 12 additions & 14 deletions src/components/InfoTip/InfoTipMenuFooter.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
import React from 'react';
import ClassNames from 'classnames';
import classNames from 'classnames';
import PropTypes from 'prop-types';

class InfoTipMenuFooter extends React.Component {
render() {
const { children, className, ...props } = this.props;
const InfoTipMenuFooter = ({ children, className, ...props }) => {
const infoTipMenuFooterClass = classNames('footer', className);

const infoTipMenuFooterClass = ClassNames('footer', className);

return (
<div ref="InfotipFooter" className={infoTipMenuFooterClass} {...props}>
{children}
</div>
);
}
}
return (
<div className={infoTipMenuFooterClass} {...props}>
{children}
</div>
);
};

InfoTipMenuFooter.propTypes = {
children: PropTypes.node.isRequired,
className: PropTypes.string
};

InfoTipMenuFooter.defaultProps = {
className: ''
};
export default InfoTipMenuFooter;
33 changes: 15 additions & 18 deletions src/components/InfoTip/InfoTipMenuItemIcon.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
import React from 'react';
import PropTypes from 'prop-types';
import ClassNames from 'classnames';
import classNames from 'classnames';
import { Icon } from '../Icon';

class InfoTipMenuItemIcon extends React.Component {
render() {
const { type, name, className, ...props } = this.props;
const InfoTipMenuItemIcon = ({ type, name, className, ...props }) => {
const infoTipMenuItemIconClass = classNames('i', className);

const infoTipMenuItemIconClass = ClassNames('i', className);

return (
<Icon
type={type}
name={name}
className={infoTipMenuItemIconClass}
{...props}
/>
);
}
}
return (
<Icon
type={type}
name={name}
className={infoTipMenuItemIconClass}
{...props}
/>
);
};

InfoTipMenuItemIcon.propTypes = {
type: PropTypes.oneOf(['fa', 'pf']),
name: PropTypes.string.isRequired,
name: PropTypes.string,
className: PropTypes.string
};

InfoTipMenuItemIcon.defaultProps = {
type: 'pf',
name: 'info'
name: 'info',
className: ''
};

export default InfoTipMenuItemIcon;
6 changes: 5 additions & 1 deletion src/components/InfoTip/InfoTipToggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import { Dropdown } from '../Dropdown';
import { Icon } from '../Icon';

// eslint-disable-next-line react/prefer-stateless-function
class InfoTipToggle extends React.Component {
render() {
const { children, className, bsRole, bsClass, open, ...props } = this.props;
Expand All @@ -23,7 +24,10 @@ InfoTipToggle.propTypes = {
};

InfoTipToggle.defaultProps = {
bsRole: 'toggle'
bsRole: 'toggle', // eslint-disable-line react/default-props-match-prop-types
children: null,
open: false,
className: ''
};

export default InfoTipToggle;
6 changes: 3 additions & 3 deletions src/components/InfoTip/__snapshots__/InfoTip.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports[`InfoTip renders properly with a default MenuItemIcon 1`] = `
>
<a
aria-expanded={false}
className={undefined}
className=""
disabled={undefined}
href="#"
id="infotip-widget"
Expand Down Expand Up @@ -82,7 +82,7 @@ exports[`InfoTip renders properly with another MenuItemIcon 1`] = `
>
<a
aria-expanded={false}
className={undefined}
className=""
disabled={undefined}
href="#"
id="infotip-widget"
Expand Down Expand Up @@ -155,7 +155,7 @@ exports[`InfoTip renders properly with item children 1`] = `
>
<a
aria-expanded={false}
className={undefined}
className=""
disabled={undefined}
href="#"
id="infotip-widget"
Expand Down

0 comments on commit 9dd5baf

Please sign in to comment.