Skip to content

Commit

Permalink
Add prettier for examples directory (vercel#5909)
Browse files Browse the repository at this point in the history
* Add prettier for examples directory

* Fix files

* Fix linting

* Add prettier script in case it has to be ran again
  • Loading branch information
timneutkens authored Dec 17, 2018
1 parent 6e2cbfa commit 9c4eefc
Show file tree
Hide file tree
Showing 391 changed files with 3,160 additions and 2,109 deletions.
4 changes: 3 additions & 1 deletion examples/active-class-name/components/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ const ActiveLink = ({ router, children, ...props }) => {

let className = child.props.className || null
if (router.pathname === props.href && props.activeClassName) {
className = `${className !== null ? className : ''} ${props.activeClassName}`.trim()
className = `${className !== null ? className : ''} ${
props.activeClassName
}`.trim()
}

delete props.activeClassName
Expand Down
4 changes: 1 addition & 3 deletions examples/analyze-bundles/pages/about.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export default () => (
<div>About us</div>
)
export default () => <div>About us</div>
6 changes: 1 addition & 5 deletions examples/analyze-bundles/pages/contact.js
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
export default () => (
<div>
This is the contact page.
</div>
)
export default () => <div>This is the contact page.</div>
4 changes: 3 additions & 1 deletion examples/analyze-bundles/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export default class Index extends React.Component {
<h1>Home Page</h1>
<p>Welcome, {name}</p>
<div>
<Link href='/about'><a>About Page</a></Link>
<Link href='/about'>
<a>About Page</a>
</Link>
</div>
</div>
)
Expand Down
4 changes: 1 addition & 3 deletions examples/basic-export/pages/about.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export default () => (
<div>About us</div>
)
export default () => <div>About us</div>
4 changes: 1 addition & 3 deletions examples/basic-export/pages/about2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export default () => (
<div>About 2</div>
)
export default () => <div>About 2</div>
4 changes: 1 addition & 3 deletions examples/basic-export/pages/day/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export default () => (
<div>Hello Day</div>
)
export default () => <div>Hello Day</div>
7 changes: 6 additions & 1 deletion examples/basic-export/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import Link from 'next/link'
export default () => (
<div>Hello World. <Link href='/about'><a>About</a></Link></div>
<div>
Hello World.{' '}
<Link href='/about'>
<a>About</a>
</Link>
</div>
)
20 changes: 9 additions & 11 deletions examples/custom-charset/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()

app.prepare()
.then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
res.setHeader('Content-Type', 'text/html; charset=iso-8859-2')
handle(req, res, parsedUrl)
})
.listen(port, (err) => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
app.prepare().then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
res.setHeader('Content-Type', 'text/html; charset=iso-8859-2')
handle(req, res, parsedUrl)
}).listen(port, err => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})
2 changes: 1 addition & 1 deletion examples/custom-server-actionhero/actions/render.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict'
const {Action, api} = require('actionhero')
const { Action, api } = require('actionhero')

module.exports = class CreateChatRoom extends Action {
constructor () {
Expand Down
32 changes: 16 additions & 16 deletions examples/custom-server-actionhero/config/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const path = require('path')

exports['default'] = {
general: (api) => {
general: api => {
const packageJSON = require(api.projectRoot + path.sep + 'package.json')

return {
Expand Down Expand Up @@ -46,16 +46,16 @@ exports['default'] = {
cliIncludeInternal: true,
// configuration for your actionhero project structure
paths: {
'action': [path.join(__dirname, '/../actions')],
'task': [path.join(__dirname, '/../tasks')],
'public': [path.join(__dirname, '/../static')],
'pid': [path.join(__dirname, '/../pids')],
'log': [path.join(__dirname, '/../log')],
'server': [path.join(__dirname, '/../servers')],
'cli': [path.join(__dirname, '/../bin')],
'initializer': [path.join(__dirname, '/../initializers')],
'plugin': [path.join(__dirname, '/../node_modules')],
'locale': [path.join(__dirname, '/../locales')]
action: [path.join(__dirname, '/../actions')],
task: [path.join(__dirname, '/../tasks')],
public: [path.join(__dirname, '/../static')],
pid: [path.join(__dirname, '/../pids')],
log: [path.join(__dirname, '/../log')],
server: [path.join(__dirname, '/../servers')],
cli: [path.join(__dirname, '/../bin')],
initializer: [path.join(__dirname, '/../initializers')],
plugin: [path.join(__dirname, '/../node_modules')],
locale: [path.join(__dirname, '/../locales')]
},
// hash containing chat rooms you wish to be created at server boot
startingChatRooms: {
Expand All @@ -67,17 +67,17 @@ exports['default'] = {
}

exports.test = {
general: (api) => {
general: api => {
return {
id: 'test-server-' + process.pid,
serverToken: 'serverToken-' + process.pid,
developmentMode: true,
startingChatRooms: {
'defaultRoom': {},
'otherRoom': {}
defaultRoom: {},
otherRoom: {}
},
paths: {
'locale': [
locale: [
// require('os').tmpdir() + require('path').sep + 'locales',
path.join(__dirname, '/../locales')
]
Expand All @@ -88,7 +88,7 @@ exports.test = {
}

exports.production = {
general: (api) => {
general: api => {
return {
fileRequestLogLevel: 'debug',
developmentMode: false
Expand Down
87 changes: 58 additions & 29 deletions examples/custom-server-actionhero/config/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,38 @@

// error messages can be strings of objects
exports['default'] = {
errors: (api) => {
errors: api => {
return {
'_toExpand': false,
_toExpand: false,

// ///////////////
// SERIALIZERS //
// ///////////////

serializers: {
servers: {
web: (error) => {
web: error => {
if (error.message) {
return String(error.message)
} else {
return error
}
},
websocket: (error) => {
websocket: error => {
if (error.message) {
return String(error.message)
} else {
return error
}
},
socket: (error) => {
socket: error => {
if (error.message) {
return String(error.message)
} else {
return error
}
},
specHelper: (error) => {
specHelper: error => {
if (error.message) {
return 'Error: ' + String(error.message)
} else {
Expand All @@ -49,38 +49,51 @@ exports['default'] = {

// When a params for an action is invalid
invalidParams: (data, validationErrors) => {
if (validationErrors.length >= 0) { return validationErrors[0] }
if (validationErrors.length >= 0) {
return validationErrors[0]
}
return data.connection.localize('actionhero.errors.invalidParams')
},

// When a required param for an action is not provided
missingParams: (data, missingParams) => {
return data.connection.localize(['actionhero.errors.missingParams', {param: missingParams[0]}])
return data.connection.localize([
'actionhero.errors.missingParams',
{ param: missingParams[0] }
])
},

// user requested an unknown action
unknownAction: (data) => {
unknownAction: data => {
return data.connection.localize('actionhero.errors.unknownAction')
},

// action not useable by this client/server type
unsupportedServerType: (data) => {
return data.connection.localize(['actionhero.errors.unsupportedServerType', {type: data.connection.type}])
unsupportedServerType: data => {
return data.connection.localize([
'actionhero.errors.unsupportedServerType',
{ type: data.connection.type }
])
},

// action failed because server is mid-shutdown
serverShuttingDown: (data) => {
serverShuttingDown: data => {
return data.connection.localize('actionhero.errors.serverShuttingDown')
},

// action failed because this client already has too many pending acitons
// limit defined in api.config.general.simultaneousActions
tooManyPendingActions: (data) => {
return data.connection.localize('actionhero.errors.tooManyPendingActions')
tooManyPendingActions: data => {
return data.connection.localize(
'actionhero.errors.tooManyPendingActions'
)
},

dataLengthTooLarge: (maxLength, receivedLength) => {
return api.i18n.localize(['actionhero.errors.dataLengthTooLarge', {maxLength: maxLength, receivedLength: receivedLength}])
return api.i18n.localize([
'actionhero.errors.dataLengthTooLarge',
{ maxLength: maxLength, receivedLength: receivedLength }
])
},

// ///////////////
Expand All @@ -89,60 +102,76 @@ exports['default'] = {

// The body message to accompany 404 (file not found) errors regarding flat files
// You may want to load in the contnet of 404.html or similar
fileNotFound: (connection) => {
fileNotFound: connection => {
return connection.localize(['actionhero.errors.fileNotFound'])
},

// user didn't request a file
fileNotProvided: (connection) => {
fileNotProvided: connection => {
return connection.localize('actionhero.errors.fileNotProvided')
},

// something went wrong trying to read the file
fileReadError: (connection, error) => {
return connection.localize(['actionhero.errors.fileReadError', {error: String(error)}])
return connection.localize([
'actionhero.errors.fileReadError',
{ error: String(error) }
])
},

// ///////////////
// CONNECTIONS //
// ///////////////

verbNotFound: (connection, verb) => {
return connection.localize(['actionhero.errors.verbNotFound', {verb: verb}])
return connection.localize([
'actionhero.errors.verbNotFound',
{ verb: verb }
])
},

verbNotAllowed: (connection, verb) => {
return connection.localize(['actionhero.errors.verbNotAllowed', {verb: verb}])
return connection.localize([
'actionhero.errors.verbNotAllowed',
{ verb: verb }
])
},

connectionRoomAndMessage: (connection) => {
connectionRoomAndMessage: connection => {
return connection.localize('actionhero.errors.connectionRoomAndMessage')
},

connectionNotInRoom: (connection, room) => {
return connection.localize(['actionhero.errors.connectionNotInRoom', {room: room}])
return connection.localize([
'actionhero.errors.connectionNotInRoom',
{ room: room }
])
},

connectionAlreadyInRoom: (connection, room) => {
return connection.localize(['actionhero.errors.connectionAlreadyInRoom', {room: room}])
return connection.localize([
'actionhero.errors.connectionAlreadyInRoom',
{ room: room }
])
},

connectionRoomHasBeenDeleted: (room) => {
return api.i18n.localize('actionhero.errors.connectionRoomHasBeenDeleted')
connectionRoomHasBeenDeleted: room => {
return api.i18n.localize(
'actionhero.errors.connectionRoomHasBeenDeleted'
)
},

connectionRoomNotExist: (room) => {
connectionRoomNotExist: room => {
return api.i18n.localize('actionhero.errors.connectionRoomNotExist')
},

connectionRoomExists: (room) => {
connectionRoomExists: room => {
return api.i18n.localize('actionhero.errors.connectionRoomExists')
},

connectionRoomRequired: (room) => {
connectionRoomRequired: room => {
return api.i18n.localize('actionhero.errors.connectionRoomRequired')
}

}
}
}
4 changes: 2 additions & 2 deletions examples/custom-server-actionhero/config/i18n.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
exports['default'] = {
i18n: (api) => {
i18n: api => {
return {
// visit https://github.com/mashpie/i18n-node to see all configuration options
// locale path can be configired from within ./config/api.js
Expand Down Expand Up @@ -28,7 +28,7 @@ exports['default'] = {
}

exports.test = {
i18n: (api) => {
i18n: api => {
return {
updateFiles: true
}
Expand Down
Loading

0 comments on commit 9c4eefc

Please sign in to comment.