Commit d6424dd9 authored by Jure's avatar Jure

Merge branch 'feat/apply-prettier' into 'master'

Feat/apply prettier

See merge request !115
parents 2bdca5ca ad164f3a
Pipeline #2736 passed with stage
in 1 minute and 47 seconds
{
"extends": [
"standard",
"plugin:react/recommended"
"plugin:react/recommended",
"prettier",
"prettier/standard",
"prettier/react",
],
"parserOptions": {
"ecmaFeatures": {
......@@ -12,9 +15,6 @@
"env": {
"browser": true
},
"plugins": [
"react"
],
"globals": {
"PUBSWEET_COMPONENTS": true
}
......
{
"*.{js, jsx}": ["prettier --write", "eslint --fix", "git add"]
}
{
"singleQuote": true,
"semi": false,
"printWidth": 80,
"trailingComma": "all"
}
language: node_js
env:
- CXX=g++-4.8
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
before_install:
- export JOBS=max
node_js:
- "4.0"
- "4"
- "5"
- "stable"
sudo: false
module.exports = {
'pubsweet-client': {
'API_ENDPOINT': 'http://localhost:3000/api'
}
API_ENDPOINT: 'http://localhost:3000/api',
},
}
module.exports = {
'pubsweet-client': {
'API_ENDPOINT': 'http://example.com',
API_ENDPOINT: 'http://example.com',
'update-subscriber': {
visible: true
}
}
visible: true,
},
},
}
......@@ -5,22 +5,27 @@
"scripts": {
"compile": "babel -d lib/ src/",
"lint": "eslint --ext js,jsx src test",
"precommit": "lint-staged",
"test": "jest",
"testci": "gitlab-ci-multi-runner exec docker test"
},
"engines": {
"node": ">=7.7.0",
"npm": ">=3.0.0"
"node": ">=8.6.0",
"npm": ">=5.0.0"
},
"author": "Collaborative Knowledge Foundation",
"license": "MIT",
"dependencies": {
"authsome": "0.0.9",
"config": "^1.21.0",
"eslint-config-prettier": "^2.6.0",
"event-source-polyfill": "^0.0.10",
"global": "^4.3.1",
"husky": "^0.14.3",
"isomorphic-fetch": "^2.1.1",
"lint-staged": "^4.2.3",
"lodash": "^4.0.0",
"prettier": "^1.7.4",
"prop-types": "^15.5.8",
"pubsweet-component-login": "^0.5.2",
"react": "^15.4.4",
......
......@@ -11,28 +11,28 @@ const collectionUrl = (collection, suffix) => {
return url
}
function getCollectionsRequest () {
function getCollectionsRequest() {
return {
type: T.GET_COLLECTIONS_REQUEST
type: T.GET_COLLECTIONS_REQUEST,
}
}
function getCollectionsFailure (error) {
function getCollectionsFailure(error) {
return {
type: T.GET_COLLECTIONS_FAILURE,
error: error
error: error,
}
}
function getCollectionsSuccess (collections) {
function getCollectionsSuccess(collections) {
return {
type: T.GET_COLLECTIONS_SUCCESS,
collections: collections,
receivedAt: Date.now()
receivedAt: Date.now(),
}
}
export function getCollections (options) {
export function getCollections(options) {
return dispatch => {
dispatch(getCollectionsRequest())
......@@ -42,191 +42,203 @@ export function getCollections (options) {
url += '?fields=' + encodeURIComponent(options.fields.join(','))
}
return api.get(url).then(
collections => dispatch(getCollectionsSuccess(collections)),
err => dispatch(getCollectionsFailure(err))
)
return api
.get(url)
.then(
collections => dispatch(getCollectionsSuccess(collections)),
err => dispatch(getCollectionsFailure(err)),
)
}
}
function getCollectionTeamsRequest () {
function getCollectionTeamsRequest() {
return {
type: T.GET_COLLECTION_TEAMS_REQUEST
type: T.GET_COLLECTION_TEAMS_REQUEST,
}
}
function getCollectionTeamsFailure (error) {
function getCollectionTeamsFailure(error) {
return {
type: T.GET_COLLECTION_TEAMS_FAILURE,
error: error
error: error,
}
}
function getCollectionTeamsSuccess (teams) {
function getCollectionTeamsSuccess(teams) {
return {
type: T.GET_COLLECTION_TEAMS_SUCCESS,
teams,
receivedAt: Date.now()
receivedAt: Date.now(),
}
}
export function getCollectionTeams (collection) {
export function getCollectionTeams(collection) {
return dispatch => {
dispatch(getCollectionTeamsRequest())
let url = collectionUrl(collection, 'teams')
return api.get(url).then(
teams => dispatch(getCollectionTeamsSuccess(teams)),
err => dispatch(getCollectionTeamsFailure(err))
)
return api
.get(url)
.then(
teams => dispatch(getCollectionTeamsSuccess(teams)),
err => dispatch(getCollectionTeamsFailure(err)),
)
}
}
function createCollectionRequest (collection) {
function createCollectionRequest(collection) {
return {
type: T.CREATE_COLLECTION_REQUEST,
collection: collection
collection: collection,
}
}
function createCollectionSuccess (collection) {
function createCollectionSuccess(collection) {
return {
type: T.CREATE_COLLECTION_SUCCESS,
collection: collection
collection: collection,
}
}
function createCollectionFailure (collection, error) {
function createCollectionFailure(collection, error) {
return {
type: T.CREATE_COLLECTION_FAILURE,
isFetching: false,
collection: collection,
error: error
error: error,
}
}
export function createCollection (collection) {
return (dispatch) => {
export function createCollection(collection) {
return dispatch => {
dispatch(createCollectionRequest(collection))
const url = collectionUrl()
return api.create(url, collection).then(
collection => dispatch(createCollectionSuccess(collection)),
err => dispatch(createCollectionFailure(collection, err))
)
return api
.create(url, collection)
.then(
collection => dispatch(createCollectionSuccess(collection)),
err => dispatch(createCollectionFailure(collection, err)),
)
}
}
function getCollectionRequest (collection) {
function getCollectionRequest(collection) {
return {
type: T.GET_COLLECTION_REQUEST,
collection: collection
collection: collection,
}
}
function getCollectionSuccess (collection) {
function getCollectionSuccess(collection) {
return {
type: T.GET_COLLECTION_SUCCESS,
collection: collection,
receivedAt: Date.now()
receivedAt: Date.now(),
}
}
function getCollectionFailure (collection, error) {
function getCollectionFailure(collection, error) {
return {
type: T.GET_COLLECTION_FAILURE,
isFetching: false,
collection: collection,
error: error
error: error,
}
}
export function getCollection (collection) {
export function getCollection(collection) {
return dispatch => {
dispatch(getCollectionRequest(collection))
const url = collectionUrl(collection)
return api.get(url).then(
collection => dispatch(getCollectionSuccess(collection)),
err => dispatch(getCollectionFailure(collection, err))
)
return api
.get(url)
.then(
collection => dispatch(getCollectionSuccess(collection)),
err => dispatch(getCollectionFailure(collection, err)),
)
}
}
function updateCollectionRequest (collection) {
function updateCollectionRequest(collection) {
return {
type: T.UPDATE_COLLECTION_REQUEST,
collection: collection
collection: collection,
}
}
function updateCollectionSuccess (collection, update) {
function updateCollectionSuccess(collection, update) {
return {
type: T.UPDATE_COLLECTION_SUCCESS,
collection: collection,
update: update,
receivedAt: Date.now()
receivedAt: Date.now(),
}
}
function updateCollectionFailure (collection, error) {
function updateCollectionFailure(collection, error) {
return {
type: T.UPDATE_COLLECTION_FAILURE,
isFetching: false,
collection: collection,
error: error
error: error,
}
}
export function updateCollection (collection) {
return (dispatch) => {
export function updateCollection(collection) {
return dispatch => {
dispatch(updateCollectionRequest(collection))
const url = collectionUrl(collection)
return api.update(url, collection).then(
update => dispatch(updateCollectionSuccess(collection, update)),
err => dispatch(updateCollectionFailure(collection, err))
)
return api
.update(url, collection)
.then(
update => dispatch(updateCollectionSuccess(collection, update)),
err => dispatch(updateCollectionFailure(collection, err)),
)
}
}
function deleteCollectionRequest (collection) {
function deleteCollectionRequest(collection) {
return {
type: T.DELETE_COLLECTION_REQUEST,
collection: collection,
update: {deleted: true}
update: { deleted: true },
}
}
function deleteCollectionSuccess (collection) {
function deleteCollectionSuccess(collection) {
return {
type: T.DELETE_COLLECTION_SUCCESS,
collection: collection
collection: collection,
}
}
function deleteCollectionFailure (collection, error) {
function deleteCollectionFailure(collection, error) {
return {
type: T.DELETE_COLLECTION_FAILURE,
collection: collection,
update: {deleted: undefined},
error: error
update: { deleted: undefined },
error: error,
}
}
export function deleteCollection (collection) {
return (dispatch) => {
export function deleteCollection(collection) {
return dispatch => {
dispatch(deleteCollectionRequest(collection))
const url = collectionUrl(collection)
return api.remove(url).then(
() => dispatch(deleteCollectionSuccess(collection)),
err => dispatch(deleteCollectionFailure(collection, err))
)
return api
.remove(url)
.then(
() => dispatch(deleteCollectionSuccess(collection)),
err => dispatch(deleteCollectionFailure(collection, err)),
)
}
}
import * as api from '../helpers/api'
import * as T from './types'
function getCurrentUserRequest () {
function getCurrentUserRequest() {
return {
type: T.GET_CURRENT_USER_REQUEST
type: T.GET_CURRENT_USER_REQUEST,
}
}
function getCurrentUserSuccess (user) {
function getCurrentUserSuccess(user) {
return {
type: T.GET_CURRENT_USER_SUCCESS,
user
user,
}
}
function getCurrentUserFailure (error) {
function getCurrentUserFailure(error) {
return {
type: T.GET_CURRENT_USER_FAILURE,
error
error,
}
}
export function getCurrentUser () {
export function getCurrentUser() {
return dispatch => {
dispatch(getCurrentUserRequest())
return api.get('/users/authenticate').then(
user => dispatch(getCurrentUserSuccess(user))
).catch(
err => dispatch(getCurrentUserFailure(err))
)
return api
.get('/users/authenticate')
.then(user => dispatch(getCurrentUserSuccess(user)))
.catch(err => dispatch(getCurrentUserFailure(err)))
}
}
import request from '../helpers/api'
import * as T from './types'
function fileUploadRequest () {
function fileUploadRequest() {
return {
type: T.FILE_UPLOAD_REQUEST,
isFetching: true
isFetching: true,
}
}
function fileUploadSuccess (file) {
function fileUploadSuccess(file) {
return {
type: T.FILE_UPLOAD_SUCCESS,
isFetching: false,
file: file
file: file,
}
}
function fileUploadFailure (message) {
function fileUploadFailure(message) {
return {
type: T.FILE_UPLOAD_FAILURE,
isFetching: false,
error: message
error: message,
}
}
export function fileUpload (file) {
return (dispatch) => {
export function fileUpload(file) {
return dispatch => {
dispatch(fileUploadRequest())
const data = new FormData()
......@@ -34,16 +34,15 @@ export function fileUpload (file) {
let opts = {
method: 'POST',
headers: {
'Accept': 'text/plain' // the response is a URL
Accept: 'text/plain', // the response is a URL
// TODO: set the Location header of the response instead
},
body: data
body: data,
}
return request('/upload', opts)
.then(
file => dispatch(fileUploadSuccess(file)),
err => dispatch(fileUploadFailure(err))
)
return request('/upload', opts).then(
file => dispatch(fileUploadSuccess(file)),
err => dispatch(fileUploadFailure(err)),
)
}
}
......@@ -19,31 +19,31 @@ export const collectionUrl = (collection, suffix) => {
return url
}
function getFragmentsRequest (collection) {
function getFragmentsRequest(collection) {
return {
type: T.GET_FRAGMENTS_REQUEST,
collection: collection
collection: collection,
}
}
function getFragmentsSuccess (collection, fragments) {
function getFragmentsSuccess(collection, fragments) {
return {
type: T.GET_FRAGMENTS_SUCCESS,
collection: collection,
fragments: fragments,
receivedAt: Date.now()
receivedAt: Date.now(),
}
}
function getFragmentsFailure (error) {
function getFragmentsFailure(error) {
return {
type: T.GET_FRAGMENTS_FAILURE,
error: error
error: error,
}
}
export function getFragments (collection, options) {
return (dispatch) => {
export function getFragments(collection, options) {
return dispatch => {
dispatch(getFragmentsRequest(collection))
let url = collectionUrl(collection, 'fragments')
......@@ -52,159 +52,169 @@ export function getFragments (collection, options) {
url += '?fields=' + encodeURIComponent(options.fields.join(','))
}
return api.get(url).then(
fragments => dispatch(getFragmentsSuccess(collection, fragments)),
err => dispatch(getFragmentsFailure(err))
)
return api
.get(url)
.then(
fragments => dispatch(getFragmentsSuccess(collection, fragments)),
err => dispatch(getFragmentsFailure(err)),
)
}
}
function createFragmentRequest (fragment) {
function createFragmentRequest(fragment) {
return {
type: T.CREATE_FRAGMENT_REQUEST,
fragment: fragment
fragment: fragment,
}
}
function createFragmentSuccess (collection, fragment) {
function createFragmentSuccess(collection, fragment) {
return {
type: T.CREATE_FRAGMENT_SUCCESS,
collection: collection,
fragment: fragment
fragment: fragment,
}
}
function createFragmentFailure (fragment, error) {
function createFragmentFailure(fragment, error) {
return {
type: T.CREATE_FRAGMENT_FAILURE,
isFetching: false,
fragment: fragment,
error: error
error: error,
}
}
export function createFragment (collection, fragment) {
return (dispatch) => {
export function createFragment(collection, fragment) {
return dispatch => {
dispatch(createFragmentRequest(fragment))
const url = fragmentUrl(collection, fragment)
return api.create(url, fragment).then(
fragment => dispatch(createFragmentSuccess(collection, fragment)),
err => dispatch(createFragmentFailure(fragment, err))
)
return api
.create(url, fragment)
.then(
fragment => dispatch(createFragmentSuccess(collection, fragment)),
err => dispatch(createFragmentFailure(fragment, err)),
)
}
}
function getFragmentRequest (fragment) {
function getFragmentRequest(fragment) {
return {
type: T.GET_FRAGMENT_REQUEST,
fragment: fragment
fragment: fragment,
}
}
function getFragmentSuccess (fragment) {
function getFragmentSuccess(fragment) {
return {
type: T.GET_FRAGMENT_SUCCESS,
fragment: fragment,
receivedAt: Date.now()
receivedAt: Date.now(),
}
}
function getFragmentFailure (fragment, error) {
function getFragmentFailure(fragment, error) {
return {
type: T.GET_FRAGMENT_FAILURE,
isFetching: false,
fragment: fragment,
error: error
error: error,
}
}
export function getFragment (collection, fragment) {
export function getFragment(collection, fragment) {
return dispatch => {
dispatch(getFragmentRequest(fragment))
const url = fragmentUrl(collection, fragment)
return api.get(url).then(
fragment => dispatch(getFragmentSuccess(fragment)),
err => dispatch(getFragmentFailure(fragment, err))
)
return api
.get(url)
.then(
fragment => dispatch(getFragmentSuccess(fragment)),
err => dispatch(getFragmentFailure(fragment, err)),
)
}
}
function updateFragmentRequest (fragment) {
function updateFragmentRequest(fragment) {
return {
type: T.UPDATE_FRAGMENT_REQUEST,
fragment: fragment
fragment: fragment,
}
}
function updateFragmentSuccess (fragment, update) {
function updateFragmentSuccess(fragment, update) {
return {
type: T.UPDATE_FRAGMENT_SUCCESS,
fragment: fragment,
update: update,
receivedAt: Date.now()
receivedAt: Date.now(),
}
}
function updateFragmentFailure (fragment, error) {
function updateFragmentFailure(fragment, error) {
return {
type: T.UPDATE_FRAGMENT_FAILURE,
isFetching: false,
fragment: fragment,
error: error
error: error,
}
}
export function updateFragment (collection, fragment) {
return (dispatch) => {
export function updateFragment(collection, fragment) {
return dispatch => {
dispatch(updateFragmentRequest(fragment))
const url = fragmentUrl(collection, fragment)
return api.update(url, fragment).then(