Skip to content

Commit

Permalink
chore(Linting): More lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuef authored and bochaco committed May 1, 2019
1 parent 005b767 commit cc99c0d
Show file tree
Hide file tree
Showing 35 changed files with 274 additions and 332 deletions.
10 changes: 8 additions & 2 deletions .eslintrc.js
Expand Up @@ -43,6 +43,7 @@ module.exports = {
'no-prototype-builtins': 'off',
'unicorn/prefer-type-error': 'off',
'unicorn/new-for-builtins': 'off',
'import/no-cycle': 'warn',
'import/prefer-default-export': 'off',
'import/no-default-export': 'error',
'import/no-extraneous-dependencies': [
Expand Down Expand Up @@ -82,13 +83,14 @@ module.exports = {
},
overrides: [
{
files: ['*config*.js'],
files: ['*config*js', 'internals/**/*'],
rules: {
'no-console': 'off',
'import/no-extraneous-dependencies': 'off',
'import/no-default-export': 'off',
'@typescript-eslint/tslint/config': 'off',
'@typescript-eslint/no-var-requires': 'off'
'@typescript-eslint/no-var-requires': 'off',
'global-require': 'off'
}
},
{
Expand All @@ -98,6 +100,10 @@ module.exports = {
'@typescript-eslint/no-var-requires': 'off'
}
},
{
files: ['*.spec.*'],
globals: { fixture: 'readonly' }
},
{
files: ['*.tsx'],
rules: {
Expand Down
14 changes: 7 additions & 7 deletions __testcafe__/navigation.spec.ts
@@ -1,4 +1,4 @@
import { ClientFunction, Selector } from 'testcafe';
import { Selector } from 'testcafe';
import { ReactSelector, waitForReact } from 'testcafe-react-selectors';
import { getPageUrl, getPageTitle, navigateTo, resetStore } from './helpers';

Expand All @@ -7,7 +7,7 @@ import { CLASSES } from '../app/constants/classes';
fixture`Browser UI Navigation`.page( '../app/app.html' ).afterEach( resetStore );
// .afterEach(assertNoConsoleErrors);

test( 'should open window', async t => {
test( 'should open window', async ( t ) => {
await t.expect( getPageTitle() ).eql( 'SAFE Browser' );
} );

Expand All @@ -16,7 +16,7 @@ test( 'should open window', async t => {
// assertNoConsoleErrors
// );

test( 'add tab should exist', async t => {
test( 'add tab should exist', async ( t ) => {
await t.expect( Selector( `.${CLASSES.ADD_TAB}` ).exists ).ok();
} );

Expand All @@ -34,7 +34,7 @@ test( 'add tab should exist', async t => {
//
// } );

test( 'can go backwards', async t => {
test( 'can go backwards', async ( t ) => {
await t
.click( `.${CLASSES.ADD_TAB}` )
.expect( Selector( `.${CLASSES.TAB}` ).count )
Expand All @@ -48,7 +48,7 @@ test( 'can go backwards', async t => {
.eql( 'safe://example.com' );
} );

test( 'can go backwards to about:blank', async t => {
test( 'can go backwards to about:blank', async ( t ) => {
await t
.click( `.${CLASSES.ADD_TAB}` )
.expect( Selector( `.${CLASSES.TAB}` ).count )
Expand All @@ -61,7 +61,7 @@ test( 'can go backwards to about:blank', async t => {
.eql( 'about:blank' );
} );

test( 'can load about:blank', async t => {
test( 'can load about:blank', async ( t ) => {
await t
.click( `.${CLASSES.ADD_TAB}` )
.expect( Selector( `.${CLASSES.TAB}` ).count )
Expand All @@ -74,7 +74,7 @@ test( 'can load about:blank', async t => {
.eql( 'about:blank' );
} );

test( 'can go forwards', async t => {
test( 'can go forwards', async ( t ) => {
await t
.click( `.${CLASSES.ADD_TAB}` )
.expect( Selector( `.${CLASSES.TAB}` ).count )
Expand Down
14 changes: 7 additions & 7 deletions __testcafe__/peruse.spec.ts
Expand Up @@ -4,10 +4,10 @@ import { getPageUrl, getPageTitle, navigateTo, resetStore } from './helpers';

import { CLASSES } from '../app/constants/classes';

const assertNoConsoleErrors = async t => {
const assertNoConsoleErrors = async ( t ) => {
const { error } = await t.getBrowserConsoleMessages();

if ( error.length ) {
if ( error.length !== 0 ) {
console.log( 'Errors encountered:', error );
}

Expand All @@ -17,7 +17,7 @@ const assertNoConsoleErrors = async t => {
fixture`Browser UI`.page( '../app/app.html' ).afterEach( resetStore );
// .afterEach(assertNoConsoleErrors);

test( 'should open window', async t => {
test( 'should open window', async ( t ) => {
await t.expect( getPageTitle() ).eql( 'SAFE Browser' );
} );

Expand All @@ -26,18 +26,18 @@ test( 'should open window', async t => {
// assertNoConsoleErrors
// );

test( 'add tab should exist', async t => {
test( 'add tab should exist', async ( t ) => {
await t.expect( Selector( `.${CLASSES.ADD_TAB}` ).exists ).ok();
} );

test( 'can add a tab', async t => {
test( 'can add a tab', async ( t ) => {
await t
.click( `.${CLASSES.ADD_TAB}` )
.expect( Selector( `.${CLASSES.TAB}` ).count )
.eql( 2 );
} );

test( 'can close a tab', async t => {
test( 'can close a tab', async ( t ) => {
await t
.click( `.${CLASSES.ADD_TAB}` )
.expect( Selector( `.${CLASSES.TAB}` ).count )
Expand All @@ -47,7 +47,7 @@ test( 'can close a tab', async t => {
.eql( 1 );
} );

test( 'can type in the address bar and get safe: automatically', async t => {
test( 'can type in the address bar and get safe: automatically', async ( t ) => {
await t
.click( `.${CLASSES.ADD_TAB}` )
.expect( Selector( `.${CLASSES.TAB}` ).count )
Expand Down
16 changes: 8 additions & 8 deletions __testcafe__/settingsMenu.spec.ts
Expand Up @@ -4,10 +4,10 @@ import { getPageUrl, getPageTitle, navigateTo, resetStore } from './helpers';

import { CLASSES } from '../app/constants/classes';

const assertNoConsoleErrors = async t => {
const assertNoConsoleErrors = async ( t ) => {
const { error } = await t.getBrowserConsoleMessages();

if ( error.length ) {
if ( error.length !== 0 ) {
console.log( 'Errors encountered:', error );
}

Expand All @@ -17,7 +17,7 @@ const assertNoConsoleErrors = async t => {
fixture`Settings Menu`.page( '../app/app.html' ).afterEach( resetStore );
// .afterEach(assertNoConsoleErrors);

test( 'should open window', async t => {
test( 'should open window', async ( t ) => {
await t.expect( getPageTitle() ).eql( 'SAFE Browser' );
} );

Expand All @@ -35,11 +35,11 @@ test( 'should open window', async t => {
//
// } );
//
test( 'can check if settings menu exists', async t => {
test( 'can check if settings menu exists', async ( t ) => {
await t.expect( Selector( `.${CLASSES.SETTINGS_MENU__BUTTON}` ).exists ).ok();
} );

test( 'can open settings menu to check options exist', async t => {
test( 'can open settings menu to check options exist', async ( t ) => {
await t
.click( `.${CLASSES.SETTINGS_MENU__BUTTON}` )
.expect( Selector( `.${CLASSES.SETTINGS_MENU__BOOKMARKS}` ).exists )
Expand All @@ -52,7 +52,7 @@ test( 'can open settings menu to check options exist', async t => {
.click( `.${CLASSES.ADDRESS_BAR}` );
} );

test( 'hides settings menu after clicking elsewhere', async t => {
test( 'hides settings menu after clicking elsewhere', async ( t ) => {
await t
.click( `.${CLASSES.SETTINGS_MENU__BUTTON}` )
.expect( Selector( `.${CLASSES.SETTINGS_MENU}` ).exists )
Expand All @@ -64,15 +64,15 @@ test( 'hides settings menu after clicking elsewhere', async t => {
.notOk();
} );

test( 'can open settings menu and go to bookmarks', async t => {
test( 'can open settings menu and go to bookmarks', async ( t ) => {
await t
.click( `.${CLASSES.SETTINGS_MENU__BUTTON}` )
.click( `.${CLASSES.SETTINGS_MENU__BOOKMARKS}` )
.expect( Selector( `.${CLASSES.ADDRESS_INPUT}` ).value )
.eql( 'safe-browser://bookmarks' );
} );

test( 'can open settings menu and go to history', async t => {
test( 'can open settings menu and go to history', async ( t ) => {
await t
.click( `.${CLASSES.SETTINGS_MENU__BUTTON}` )
.click( `.${CLASSES.SETTINGS_MENU__HISTORY}` )
Expand Down
6 changes: 5 additions & 1 deletion __tests__/components/AddressBarInput.spec.tsx
Expand Up @@ -42,7 +42,11 @@ describe( 'AddressBarInput', () => {
onSelect: jest.fn(),
onFocus: jest.fn(),
activeTab: { isLoading: false },
updateTab: jest.fn()
updateTab: jest.fn(),
safeBrowserApp: {
isMock: false,
experimentsEnabled: false
}
};
} );

Expand Down
7 changes: 3 additions & 4 deletions __tests__/components/Bookmarks.spec.tsx
Expand Up @@ -16,13 +16,12 @@ describe( 'Bookmarks', () => {
addTab: jest.fn()
};

wrapper = shallow( <Bookmarks {...props} /> );
instance = wrapper.instance();
wrapper = mount( <Bookmarks {...props} /> );
} );

describe( 'constructor( props )', () => {
it( 'should have name Bookmarks', () => {
expect( instance.constructor.name ).toBe( 'Bookmarks' );
expect( Bookmarks.name ).toBe( 'Bookmarks' );
} );
} );

Expand Down Expand Up @@ -52,7 +51,7 @@ describe( 'Bookmarks', () => {
describe( 'props', () => {
describe( 'tabs', () => {
it( 'tabs length should be "0" by default', () => {
expect( instance.props.bookmarks.length ).toBe( 0 );
expect( wrapper.props().bookmarks.length ).toBe( 0 );
} );
} );
} );
Expand Down
17 changes: 6 additions & 11 deletions __tests__/components/UrlList.spec.tsx
@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { mount } from 'enzyme';

import { UrlList } from '$Components/UrlList';
import { Table, TableRow } from 'nessie-ui';
Expand All @@ -14,24 +14,19 @@ describe( 'UrlList', () => {
list: []
};

wrapper = shallow( <UrlList {...props} /> );
instance = wrapper.instance();
wrapper = mount( <UrlList {...props} /> );
} );

describe( 'constructor( props )', () => {
it( 'should have name UrlList', () => {
expect( instance.constructor.name ).toBe( 'UrlList' );
expect( UrlList.name ).toBe( 'UrlList' );
} );
} );

describe( 'render() with one tab', () => {
beforeEach( () => {
props = { ...props, list: ['hello'] };
wrapper = shallow( <UrlList {...props} /> );
} );

it( 'should have one link', () => {
wrapper = shallow( <UrlList {...props} /> );
props = { ...props, list: ['hello'] };
wrapper = mount( <UrlList {...props} /> );
expect( wrapper.find( 'a' ).length ).toBe( 1 );
} );

Expand All @@ -46,7 +41,7 @@ describe( 'UrlList', () => {
describe( 'props', () => {
describe( 'list', () => {
it( 'list length should be "0" by default', () => {
expect( instance.props.list.length ).toBe( 0 );
expect( wrapper.props().list.length ).toBe( 0 );
} );
} );
} );
Expand Down
6 changes: 3 additions & 3 deletions app/background.manageRemoteCalls.ts
Expand Up @@ -17,15 +17,15 @@ const allApiCalls = {
* updating the remoteCall.
* @param {[type]} store Redux store
*/
export const manageRemoteCalls = async store => {
export const manageRemoteCalls = async ( store ) => {
const state = store.getState();
const { remoteCalls } = state;
if ( cachedRemoteCallArray !== remoteCalls ) {
cachedRemoteCallArray = remoteCalls;

if ( !remoteCalls.length ) return;
if ( remoteCalls.length === 0 ) return;

remoteCalls.forEach( async theCall => {
remoteCalls.forEach( async ( theCall ) => {
if ( !theCall.inProgress && !pendingCallIds[theCall.id] ) {
// hack to prevent multi store triggering.
// not needed for auth via redux.
Expand Down
4 changes: 2 additions & 2 deletions app/components/AddressBar/Input/Input.tsx
Expand Up @@ -81,7 +81,7 @@ class AddressBarInput extends Component<{}, AddressBarInputState> {
}
}

handleFocus = event => {
handleFocus = ( event ) => {
const { onFocus } = this.props;
onFocus();
event.target.select();
Expand Down Expand Up @@ -123,7 +123,7 @@ class AddressBarInput extends Component<{}, AddressBarInputState> {
size="large"
value={address}
type="text"
ref={input => {
ref={( input ) => {
this.addressInput = input;
if (
isSelected &&
Expand Down
53 changes: 24 additions & 29 deletions app/components/PerusePages/Bookmarks/Bookmarks.tsx
Expand Up @@ -5,35 +5,30 @@ import styles from './bookmarks.css';
import { CLASSES } from '$Constants';

interface BookmarksProps {
isActiveTab?: boolean;
bookmarks: Array<any>;
addTab: ( ...args: Array<any> ) => any;
addTab?: ( ...args: Array<any> ) => any;
}
export class Bookmarks extends Component<BookmarksProps, {}> {
static defaultProps = {
bookmarks: []
};

render() {
const { bookmarks, isActiveTab, addTab } = this.props;
const bookmarkList = bookmarks.map( ( bookmark ) => bookmark.url );
let moddedClass = styles.tab;
if ( isActiveTab ) {
moddedClass = styles.activeTab;
}
return (
<div className={moddedClass}>
<div className={`${styles.container}`}>
<Page
className={`${CLASSES.SAFE_BROWSER_PAGE} ${styles.page}`}
overflow="auto"
>
<PageHeader>
<H1 title="Bookmarks" />
</PageHeader>
<UrlList list={bookmarkList} addTab={addTab} />
</Page>
</div>
</div>
);
export const Bookmarks = ( props: BookmarksProps = { bookmarks: [] } ) => {
const { bookmarks, isActiveTab, addTab } = props;
const bookmarkList = bookmarks.map( ( bookmark ) => bookmark.url );
let moddedClass = styles.tab;
if ( isActiveTab ) {
moddedClass = styles.activeTab;
}
}
return (
<div className={moddedClass}>
<div className={`${styles.container}`}>
<Page
className={`${CLASSES.SAFE_BROWSER_PAGE} ${styles.page}`}
overflow="auto"
>
<PageHeader>
<H1 title="Bookmarks" />
</PageHeader>
<UrlList list={bookmarkList} addTab={addTab} />
</Page>
</div>
</div>
);
};

0 comments on commit cc99c0d

Please sign in to comment.