Skip to content

Commit

Permalink
Chore: add arrowParens rule to prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
chasefleming committed May 13, 2022
1 parent 9a6476a commit 0ac7427
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 27 deletions.
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"semi": false,
"singleQuote": true,
"tabWidth": 2
"tabWidth": 2,
"arrowParens": "avoid"
}
10 changes: 5 additions & 5 deletions components/Discovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const fetcher = (url, opts) => {
'Content-Type': 'application/json',
},
body: JSON.stringify(opts),
}).then((d) => d.json())
}).then(d => d.json())
}

export const Discovery = ({
Expand All @@ -45,7 +45,7 @@ export const Discovery = ({
walletInclude,
}) => {
const requestUrl = `/api${PATHS[network]}?discoveryType=UI`
const { data, error } = useSWR(requestUrl, (url) =>
const { data, error } = useSWR(requestUrl, url =>
fetcher(url, {
fclVersion: appVersion,
include: walletInclude,
Expand All @@ -60,12 +60,12 @@ export const Discovery = ({
)

return pipe(
(data) => {
data => {
if (!isSupported) return data
return combineServices(data, extensions, true)
},
(data) => serviceListOfType(data, SERVICE_TYPES.authn), // Only show authn services
(data) => sortByAddress(data, lastUsed) // Put last used service at top
data => serviceListOfType(data, SERVICE_TYPES.authn), // Only show authn services
data => sortByAddress(data, lastUsed) // Put last used service at top
)(data)
}, [data, extensions, appVersion])

Expand Down
8 changes: 3 additions & 5 deletions components/ServiceCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ const ServiceCardContainer = styled.a`
box-shadow: 0px 1px 5px rgba(0, 0, 0, 0.25);
border-radius: 15px;
opacity: ${(props) => (props.enabled ? '1' : '0.7')};
cursor: ${(props) => (props.enabled ? 'pointer' : 'unset')};
opacity: ${props => (props.enabled ? '1' : '0.7')};
cursor: ${props => (props.enabled ? 'pointer' : 'unset')};
text-decoration: none;
user-select: none;
Expand Down Expand Up @@ -148,9 +148,7 @@ export default function ServiceCard({
lastUsed = false,
}) {
const { extensions, appVersion } = useFCL()
const isInstalled = extensions.some(
(ext) => ext?.provider?.address === address
)
const isInstalled = extensions.some(ext => ext?.provider?.address === address)
const [_, setLastUsed] = useLocalStorage(
LOCAL_STORAGE_KEYS.LAST_INSTALLED,
null
Expand Down
6 changes: 3 additions & 3 deletions helpers/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { PATHS } from './constants'
export const createPathFromArray = (arr = []) =>
`/${arr.join('/')}`.toLowerCase()

export const isValidPath = (path) => {
export const isValidPath = path => {
if (!path) return false
const pathStr = createPathFromArray(path)
return Object.values(PATHS).some((p) => p === pathStr)
return Object.values(PATHS).some(p => p === pathStr)
}

export const getNetworkFromPath = (path) =>
export const getNetworkFromPath = path =>
path && path.length === 2 ? path[0].toLowerCase() : 'mainnet'
2 changes: 1 addition & 1 deletion helpers/pipe.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const pipe =
(...fns) =>
(x) =>
x =>
fns.reduce((y, f) => f(y), x)
14 changes: 7 additions & 7 deletions helpers/services.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const filterUniqueServices = (services) => {
const filterUniqueServices = services => {
let foundIds = []
return services.filter((p) => {
return services.filter(p => {
if (foundIds.includes(p.provider.address)) {
return false
} else {
Expand All @@ -25,30 +25,30 @@ export const combineServices = (
}

export const serviceListOfType = (services = [], type) =>
services.filter((service) => service.type === type)
services.filter(service => service.type === type)

// If it's an optIn service, make sure it's been asked to be included
export function filterOptInServices(services = [], includeList = []) {
return services.filter((service) => {
return services.filter(service => {
if (service.optIn) return includeList.includes(service?.provider?.address)
return true
})
}

export const getServiceByAddress = (services, address) => {
return services.find((service) => service?.provider?.address === address)
return services.find(service => service?.provider?.address === address)
}

export const containsAddress = (services, address) => {
return services.some((service) => service?.provider?.address === address)
return services.some(service => service?.provider?.address === address)
}

export function sortByAddress(services, selectedAddress) {
if (!selectedAddress) return services
if (!containsAddress(services, selectedAddress)) return services // Do not continue if address you want to sort by is not in list
const serviceWithAddress = getServiceByAddress(services, selectedAddress)
const servicesWithoutSpecified = services.filter(
(service) => service?.provider?.address !== selectedAddress
service => service?.provider?.address !== selectedAddress
)
return [serviceWithAddress, ...servicesWithoutSpecified]
}
2 changes: 1 addition & 1 deletion pages/[...path].js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const AppContainer = styled.div`
max-height: 0;
transition: max-height 250ms ease-in;
${(props) =>
${props =>
props.isSet &&
css`
max-height: 500px;
Expand Down
4 changes: 2 additions & 2 deletions pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function MyApp({ Component, pageProps }) {
const developerLink =
'https://github.com/onflow/fcl-discovery/blob/master/README.md#configuration'

const closeMessage = (event) => {
const closeMessage = event => {
event.stopPropagation()
setMessageOpen(false)
}
Expand All @@ -127,7 +127,7 @@ function MyApp({ Component, pageProps }) {
<>
<GlobalStyle />
<Wrapper onClick={handleCancel}>
<Inner onClick={(e) => e.stopPropagation()}>
<Inner onClick={e => e.stopPropagation()}>
<CloseSection onClick={handleCancel}>
<CloseIcon src="/images/close.svg" alt="Close" />
</CloseSection>
Expand Down
4 changes: 2 additions & 2 deletions pages/api/[...slug].js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const cors = Cors({
// And to throw an error when an error happens in a middleware
function runMiddleware(req, res, fn) {
return new Promise((resolve, reject) => {
fn(req, res, (result) => {
fn(req, res, result => {
if (result instanceof Error) {
return reject(result)
}
Expand Down Expand Up @@ -53,7 +53,7 @@ async function handler(req, res) {
network,
})

const services = pipe((s) =>
const services = pipe(s =>
shouldFilterOrReturnDefault(
() => filterOptInServices(s, include),
isFilteringSupported,
Expand Down

1 comment on commit 0ac7427

@vercel
Copy link

@vercel vercel bot commented on 0ac7427 May 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.