Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: eslint no unused vars #205

Merged
merged 7 commits into from
Jan 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ rules:
#no-undefined: 2
no-underscore-dangle: 0
no-unreachable: 2
#no-unused-vars: [2, { ignoreRestSiblings: true }]
no-unused-vars: [2, { ignoreRestSiblings: true }]
quote-props: [2, 'as-needed', { 'keywords': true, 'unnecessary': false }]
quotes: [2, 'single']
radix: 2
Expand Down
1 change: 0 additions & 1 deletion src/Dropdown/Dropdown.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { mount } from 'enzyme';
import React from 'react';
import renderer from 'react-test-renderer';
import { Dropdown } from './Dropdown';
Expand Down
1 change: 0 additions & 1 deletion src/InlineHelp/InlineHelp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import renderer from 'react-test-renderer';
import { InlineHelp } from './InlineHelp';

describe('<InlineHelp />', () => {
const handleClick = jest.fn();
const defaultInlineHelp = (
<InlineHelp
className='blue'
Expand Down
2 changes: 1 addition & 1 deletion src/MegaMenu/MegaMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class MegaMenuList extends Component {
const { itemStates } = this.state;
let iStates = itemStates;
iStates[id] = !iStates[id];
Object.keys(iStates).map((key, item) => {
Object.keys(iStates).map((key) => {
if (key === id) {
iStates[key] = true;
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/Modal/Modal.Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ export class ModalComponent extends Component {
if (this.state.bShowFormModal) {
this.txtEmailRef.current.focus();
} else {
this.setState(prevState => ({
this.setState({
emailAddress: ''
}));
});
}
}
);
Expand All @@ -129,9 +129,9 @@ export class ModalComponent extends Component {
updateEmailAddress = event => {
const newEmail = event.target.value;

this.setState(prevState => ({
this.setState({
emailAddress: newEmail
}));
});
};

render() {
Expand Down
186 changes: 100 additions & 86 deletions src/MultiInput/MultiInput.Component.js
Original file line number Diff line number Diff line change
@@ -1,113 +1,127 @@
import React, { Component } from 'react';
import { DocsTile, DocsText, Separator, Header, Description, Import, Properties } from '../';
import {
DocsTile,
DocsText,
Separator,
Header,
Description,
Import,
Properties
} from '../';
import { MultiInput } from '../';

export class MultiInputComponent extends Component {
data = [
'Apple',
'Apricot',
'Acai',
'African Moringa',
'Bearberry',
'Bilberry',
'Blood orange',
'Barbadine',
'Barbados cherry',
'Balsam Apple',
'Chokeberry',
'Cranberry',
'Cupuacu'
];
data = [
'Apple',
'Apricot',
'Acai',
'African Moringa',
'Bearberry',
'Bilberry',
'Blood orange',
'Barbadine',
'Barbados cherry',
'Balsam Apple',
'Chokeberry',
'Cranberry',
'Cupuacu'
];

constructor(props) {
super(props);
constructor(props) {
super(props);

this.state = {
data: []
};
}

performTagsUpdate = aTags => {
// console.log(aTags);
this.state = {
data: []
};
}

performTagsUpdate = aTags => {
alert(aTags);
};

multiInputCode = `<MultiInput
multiInputCode = `<MultiInput
data={this.data}
onTagsUpdate={this.performTagsUpdate}
placeHolder="Select a Fruit"
/>`;

multiInputCompactCode = `<MultiInput
multiInputCompactCode = `<MultiInput
data={this.data}
onTagsUpdate={this.performTagsUpdate}
placeHolder="Select a Fruit"
compact={true}
/>`;

render() {
return (
<div>
<Header>Multi Input</Header>
<Description />
<Import module='MultiInput' path='/fundamental-react/src/' />
render() {
return (
<div>
<Header>Multi Input</Header>
<Description />
<Import module='MultiInput' path='/fundamental-react/src/' />

<Separator />
<Separator />

<Properties
type='Inputs'
properties={[
{
name: 'data',
description: 'array (Required) - Collection of items to display in the list.'
},
{
name: 'placeHolder',
description: 'string - The text to use as placeholder when no text is entered.'
},
{
name: 'onTagsUpdate',
description:
'func - Method to fire on add or remove of tag. Component returns array of tags selected.'
},
{
name: 'compact',
description: 'bool - true: display compact style, false: default style'
}
]} />
<Properties
type='Inputs'
properties={[
{
name: 'data',
description:
'array (Required) - Collection of items to display in the list.'
},
{
name: 'placeHolder',
description:
'string - The text to use as placeholder when no text is entered.'
},
{
name: 'onTagsUpdate',
description:
'func - Method to fire on add or remove of tag. Component returns array of tags selected.'
},
{
name: 'compact',
description:
'bool - true: display compact style, false: default style'
}
]} />

<Separator />
<Separator />

<h2>Default</h2>
<Description>A text input when on focus will show list of items to select.</Description>
<DocsTile>
<div>
<MultiInput
data={this.data}
onTagsUpdate={this.performTagsUpdate}
placeHolder='Select a Fruit' />
</div>
</DocsTile>
<DocsText>{this.multiInputCode}</DocsText>
<h2>Default</h2>
<Description>
A text input when on focus will show list of items to select.
</Description>
<DocsTile>
<div>
<MultiInput
data={this.data}
onTagsUpdate={this.performTagsUpdate}
placeHolder='Select a Fruit' />
</div>
</DocsTile>
<DocsText>{this.multiInputCode}</DocsText>

<Separator />
<Separator />

<h2>Compact Style</h2>
<Description>
A text input when on focus will show list of items to select, but with a compact input box.
</Description>
<DocsTile>
<div>
<MultiInput
data={this.data}
onTagsUpdate={this.performTagsUpdate}
placeHolder='Select a Fruit'
compact />
</div>
</DocsTile>
<DocsText>{this.multiInputCompactCode}</DocsText>
<h2>Compact Style</h2>
<Description>
A text input when on focus will show list of items to select, but with
a compact input box.
</Description>
<DocsTile>
<div>
<MultiInput
data={this.data}
onTagsUpdate={this.performTagsUpdate}
placeHolder='Select a Fruit'
compact />
</div>
</DocsTile>
<DocsText>{this.multiInputCompactCode}</DocsText>

<Separator />
</div>
);
}
<Separator />
</div>
);
}
}
15 changes: 12 additions & 3 deletions src/MultiInput/MultiInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class MultiInput extends Component {
};

// create tag elements to display below input box
createTags = tags => {
createTags = () => {
return this.state.tags.map((tag, index) => (
<span
key={index}
Expand Down Expand Up @@ -104,7 +104,14 @@ export class MultiInput extends Component {
};

render() {
const { placeHolder, data, compact, className, ...rest} = this.props;
const {
placeHolder,
data,
compact,
className,
onTagsUpdate,
...rest
} = this.props;

const inputGroupClassNames = `fd-input-group fd-input-group--after${
compact ? ' fd-input-group--compact' : ''
Expand All @@ -113,7 +120,9 @@ export class MultiInput extends Component {
const inputClassNames = `fd-input${compact ? ' fd-input--compact' : ''}`;

return (
<div className={`fd-multi-input${className ? ' ' + className : ''}`} {...rest}>
<div
className={`fd-multi-input${className ? ' ' + className : ''}`}
{...rest}>
<div className='fd-multi-input-field'>
<div className='fd-popover'>
<div className='fd-popover__control'>
Expand Down
8 changes: 4 additions & 4 deletions src/MultiInput/MultiInput.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,23 @@ describe('<MultiInput />', () => {
});

// create a default multi-input control
test('create multi-input', () => {
xtest('create multi-input', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@greg-a-smith: why are these test being x-ed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a to-do comment stating why snapshots were failing and the assertion was commented out causing the no-unused-vars lint error. To resolve all of the lint errors, the entire test ended up being commented out so I decided to uncomment everything and just x the tests until the to-do comments are resolved.

const component = renderer.create(multiInput);
const tree = component.toJSON();

// todo: multi-input uses randon number for some elements which cause snapshot to fail
// todo: work on testing solution
// expect(tree).toMatchSnapshot();
expect(tree).toMatchSnapshot();
});

// create a compact multi-input control
test('create compact multi-input', () => {
xtest('create compact multi-input', () => {
const component = renderer.create(compactMultiInput);
const tree = component.toJSON();

// todo: multi-input uses randon number for some elements which cause snapshot to fail
// todo: work on testing solution
// expect(tree).toMatchSnapshot();
expect(tree).toMatchSnapshot();
});

// check that the tag list is hidden
Expand Down
Loading