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 1 commit
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
2 changes: 1 addition & 1 deletion 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
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
1 change: 0 additions & 1 deletion src/SearchInput/SearchInput.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';

export class SearchInput extends Component {
constructor(props) {
Expand Down
2 changes: 1 addition & 1 deletion src/SearchInput/SearchInput.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe('<SearchInput />', () => {
expect(wrapper.state('isExpanded')).toBeTruthy();

// enter text into search input
const itemClicked = wrapper
wrapper
.find('.fd-menu__item')
.at(0)
.simulate('click', searchData[0]);
Expand Down
96 changes: 0 additions & 96 deletions src/Shellbar/Shellbar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { mount } from 'enzyme';
import React from 'react';
import renderer from 'react-test-renderer';
import { Shellbar } from './Shellbar';
import { Menu, MenuList, MenuItem } from '../Menu/Menu';

describe('<Shellbar />', () => {
const profile1 = {
Expand Down Expand Up @@ -51,101 +50,6 @@ describe('<Shellbar />', () => {
profileMenu={profileMenu} />
);

const searchInput = {
label: 'Search',
placeholder: 'Enter a fruit',
onSearch: function(searchTerm) {
alert(`Search fired for ${searchTerm}`);
},
callback: () => alert('Search selected!')
};

const actions = [
{
glyph: 'settings',
label: 'Settings',
notificationCount: 5,
callback: () => alert('Settings selected!'),
menu: (
<Menu>
<MenuList>
<MenuItem url='/'>Option 1</MenuItem>
<MenuItem url='/'>Option 2</MenuItem>
<MenuItem url='/'>Option 3</MenuItem>
</MenuList>
</Menu>
)
}
];

const notifications = {
notificationCount: 2,
label: 'Notifications',
notificationsBody: (
<Menu>
<MenuList>
<MenuItem url='/'>Notification 1</MenuItem>
<MenuItem url='/'>Notification 2</MenuItem>
<MenuItem url='/'>Notification 3</MenuItem>
</MenuList>
</Menu>
),
noNotificationsBody: (
<Menu>
<MenuList>
<MenuItem>There are no notifications</MenuItem>
</MenuList>
</Menu>
),
callback: () => alert('Notification selected!')
};

const profile = {
initials: 'JS',
userName: 'John Snow',
colorAccent: 8
};

const productMenu = [
{ name: 'Application A', callback: () => alert('Application A selected!') },
{ name: 'Application B', callback: () => alert('Application B selected!') },
{ name: 'Application C', callback: () => alert('Application C selected!') },
{ name: 'Application D', callback: () => alert('Application D selected!') }
];

const productSwitcherList = [
{
title: 'Fiori Home',
glyph: 'home',
callback: () => alert('Fiori Home selected!')
},
{
title: 'S/4 HANA Cloud',
glyph: 'cloud',
callback: () => alert('S/4 HANA Cloud selected!')
}
];

const productSwitcher = {
label: 'Product Switcher'
};

const coPilotShell = (
<Shellbar
logoSAP
productTitle='Corporate Portal'
productMenu={productMenu}
subtitle='Subtitle'
copilot
searchInput={searchInput}
actions={actions}
notifications={notifications}
profile={profile}
profileMenu={profileMenu}
productSwitcher={productSwitcher}
productSwitcherList={productSwitcherList} />
);

Copy link
Contributor

Choose a reason for hiding this comment

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

Were these made with the intention of using them in the snapshot tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good question. There were a bunch of variables defined to create it, but then it was never used. I will check the blame on this to see if someone wants to retain all this code in a separate branch, but it should all be removed from master.

Copy link
Contributor

Choose a reason for hiding this comment

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

My bad, i think i forgot to make the snapshot call. I will create a chore: PR to add the call in there. This snapshot call bumps up the code coverage from 30% to about 85%

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@chrismanciero Do you want to fix it in this PR or create a separate one?

test('create shellbar', () => {
let component = renderer.create(simpleShellBar);
let tree = component.toJSON();
Expand Down
12 changes: 0 additions & 12 deletions src/SideNavigation/SideNavigation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,6 @@ describe('<SideNavigation />', () => {
</SideNav>
);

const sideNavList = (
<SideNavList
items={[
{ id: 'item-1', url: '#', glyph: 'home' },
{ id: 'item-2', url: '#', glyph: 'home' },
{ id: 'item-3', url: '#', glyph: 'home' },
{ id: 'item-4', url: '#', glyph: 'home' },
{ id: 'item-5', url: '#', glyph: 'home' },
{ id: 'item-6', link: '/', glyph: 'home' }
]} />
);

test('create side navigation', () => {
// create one level side nav
let component = renderer.create(oneLevelSideNav);
Expand Down
2 changes: 1 addition & 1 deletion src/Tree/Tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class Tree extends Component {

if (this.state.numberOfElements === 0) {
treeData.map(row => {
row.values.forEach(element => {
row.values.forEach(() => {
++numberOfElements;
});
if (row.hasChildren) {
Expand Down
2 changes: 1 addition & 1 deletion src/documentation/Playground/Playground.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import { Alert } from '../../';
import { Badge, Label, Status } from '../../';
import { Button, ButtonGroup } from '../../';
import { Button } from '../../';
import { Dropdown } from '../../';
import { Icon } from '../../';
import { Identifier } from '../../';
Expand Down
2 changes: 1 addition & 1 deletion src/documentation/Separator/Separator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

export const Separator = (props) => {
export const Separator = () => {
const separatorStyle = {
display: 'block',
margin: '2rem 0',
Expand Down