Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
Format source to comply with JavaScript Standard Style
Browse files Browse the repository at this point in the history
Starter kit supposedly based coding standards on the "JavaScript Standard Style" (https://standardjs.com), but there were several rules in the `.eslintrc.json` configuration that rather defeated the purpose; if you're going to follow a style guide, *especially* for a tool used as a basis for other people's, often beginners', projects, having standard-compliant formatting is a practical necessity.
  • Loading branch information
jdickey committed Apr 29, 2017
1 parent 7ea0735 commit 4fa57e8
Show file tree
Hide file tree
Showing 29 changed files with 429 additions and 440 deletions.
12 changes: 0 additions & 12 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,5 @@
"node": true
},
"rules": {
"comma-dangle": 1,
"array-bracket-spacing": ["error", "never"],
"babel/object-curly-spacing": 1,
"global-strict": 0,
"semi": 1,
"no-extra-semi": 1,
"no-trailing-spaces": [1, {
"skipBlankLines": true
}],
"react/jsx-indent": [2, "tab"],
"no-tabs": 0,
"indent": ["error", "tab"]
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ jspm_packages

# Optional REPL history
.node_repl_history
yarn.lock
28 changes: 14 additions & 14 deletions common/actions/auth/index.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import {
loginAPI,
setLocalToken,
resetLocalToken
loginAPI,
setLocalToken,
resetLocalToken
} from 'api/AuthSvc'
import {resultOK} from 'api/utils'
import { resultOK } from 'api/utils'

export const LOGIN_AUTH_SUCCESS = 'LOGIN_AUTH_SUCCESS'
export const LOGIN_AUTH_FAIL = 'LOGIN_AUTH_FAIL'

export const LOGOUT_AUTH_SUCCESS = 'LOGOUT_AUTH_SUCCESS'

export function LOGIN_AUTH (data) {
return async() => {
let result = await loginAPI(data)
if (!resultOK(result)) {
return {type: LOGIN_AUTH_FAIL, error: result.data}
}
setLocalToken(result.token)
return {type: LOGIN_AUTH_SUCCESS, result: result.data}
}
return async () => {
let result = await loginAPI(data)
if (!resultOK(result)) {
return { type: LOGIN_AUTH_FAIL, error: result.data }
}
setLocalToken(result.token)
return { type: LOGIN_AUTH_SUCCESS, result: result.data }
}
}

export function LOGOUT_AUTH () {
resetLocalToken()
return {type: LOGOUT_AUTH_SUCCESS}
resetLocalToken()
return { type: LOGOUT_AUTH_SUCCESS }
}
54 changes: 27 additions & 27 deletions common/actions/auth/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@ const middlewares = [thunk]
const mockStore = configureMockStore(middlewares)

describe('Auth actions', () => {
it('creates LOGIN_AUTH_SUCCESS when LOGIN_AUTH was successful', done => {
const expectedActions = {
type: actions.LOGIN_AUTH_SUCCESS,
result: {
token: 'nothing'
}
}
it('creates LOGIN_AUTH_SUCCESS when LOGIN_AUTH was successful', done => {
const expectedActions = {
type: actions.LOGIN_AUTH_SUCCESS,
result: {
token: 'nothing'
}
}

const store = mockStore({})
return store.dispatch(actions.LOGIN_AUTH({})).then(res => {
expect(res).toEqual(expectedActions)
done()
})
})
const store = mockStore({})
return store.dispatch(actions.LOGIN_AUTH({})).then(res => {
expect(res).toEqual(expectedActions)
done()
})
})

// JSON DB should handle it too.
// it('creates LOGIN_AUTH_FAIL when LOGIN_AUTH was failed', (done) => {
//
// const expectedActions = {
// type: actions.LOGIN_AUTH_FAIL,
// error: {}
// }
//
// const store = mockStore({})
// return store.dispatch(actions.LOGIN_AUTH({})).then((res) => {
// expect(res).toEqual(expectedActions)
// done()
// })
// })
// JSON DB should handle it too.
// it('creates LOGIN_AUTH_FAIL when LOGIN_AUTH was failed', (done) => {
//
// const expectedActions = {
// type: actions.LOGIN_AUTH_FAIL,
// error: {}
// }
//
// const store = mockStore({})
// return store.dispatch(actions.LOGIN_AUTH({})).then((res) => {
// expect(res).toEqual(expectedActions)
// done()
// })
// })
})
16 changes: 8 additions & 8 deletions common/actions/dashboard/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {getStatisticsAPI} from 'api/StatisticsSvc'
import {resultOK} from 'api/utils'
import { getStatisticsAPI } from 'api/StatisticsSvc'
import { resultOK } from 'api/utils'

// define action types
export const GET_STATISTICS_SUCCESS = 'GET_STATISTICS_SUCCESS'
export const GET_STATISTICS_FAIL = 'GET_STATISTICS_FAIL'

export const GET_STATISTICS = async() => {
let result = await getStatisticsAPI()
if (!resultOK(result)) {
return {type: GET_STATISTICS_FAIL, error: result.data}
}
return {type: GET_STATISTICS_SUCCESS, result: result.data}
export const GET_STATISTICS = async () => {
let result = await getStatisticsAPI()
if (!resultOK(result)) {
return { type: GET_STATISTICS_FAIL, error: result.data }
}
return { type: GET_STATISTICS_SUCCESS, result: result.data }
}
24 changes: 12 additions & 12 deletions common/actions/dashboard/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ const middlewares = [thunk]
const mockStore = configureMockStore(middlewares)

describe('Dashboard actions', () => {
it('creates GET_STATISTICS_SUCCESS when GET_STATISTICS was successful', done => {
const store = mockStore({})
return store.dispatch(actions.GET_STATISTICS).then(res => {
const {result} = res
const expectedAction = {
type: actions.GET_STATISTICS_SUCCESS,
result
}
it('creates GET_STATISTICS_SUCCESS when GET_STATISTICS was successful', done => {
const store = mockStore({})
return store.dispatch(actions.GET_STATISTICS).then(res => {
const { result } = res
const expectedAction = {
type: actions.GET_STATISTICS_SUCCESS,
result
}

expect(res).toEqual(expectedAction)
done()
})
})
expect(res).toEqual(expectedAction)
done()
})
})
})
16 changes: 8 additions & 8 deletions common/actions/inbox/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {resultOK} from 'api/utils'
import {getInboxAPI} from 'api/InboxSvc'
import { resultOK } from 'api/utils'
import { getInboxAPI } from 'api/InboxSvc'

// define action types
export const GET_INBOX_SUCCESS = 'GET_INBOX_SUCCESS'
export const GET_INBOX_FAIL = 'GET_INBOX_FAIL'

export const GET_INBOX = async() => {
let result = await getInboxAPI()
if (!resultOK(result)) {
return {type: GET_INBOX_FAIL, error: result.data}
}
return {type: GET_INBOX_SUCCESS, result: result.data}
export const GET_INBOX = async () => {
let result = await getInboxAPI()
if (!resultOK(result)) {
return { type: GET_INBOX_FAIL, error: result.data }
}
return { type: GET_INBOX_SUCCESS, result: result.data }
}
24 changes: 12 additions & 12 deletions common/actions/inbox/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ const middlewares = [thunk]
const mockStore = configureMockStore(middlewares)

describe('Inbox actions', () => {
it('creates GET_INBOX_SUCCESS when GET_INBOX was successful', done => {
const store = mockStore({})
return store.dispatch(actions.GET_INBOX).then(res => {
const {result} = res
const expectedAction = {
type: actions.GET_INBOX_SUCCESS,
result
}
it('creates GET_INBOX_SUCCESS when GET_INBOX was successful', done => {
const store = mockStore({})
return store.dispatch(actions.GET_INBOX).then(res => {
const { result } = res
const expectedAction = {
type: actions.GET_INBOX_SUCCESS,
result
}

expect(res).toEqual(expectedAction)
done()
})
})
expect(res).toEqual(expectedAction)
done()
})
})
})
6 changes: 3 additions & 3 deletions common/actions/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ export const UI_CLOSE_SIDEBAR = 'UI_CLOSE_SIDEBAR'
export const UI_WINDOW_RESIZE = 'UI_WINDOW_RESIZE'

export const CLOSE_SIDEBAR = () => ({
type: UI_CLOSE_SIDEBAR
type: UI_CLOSE_SIDEBAR
})

export const OPEN_SIDEBAR = () => ({
type: UI_OPEN_SIDEBAR
type: UI_OPEN_SIDEBAR
})

export const WINDOW_RESIZE = () => ({
type: UI_WINDOW_RESIZE
type: UI_WINDOW_RESIZE
})
48 changes: 24 additions & 24 deletions common/actions/layout/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,35 @@ const middlewares = [thunk]
const mockStore = configureMockStore(middlewares)

describe('Layout actions', () => {
it('creates UI_CLOSE_SIDEBAR after CLOSE_SIDEBAR was dispatched', () => {
const expectedAction = {
type: actions.UI_CLOSE_SIDEBAR
}
it('creates UI_CLOSE_SIDEBAR after CLOSE_SIDEBAR was dispatched', () => {
const expectedAction = {
type: actions.UI_CLOSE_SIDEBAR
}

const store = mockStore({})
const result = store.dispatch(actions.CLOSE_SIDEBAR)
const store = mockStore({})
const result = store.dispatch(actions.CLOSE_SIDEBAR)

expect(result).toEqual(expectedAction)
})
expect(result).toEqual(expectedAction)
})

it('creates UI_OPEN_SIDEBAR after OPEN_SIDEBAR was dispatched', () => {
const expectedAction = {
type: actions.UI_OPEN_SIDEBAR
}
it('creates UI_OPEN_SIDEBAR after OPEN_SIDEBAR was dispatched', () => {
const expectedAction = {
type: actions.UI_OPEN_SIDEBAR
}

const store = mockStore({})
const result = store.dispatch(actions.OPEN_SIDEBAR)
const store = mockStore({})
const result = store.dispatch(actions.OPEN_SIDEBAR)

expect(result).toEqual(expectedAction)
})
expect(result).toEqual(expectedAction)
})

it('creates UI_WINDOW_RESIZE after WINDOW_RESIZE was dispatched', () => {
const expectedAction = {
type: actions.UI_WINDOW_RESIZE
}
it('creates UI_WINDOW_RESIZE after WINDOW_RESIZE was dispatched', () => {
const expectedAction = {
type: actions.UI_WINDOW_RESIZE
}

const store = mockStore({})
const result = store.dispatch(actions.WINDOW_RESIZE)
expect(result).toEqual(expectedAction)
})
const store = mockStore({})
const result = store.dispatch(actions.WINDOW_RESIZE)
expect(result).toEqual(expectedAction)
})
})
24 changes: 12 additions & 12 deletions common/api/AuthSvc.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import {post} from './utils'
import { post } from './utils'
import * as store from 'store2'

export function getLocalToken () {
return store.get('auth_token')
return store.get('auth_token')
}

export function resetLocalToken () {
store.remove('auth_token')
store.remove('auth_token')
}
export function setLocalToken (token) {
store.set('auth_token', token)
store.set('auth_token', token)
}

export function isLoggedIn () {
return getLocalToken() !== null
return getLocalToken() !== null
}

export async function loginAPI (data) {
if (process.env.BUILD_DEMO) {
return {
ok: true,
token: 'Just_for_demo'
}
}
return post('/auth', data)
if (process.env.BUILD_DEMO) {
return {
ok: true,
token: 'Just_for_demo'
}
}
return post('/auth', data)
}
2 changes: 1 addition & 1 deletion common/api/InboxSvc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {get} from './utils'

export async function getInboxAPI () {
return get('https://jsonplaceholder.typicode.com/users')
return get('https://jsonplaceholder.typicode.com/users')
}
2 changes: 1 addition & 1 deletion common/api/StatisticsSvc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {get} from './utils'

export async function getStatisticsAPI () {
return get('https://jsonplaceholder.typicode.com/posts?userId=1')
return get('https://jsonplaceholder.typicode.com/posts?userId=1')
}
Loading

0 comments on commit 4fa57e8

Please sign in to comment.