Skip to content

Commit

Permalink
add prettier config and reformat everything
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffmcaffer committed Mar 3, 2018
1 parent b839f5d commit 2e5536e
Show file tree
Hide file tree
Showing 66 changed files with 863 additions and 798 deletions.
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
printWidth: 120
singleQuote: true
semi: false
7 changes: 4 additions & 3 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">

<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,600" rel="stylesheet">

<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
Expand Down Expand Up @@ -48,4 +49,4 @@
-->
</body>

</html>
</html>
12 changes: 6 additions & 6 deletions src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright (c) Microsoft Corporation and others. Licensed under the MIT license.
// SPDX-License-Identifier: MIT

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'

it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
});
const div = document.createElement('div')
ReactDOM.render(<App />, div)
})
4 changes: 2 additions & 2 deletions src/actions/curationActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { curate, getCuration } from '../api/clearlyDefined'
export const CURATION_POST = 'CURATION_POST'

export function getCurationAction(token, entity, name) {
return (dispatch) => {
return dispatch => {
const actions = asyncActions(name)
dispatch(actions.start())
return getCuration(token, entity).then(
Expand All @@ -18,7 +18,7 @@ export function getCurationAction(token, entity, name) {
}

export function curateAction(token, entity, spec) {
return (dispatch) => {
return dispatch => {
const actions = asyncActions(CURATION_POST)
dispatch(actions.start())
return curate(token, entity, spec).then(
Expand Down
8 changes: 4 additions & 4 deletions src/actions/definitionActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const DEFINITION_LIST = 'DEFINITION_LIST'
export const DEFINITION_BODIES = 'DEFINITION_BODIES'

export function getDefinitionAction(token, entity, name) {
return (dispatch) => {
return dispatch => {
const actions = asyncActions(name)
dispatch(actions.start())
return getDefinition(token, entity).then(
Expand All @@ -19,7 +19,7 @@ export function getDefinitionAction(token, entity, name) {
}

export function getDefinitionsAction(token, entities) {
return (dispatch) => {
return dispatch => {
const actions = asyncActions(DEFINITION_BODIES)
dispatch(actions.start())
return getDefinitions(token, entities).then(
Expand All @@ -30,7 +30,7 @@ export function getDefinitionsAction(token, entities) {
}

export function getDefinitionListAction(token, prefix, force) {
return (dispatch) => {
return dispatch => {
const actions = asyncActions(DEFINITION_LIST)
dispatch(actions.start())
return getDefinitionList(token, prefix, force).then(
Expand All @@ -41,7 +41,7 @@ export function getDefinitionListAction(token, prefix, force) {
}

export function previewDefinitionAction(token, entity, curation, name) {
return (dispatch) => {
return dispatch => {
const actions = asyncActions(name)
dispatch(actions.start())
return previewDefinition(token, entity, curation).then(
Expand Down
4 changes: 2 additions & 2 deletions src/actions/harvestActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const HARVEST_POST = 'HARVEST_POST'
export const HARVEST_GET = 'HARVEST_GET'

export function harvestAction(token, spec) {
return (dispatch) => {
return dispatch => {
const actions = asyncActions(HARVEST_POST)
dispatch(actions.start())
return harvest(token, spec).then(
Expand All @@ -19,7 +19,7 @@ export function harvestAction(token, spec) {
}

export function getHarvestOutputAction(token, entity, name) {
return (dispatch) => {
return dispatch => {
const actions = asyncActions(name)
dispatch(actions.start())
return getHarvestResults(token, entity).then(
Expand Down
4 changes: 2 additions & 2 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

export function asyncActions(actionType, group = null) {
return {
start: (context) => ({
start: context => ({
type: actionType,
group,
context
Expand All @@ -21,4 +21,4 @@ export function asyncActions(actionType, group = null) {
context
})
}
}
}
4 changes: 2 additions & 2 deletions src/actions/sessionActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ export const LOGIN = 'LOGIN'
export const LOGOUT = 'LOGOUT'

export function login(token, permissions) {
return (dispatch) => dispatch({ type: LOGIN, token, permissions })
return dispatch => dispatch({ type: LOGIN, token, permissions })
}

export function logout(error) {
return (dispatch) => {
return dispatch => {
dispatch({ type: LOGOUT, error })
dispatch(uiRedirect(ROUTE_ROOT))
}
Expand Down
6 changes: 3 additions & 3 deletions src/actions/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function uiRedirect(to) {

let nextNotificationId = 0
export function uiNotificationNew(message) {
return { type: UI_NOTIFICATION_NEW, message: { ...message, id: nextNotificationId++} }
return { type: UI_NOTIFICATION_NEW, message: { ...message, id: nextNotificationId++ } }
}

export function uiNotificationDelete(message) {
Expand Down Expand Up @@ -67,11 +67,11 @@ export function uiCurateUpdateFilter(value) {
}

export function uiCurateGetCuration(token, entity) {
return getCurationAction(token, entity, entity.pr ? UI_CURATE_GET_PROPOSED: UI_CURATE_GET)
return getCurationAction(token, entity, entity.pr ? UI_CURATE_GET_PROPOSED : UI_CURATE_GET)
}

export function uiCurateGetDefinition(token, entity) {
return getDefinitionAction(token, entity, entity.pr ? UI_CURATE_GET_DEFINITION_PROPOSED: UI_CURATE_GET_DEFINITION)
return getDefinitionAction(token, entity, entity.pr ? UI_CURATE_GET_DEFINITION_PROPOSED : UI_CURATE_GET_DEFINITION)
}

export function uiCurateGetDefinitionPreview(token, entity, curation) {
Expand Down
31 changes: 13 additions & 18 deletions src/api/clearlyDefined.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function getServiceDefaultUrl() {
case 'test':
return API_DEVELOP
case 'production':
// TODO this needs to be replaced when we do a prod deployment. We want a "production" build deployed in
// TODO this needs to be replaced when we do a prod deployment. We want a "production" build deployed in
// the dev environment but of course it will need to point to the dev server. Don't know how to do that.
return API_DEVELOP
default:
Expand Down Expand Up @@ -62,7 +62,7 @@ export function getDefinitions(token, list) {
}

export async function getDefinitionList(token, prefix, force = false) {
if (!force && lastFetchDefinitionList && (Date.now() - lastFetchDefinitionList < definitionListTTL))
if (!force && lastFetchDefinitionList && Date.now() - lastFetchDefinitionList < definitionListTTL)
return { list: definitionList }
const list = await get(url(`${DEFINITIONS}/${prefix || ''}`), token)
lastFetchDefinitionList = Date.now()
Expand Down Expand Up @@ -106,34 +106,32 @@ export function getMavenRevisions(token, path) {

export function url(path, query) {
path = apiHome + '/' + path
if (!query)
return path
if (!query) return path

const queryString = toPairs(query)
// take only having values ones (0 is allowed)
.filter((p) => p[1] || p[1] === 0)
.filter(p => p[1] || p[1] === 0)
// sort() is essential for caching
.sort()
// compose key=value&key2=value with encoded keys and values
.map((p) => p.map(encodeURIComponent).join('=')).join('&')
.map(p => p.map(encodeURIComponent).join('='))
.join('&')
return `${path}?${queryString}`
}

function getHeaders(token) {
const result = {
'Content-Type': 'application/json; charset=utf-8'
}
if (token)
result.Authorization = 'Bearer ' + token
if (token) result.Authorization = 'Bearer ' + token
return result
}

function handleResponse(response) {
// reject if code is out of range 200-299
if (!response || !response.ok) {
const err = new Error(response ? response.statusText : 'Error')
if (response)
err.status = response.status
if (response) err.status = response.status
throw err
}
if (response.status === 204) {
Expand All @@ -158,18 +156,16 @@ function post(url, token, payload) {
return fetch(url, {
headers: getHeaders(token),
method: 'POST',
body: JSON.stringify(payload),
})
.then(handleResponse)
body: JSON.stringify(payload)
}).then(handleResponse)
}

function patch(url, token, payload) {
return fetch(url, {
headers: getHeaders(token),
method: 'PATCH',
body: JSON.stringify(payload)
})
.then(handleResponse)
}).then(handleResponse)
}

// function del(url, token) {
Expand All @@ -182,7 +178,6 @@ function patch(url, token, payload) {

function get(url, token) {
return fetch(url, {
headers: getHeaders(token),
})
.then(handleResponse)
headers: getHeaders(token)
}).then(handleResponse)
}
6 changes: 2 additions & 4 deletions src/components/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation and others. Licensed under the MIT license.
// SPDX-License-Identifier: MIT

import React, { Component } from 'react';
import React, { Component } from 'react'
import { Header, Footer, NotificationList } from './'

export default class App extends Component {
Expand All @@ -10,9 +10,7 @@ export default class App extends Component {
return (
<div className="App">
<Header />
<main className="App-content">
{children}
</main>
<main className="App-content">{children}</main>
<Footer />
<NotificationList />
</div>
Expand Down
10 changes: 5 additions & 5 deletions src/components/Clearly.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ import PropTypes from 'prop-types'

export const primaryColor = { color: '#0064b5' }
export const secondaryColor = { color: '#60b360' }
export const licensedColor = { color: '#38a038'}
export const describedColor = { color: '#00b294'}
export const secureColor = { color: '#409ae1'}
export const licensedColor = { color: '#38a038' }
export const describedColor = { color: '#00b294' }
export const secureColor = { color: '#409ae1' }
export const definedColor = primaryColor

export default class Clearly extends Component {
static propTypes = {
word: PropTypes.string,
style: PropTypes.object
};
}

render() {
return (
<span style={this.props.style}>
Clearly<span className="semi-bold">{this.props.children}</span>
</span>
);
)
}
}
Loading

0 comments on commit 2e5536e

Please sign in to comment.