Skip to content

Commit

Permalink
Run prettier and update monorepo deps
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredpalmer committed Sep 24, 2020
1 parent a8b1700 commit 76dbc46
Show file tree
Hide file tree
Showing 102 changed files with 720 additions and 740 deletions.
6 changes: 3 additions & 3 deletions app/pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import '../styles/globals.css'
import '../styles/globals.css';

function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />
return <Component {...pageProps} />;
}

export default MyApp
export default MyApp;
8 changes: 3 additions & 5 deletions app/pages/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@ const Basic = () => (
picked: '',
}}
validationSchema={Yup.object().shape({
email: Yup.string()
.email('Invalid email address')
.required('Required'),
email: Yup.string().email('Invalid email address').required('Required'),
firstName: Yup.string().required('Required'),
lastName: Yup.string()
.min(2, 'Must be longer than 2 characters')
.max(20, 'Nice try, nobody has a last name that long')
.required('Required'),
})}
onSubmit={async values => {
await new Promise(r => setTimeout(r, 500));
onSubmit={async (values) => {
await new Promise((r) => setTimeout(r, 500));
alert(JSON.stringify(values, null, 2));
}}
>
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Link from 'next/link';

export interface FooterProps {}

export const Footer: React.FC<FooterProps> = props => {
export const Footer: React.FC<FooterProps> = (props) => {
return (
<div className="bg-gray-50 border-t border-gray-200">
<div className="container mx-auto py-12 px-4 sm:px-6 lg:py-16 lg:px-8">
Expand Down
4 changes: 2 additions & 2 deletions docs/src/components/LayoutDocs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const addTagToSlug = (slug: string, tag?: string) => {
return tag ? `/docs/${tag}/${slug.replace('/docs/', '')}` : slug;
};

export const LayoutDocs: React.FC<DocsProps> = props => {
export const LayoutDocs: React.FC<DocsProps> = (props) => {
const router = useRouter();
const { slug, tag } = getSlugAndTag(router.asPath);
const { routes } = getManifest(tag);
Expand Down Expand Up @@ -125,7 +125,7 @@ export const LayoutDocs: React.FC<DocsProps> = props => {
};

function getCategoryPath(routes: RouteItem[]) {
const route = routes.find(r => r.path);
const route = routes.find((r) => r.path);
return route && removeFromLast(route.path!, '/');
}

Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/blog/intersection-observer/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from './intersection-observer'
export { default } from './intersection-observer';
48 changes: 24 additions & 24 deletions docs/src/components/blog/intersection-observer/manager.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
import { hasEqualOptions, parseOptions } from './utils'
import { hasEqualOptions, parseOptions } from './utils';

if (typeof window !== 'undefined') {
require('intersection-observer')
require('intersection-observer');
}

const manager = (function makeManager() {
const observers = new Map()
const observers = new Map();

function getObserver(options) {
return (
findObserver(options) ||
new IntersectionObserver(intersectionCallback, options)
)
);
}

function findObserver(options = {}) {
const parsedOptions = parseOptions(options)
const parsedOptions = parseOptions(options);
for (const observer of observers.keys()) {
if (hasEqualOptions(observer, parsedOptions)) {
return observer
return observer;
}
}
return null
return null;
}

function getObserverTargets(observer) {
return !observers.has(observer)
? observers.set(observer, new Map()).get(observer)
: observers.get(observer)
: observers.get(observer);
}

function observeTarget(observer, target, handler) {
const targets = getObserverTargets(observer)
targets.set(target, handler)
observer.observe(target)
const targets = getObserverTargets(observer);
targets.set(target, handler);
observer.observe(target);
}

function unobserveTarget(observer, target) {
const handlers = getObserverTargets(observer)
handlers.delete(target)
observer.unobserve(target)
const handlers = getObserverTargets(observer);
handlers.delete(target);
observer.unobserve(target);
}

function intersectionCallback(entries, observer) {
for (let entry of entries) {
const handlers = getObserverTargets(observer)
const handler = handlers.get(entry.target)
const handlers = getObserverTargets(observer);
const handler = handlers.get(entry.target);
if (handler) {
handler(entry)
handler(entry);
}
}
}

return {
getObserver,
observeTarget,
unobserveTarget
}
})()
unobserveTarget,
};
})();

export default manager
export const { getObserver } = manager
export const { observeTarget } = manager
export const { unobserveTarget } = manager
export default manager;
export const { getObserver } = manager;
export const { observeTarget } = manager;
export const { unobserveTarget } = manager;
28 changes: 14 additions & 14 deletions docs/src/components/blog/intersection-observer/utils.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
export function isDOMNode(node) {
return (
node && Object.prototype.hasOwnProperty.call(node, 'getBoundingClientRect')
)
);
}

export function parseOptions(options = {}) {
return {
root: options.root || null,
rootMargin: parseRootMargin(options.rootMargin),
threshold: parseThreshold(options.threshold)
}
threshold: parseThreshold(options.threshold),
};
}

export function hasEqualOptions(observer, options) {
return (
equalPair(options.root, observer.root) &&
equalPair(options.rootMargin, observer.rootMargin) &&
equalPair(options.threshold, observer.thresholds)
)
);
}

function parseRootMargin(rootMargin) {
const margins = (rootMargin || '0px').trim().split(/\s+/)
margins.forEach(validateRootMargin)
margins[1] = margins[1] || margins[0]
margins[2] = margins[2] || margins[0]
margins[3] = margins[3] || margins[1]
return margins.join(' ')
const margins = (rootMargin || '0px').trim().split(/\s+/);
margins.forEach(validateRootMargin);
margins[1] = margins[1] || margins[0];
margins[2] = margins[2] || margins[0];
margins[3] = margins[3] || margins[1];
return margins.join(' ');
}

function validateRootMargin(margin) {
if (!/^-?\d*\.?\d+(px|%)$/.test(margin)) {
throw new Error('rootMargin must be specified as a CSS margin property')
throw new Error('rootMargin must be specified as a CSS margin property');
}
}

function parseThreshold(threshold) {
return !Array.isArray(threshold)
? [typeof threshold !== 'undefined' ? threshold : 0]
: threshold
: threshold;
}

function equalPair(optionA, optionB) {
if (Array.isArray(optionA) && Array.isArray(optionB)) {
if (optionA.length === optionB.length) {
return optionA.every((element, idx) =>
equalPair(optionA[idx], optionB[idx])
)
);
}
}
return optionA === optionB
return optionA === optionB;
}
4 changes: 2 additions & 2 deletions docs/src/components/clients/ClientsMarquee.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from 'react';
import { Client } from './Client';
import { users } from 'users';

const pinnedLogos = users.filter(p => p.pinned);
const pinnedLogos = users.filter((p) => p.pinned);

export const ClientsMarquee = React.memo(props => {
export const ClientsMarquee = React.memo((props) => {
return (
<div className="overflow-x-hidden">
<div className="relative translate-x-1/2" {...props}>
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/useBoolean.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const useBoolean = (initial: boolean) => {
value,
{
setValue,
toggle: useCallback(() => setValue(v => !v), []),
toggle: useCallback(() => setValue((v) => !v), []),
setTrue: useCallback(() => setValue(true), []),
setFalse: useCallback(() => setValue(false), []),
},
Expand Down
2 changes: 1 addition & 1 deletion docs/src/lib/docs/md-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fm = require('gray-matter');
// the docs are still readable on github
// (Shamelessly stolen from Expo.io docs)
// @see https://github.com/expo/expo/blob/master/docs/common/md-loader.js
module.exports = async function(src) {
module.exports = async function (src) {
const callback = this.async();
const { content, data } = fm(src);
const layout = data.layout || 'Docs';
Expand Down
6 changes: 3 additions & 3 deletions docs/src/lib/docs/remark-paragraph-alerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ const sigils = {
module.exports = function paragraphCustomAlertsPlugin() {
return function transformer(tree) {
visit(tree, 'paragraph', (pNode, _, parent) => {
visit(pNode, 'text', textNode => {
Object.keys(sigils).forEach(symbol => {
visit(pNode, 'text', (textNode) => {
Object.keys(sigils).forEach((symbol) => {
if (textNode.value.startsWith(`${symbol} `)) {
// Remove the literal sigil symbol from string contents
textNode.value = textNode.value.replace(`${symbol} `, '');

// Wrap matched nodes with <div> (containing proper attributes)
parent.children = parent.children.map(node => {
parent.children = parent.children.map((node) => {
return is(pNode, node)
? {
type: 'wrapper',
Expand Down
54 changes: 27 additions & 27 deletions docs/src/lib/notion/createTable.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
// commonjs so it can be run without transpiling
const uuid = require('uuid/v4')
const fetch = require('node-fetch')
const uuid = require('uuid/v4');
const fetch = require('node-fetch');
const {
BLOG_INDEX_ID: pageId,
NOTION_TOKEN,
API_ENDPOINT,
} = require('./server-constants')
} = require('./server-constants');

async function main() {
const userId = await getUserId()
const transactionId = () => uuid()
const collectionId = uuid()
const collectionViewId = uuid()
const viewId = uuid()
const now = Date.now()
const pageId1 = uuid()
const pageId2 = uuid()
const pageId3 = uuid()
let existingBlockId = await getExistingexistingBlockId()
const userId = await getUserId();
const transactionId = () => uuid();
const collectionId = uuid();
const collectionViewId = uuid();
const viewId = uuid();
const now = Date.now();
const pageId1 = uuid();
const pageId2 = uuid();
const pageId3 = uuid();
let existingBlockId = await getExistingexistingBlockId();

const requestBody = {
requestId: uuid(),
Expand Down Expand Up @@ -308,7 +308,7 @@ async function main() {
],
},
],
}
};

const res = await fetch(`${API_ENDPOINT}/submitTransaction`, {
method: 'POST',
Expand All @@ -317,10 +317,10 @@ async function main() {
'content-type': 'application/json',
},
body: JSON.stringify(requestBody),
})
});

if (!res.ok) {
throw new Error(`Failed to add table, request status ${res.status}`)
throw new Error(`Failed to add table, request status ${res.status}`);
}
}

Expand All @@ -338,18 +338,18 @@ async function getExistingexistingBlockId() {
chunkNumber: 0,
verticalColumns: false,
}),
})
});

if (!res.ok) {
throw new Error(
`failed to get existing block id, request status: ${res.status}`
)
);
}
const data = await res.json()
const data = await res.json();
const id = Object.keys(data ? data.recordMap.block : {}).find(
id => id !== pageId
)
return id || uuid()
(id) => id !== pageId
);
return id || uuid();
}

async function getUserId() {
Expand All @@ -360,15 +360,15 @@ async function getUserId() {
'content-type': 'application/json',
},
body: '{}',
})
});

if (!res.ok) {
throw new Error(
`failed to get Notion user id, request status: ${res.status}`
)
);
}
const data = await res.json()
return Object.keys(data.recordMap.notion_user)[0]
const data = await res.json();
return Object.keys(data.recordMap.notion_user)[0];
}

module.exports = main
module.exports = main;
Loading

0 comments on commit 76dbc46

Please sign in to comment.