Skip to content

Commit

Permalink
style: fix eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
kelp404 committed Oct 1, 2021
1 parent 8242c43 commit f3f5774
Show file tree
Hide file tree
Showing 20 changed files with 137 additions and 137 deletions.
16 changes: 8 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@ module.exports = {
browser: true,
commonjs: true,
es6: true,
node: true
node: true,
},
extends: [
'xo',
'xo-space',
'xo-react/space'
'xo-react/space',
],
globals: {
jest: 'readonly',
test: 'readonly',
expect: 'readonly',
beforeEach: 'readonly',
afterEach: 'readonly'
afterEach: 'readonly',
},
parser: 'babel-eslint',
parserOptions: {
ecmaFeatures: {
jsx: true
jsx: true,
},
ecmaVersion: 2018
ecmaVersion: 2018,
},
plugins: [
'react'
'react',
],
rules: {
'no-eq-null': 0,
eqeqeq: ['error', 'allow-null'],
'valid-jsdoc': ['error']
}
'valid-jsdoc': ['error'],
},
};
8 changes: 4 additions & 4 deletions __tests__/components/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ beforeEach(() => {
router = new Router({
history: history.createMemoryHistory({initialEntries: ['/']}),
routes: [
{name: 'home', uri: '/'}
]
{name: 'home', uri: '/'},
],
});
});
afterEach(() => {
Expand All @@ -27,15 +27,15 @@ test('Link component render.', () => {
test('Link component render with object props.', () => {
const route = new Route({
name: 'web',
uri: '/web?index'
uri: '/web?index',
});
jest.spyOn(utils, 'findRouteByNameInRoutes').mockImplementation(name => {
expect(name).toBe('web');
return route;
});
jest.spyOn(route, 'generateUri').mockImplementation(() => '/web?index=0');
const component = renderer.create(
<Link to={{name: 'web', params: {index: 0}}}>Web</Link>
<Link to={{name: 'web', params: {index: 0}}}>Web</Link>,
);
const tree = component.toJSON();
expect(utils.findRouteByNameInRoutes).toBeCalled();
Expand Down
6 changes: 3 additions & 3 deletions __tests__/components/router-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ beforeEach(() => {
router = new Router({
history: history.createMemoryHistory({initialEntries: ['/']}),
routes: [
{name: 'home', uri: '/'}
]
{name: 'home', uri: '/'},
],
});
router.start();
});
Expand All @@ -35,7 +35,7 @@ test('RouterView component render with a child component.', () => {
const component = renderer.create(<RouterView>Loading</RouterView>);
routerView.dispatch({
route: {component: Child},
props: {className: 'head'}
props: {className: 'head'},
});
const tree = component.toJSON();
expect(tree).toMatchSnapshot();
Expand Down
22 changes: 11 additions & 11 deletions __tests__/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ test('Initial Route without a parent.', () => {
resolve: {
user: ({userId}) => ({id: userId, name: 'User'}),
projects: () => ([
{id: 'AWgrmJp1SjjuUM2bzZXM', title: 'Project'}
])
{id: 'AWgrmJp1SjjuUM2bzZXM', title: 'Project'},
]),
},
component: () => <div/>
component: () => <div/>,
});
expect(route).toMatchSnapshot();
});
Expand All @@ -21,7 +21,7 @@ test('Initial Route with a parent.', () => {
const route = new Route({
name: 'web.dashboard',
uri: 'dashboard',
parent
parent,
});
expect(route).toMatchSnapshot();
});
Expand All @@ -32,15 +32,15 @@ test('Generate a route with the parent.', () => {
uri: '/users/{userId:[\\w-]{20}}/projects?index?sort',
resolve: {id: () => 'id'},
onEnter: () => {},
component: () => {}
component: () => {},
});
const child = new Route({
name: 'web.project',
uri: '/users/{userId:[\\w-]{20}}/projects/{projectId:[\\w-]{20}}',
resolve: {id: () => 'id'},
onEnter: () => {},
component: () => {},
parent
parent,
});
expect(parent).toMatchSnapshot();
expect(child).toMatchSnapshot();
Expand All @@ -50,7 +50,7 @@ test('Get an error on generating a route with a resolve key called "key".', () =
const func = () => new Route({
name: 'web',
uri: '/',
resolve: {key: () => null}
resolve: {key: () => null},
});

expect(func).toThrow(Error);
Expand All @@ -59,7 +59,7 @@ test('Get an error on generating a route with a resolve key called "params".', (
const func = () => new Route({
name: 'web',
uri: '/',
resolve: {params: () => null}
resolve: {params: () => null},
});

expect(func).toThrow(Error);
Expand All @@ -71,14 +71,14 @@ test('Generate the URI of the route with params', () => {
uri: '/users/{userId:[\\w-]{20}}/projects?index?sort',
resolve: {
user: ({userId}) => Promise.resolve({id: userId, name: 'User'}),
projects: () => Promise.resolve([{id: 'AWgrmJp1SjjuUM2bzZXM', title: 'Project'}])
projects: () => Promise.resolve([{id: 'AWgrmJp1SjjuUM2bzZXM', title: 'Project'}]),
},
component: () => <div/>
component: () => <div/>,
});
const uri = fakeRoute.generateUri({
userId: 'AWgrmJp1SjjuUM2bzZXM',
index: 0,
sort: 'asc'
sort: 'asc',
});
expect(uri).toMatchSnapshot();
});
40 changes: 20 additions & 20 deletions __tests__/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ beforeEach(() => {
pathname: '/',
port: '8000',
protocol: 'http:',
search: ''
search: '',
};
router = new Router({
history: history.createMemoryHistory({initialEntries: ['/']}),
Expand All @@ -27,33 +27,33 @@ beforeEach(() => {
name: 'home',
uri: '/',
onEnter: () => {},
component: () => <div>Home</div>
component: () => <div>Home</div>,
},
{
name: 'login',
uri: '/login',
onEnter: () => {},
component: () => <div>Login</div>
component: () => <div>Login</div>,
},
{
name: 'projects',
uri: '/users/{userId:[\\w-]{20}}/projects?index',
onEnter: () => {},
component: () => <div>Projects</div>
component: () => <div>Projects</div>,
},
{
isAbstract: true,
name: 'settings',
uri: '/settings',
component: () => <div>Loading</div>
component: () => <div>Loading</div>,
},
{
name: 'settings.account',
uri: '',
component: () => <div>Account</div>
}
component: () => <div>Account</div>,
},
],
errorComponent: () => <div>Error</div>
errorComponent: () => <div>Error</div>,
});
});
afterEach(() => jest.restoreAllMocks());
Expand All @@ -80,29 +80,29 @@ test('Going to a page with a route name will push the history state.', () => {
router.history.push = jest.fn(() => {});
router.go({
name: 'projects',
params: {userId: 'AWgrmJp1SjjuUM2bzZXM', index: 0}
params: {userId: 'AWgrmJp1SjjuUM2bzZXM', index: 0},
});
expect(router.history.push).toBeCalledWith(
{pathname: '/users/AWgrmJp1SjjuUM2bzZXM/projects', search: '?index=0'},
{
name: 'projects',
params: {index: 0, userId: 'AWgrmJp1SjjuUM2bzZXM'}
}
params: {index: 0, userId: 'AWgrmJp1SjjuUM2bzZXM'},
},
);
});

test('Replace a page with a route name.', () => {
router.history.replace = jest.fn(() => {});
router.go(
{name: 'projects', params: {userId: 'AWgrmJp1SjjuUM2bzZXM', index: 0}},
{replace: true}
{replace: true},
);
expect(router.history.replace).toBeCalledWith(
{pathname: '/users/AWgrmJp1SjjuUM2bzZXM/projects', search: '?index=0'},
{
name: 'projects',
params: {index: 0, userId: 'AWgrmJp1SjjuUM2bzZXM'}
}
params: {index: 0, userId: 'AWgrmJp1SjjuUM2bzZXM'},
},
);
});

Expand Down Expand Up @@ -181,7 +181,7 @@ test('Broadcast a start event.', () => {
previousRoute: route,
previousParams: {id: 'old'},
nextRoute: route,
nextParams: {id: 'new'}
nextParams: {id: 'new'},
})
.then(() => {
unsubscribe();
Expand All @@ -202,7 +202,7 @@ test('Broadcast a success event.', () => {
previousRoute: route,
previousParams: {id: 'old'},
nextRoute: route,
nextParams: {id: 'new'}
nextParams: {id: 'new'},
});
unsubscribe();
expect(onChangeSuccess).toBeCalled();
Expand Down Expand Up @@ -257,14 +257,14 @@ test('Call onEnter() of the route when the router was started.', () => {
return router.promise.then(() => {
expect(router.routes[0].onEnter).toBeCalledWith({
key: 0.1.toString(36).substr(2),
params: {}
params: {},
});
});
});

test('Render the error component when the router was started with error.', () => {
router.routes[0].resolve = {
error: () => Promise.reject(new Error())
error: () => Promise.reject(new Error()),
};
router.start();
const component = renderer.create(<RouterView>Loading</RouterView>);
Expand Down Expand Up @@ -335,7 +335,7 @@ test('Call onEnter() of the route when the history was changed.', () => {
.then(() => {
expect(router.routes[1].onEnter).toBeCalledWith({
key: 0.1.toString(36).substr(2),
params: {}
params: {},
});
});
});
Expand Down Expand Up @@ -395,7 +395,7 @@ test('Render the error component when reload with error.', () => {
return router.promise.then(() => {
jest.spyOn(Math, 'random').mockImplementation(() => 0.1);
router.routes[0].resolve = {
error: () => Promise.reject(new Error())
error: () => Promise.reject(new Error()),
};
router.routes[0].onEnter = jest.fn(() => {});
router.reload();
Expand Down
Loading

0 comments on commit f3f5774

Please sign in to comment.