chore: add code formatting and linting (#952)

This commit is contained in:
Caleb
2018-08-07 14:46:54 -06:00
committed by Shawn Erquhart
parent 32e0a9b2b5
commit f801b19221
265 changed files with 5988 additions and 4481 deletions

View File

@ -10,12 +10,12 @@ const StyledAuthenticationPage = styled.section`
align-items: center;
justify-content: center;
height: 100vh;
`
`;
const PageLogoIcon = styled(Icon)`
color: #c4c6d2;
margin-top: -300px;
`
`;
const LoginButton = styled.button`
${buttons.button};
@ -32,7 +32,7 @@ const LoginButton = styled.button`
${Icon} {
margin-right: 18px;
}
`
`;
export default class AuthenticationPage extends React.Component {
static propTypes = {
@ -51,7 +51,7 @@ export default class AuthenticationPage extends React.Component {
}
}
handleLogin = (e) => {
handleLogin = e => {
e.preventDefault();
this.props.onLogin(this.state);
};
@ -61,9 +61,9 @@ export default class AuthenticationPage extends React.Component {
return (
<StyledAuthenticationPage>
<PageLogoIcon size="300px" type="netlify-cms"/>
<PageLogoIcon size="300px" type="netlify-cms" />
<LoginButton disabled={inProgress} onClick={this.handleLogin}>
{inProgress ? "Logging in..." : "Login"}
{inProgress ? 'Logging in...' : 'Login'}
</LoginButton>
</StyledAuthenticationPage>
);

View File

@ -23,8 +23,8 @@ const getCursor = (collection, extension, entries, index) => {
const pageCount = Math.floor(count / pageSize);
return Cursor.create({
actions: [
...(index < pageCount ? ["next", "last"] : []),
...(index > 0 ? ["prev", "first"] : []),
...(index < pageCount ? ['next', 'last'] : []),
...(index > 0 ? ['prev', 'first'] : []),
],
meta: { index, count, pageSize, pageCount },
data: { collection, extension, index, pageCount },
@ -33,9 +33,9 @@ const getCursor = (collection, extension, entries, index) => {
const getFolderEntries = (folder, extension) => {
return Object.keys(window.repoFiles[folder] || {})
.filter(path => path.endsWith(`.${ extension }`))
.filter(path => path.endsWith(`.${extension}`))
.map(path => ({
file: { path: `${ folder }/${ path }` },
file: { path: `${folder}/${path}` },
data: window.repoFiles[folder][path].content,
}))
.reverse();
@ -71,14 +71,22 @@ export default class TestRepo {
traverseCursor(cursor, action) {
const { collection, extension, index, pageCount } = cursor.data.toObject();
const newIndex = (() => {
if (action === "next") { return index + 1; }
if (action === "prev") { return index - 1; }
if (action === "first") { return 0; }
if (action === "last") { return pageCount; }
if (action === 'next') {
return index + 1;
}
if (action === 'prev') {
return index - 1;
}
if (action === 'first') {
return 0;
}
if (action === 'last') {
return pageCount;
}
})();
// TODO: stop assuming cursors are for collections
const allEntries = getFolderEntries(collection.get('folder'), extension);
const entries = allEntries.slice(newIndex * pageSize, (newIndex * pageSize) + pageSize);
const entries = allEntries.slice(newIndex * pageSize, newIndex * pageSize + pageSize);
const newCursor = getCursor(collection, extension, allEntries, newIndex);
return Promise.resolve({ entries, cursor: newCursor });
}
@ -97,10 +105,12 @@ export default class TestRepo {
path: collectionFile.get('file'),
label: collectionFile.get('label'),
}));
return Promise.all(files.map(file => ({
file,
data: getFile(file.path).content,
})));
return Promise.all(
files.map(file => ({
file,
data: getFile(file.path).content,
})),
);
}
getEntry(collection, slug, path) {
@ -115,20 +125,22 @@ export default class TestRepo {
}
unpublishedEntry(collection, slug) {
const entry = window.repoFilesUnpublished.find(e => (
e.metaData.collection === collection.get('name') && e.slug === slug
));
const entry = window.repoFilesUnpublished.find(
e => e.metaData.collection === collection.get('name') && e.slug === slug,
);
if (!entry) {
return Promise.reject(new EditorialWorkflowError('content is not under editorial workflow', true));
return Promise.reject(
new EditorialWorkflowError('content is not under editorial workflow', true),
);
}
return Promise.resolve(entry);
}
deleteUnpublishedEntry(collection, slug) {
const unpubStore = window.repoFilesUnpublished;
const existingEntryIndex = unpubStore.findIndex(e => (
e.metaData.collection === collection && e.slug === slug
));
const existingEntryIndex = unpubStore.findIndex(
e => e.metaData.collection === collection && e.slug === slug,
);
unpubStore.splice(existingEntryIndex, 1);
return Promise.resolve();
}
@ -176,18 +188,18 @@ export default class TestRepo {
updateUnpublishedEntryStatus(collection, slug, newStatus) {
const unpubStore = window.repoFilesUnpublished;
const entryIndex = unpubStore.findIndex(e => (
e.metaData.collection === collection && e.slug === slug
));
const entryIndex = unpubStore.findIndex(
e => e.metaData.collection === collection && e.slug === slug,
);
unpubStore[entryIndex].metaData.status = newStatus;
return Promise.resolve();
}
publishUnpublishedEntry(collection, slug) {
const unpubStore = window.repoFilesUnpublished;
const unpubEntryIndex = unpubStore.findIndex(e => (
e.metaData.collection === collection && e.slug === slug
));
const unpubEntryIndex = unpubStore.findIndex(
e => e.metaData.collection === collection && e.slug === slug,
);
const unpubEntry = unpubStore[unpubEntryIndex];
const entry = { raw: unpubEntry.data, slug: unpubEntry.slug, path: unpubEntry.file.path };
unpubStore.splice(unpubEntryIndex, 1);
@ -211,9 +223,7 @@ export default class TestRepo {
const assetIndex = this.assets.findIndex(asset => asset.path === path);
if (assetIndex > -1) {
this.assets.splice(assetIndex, 1);
}
else {
} else {
const folder = path.substring(0, path.lastIndexOf('/'));
const fileName = path.substring(path.lastIndexOf('/') + 1);
delete window.repoFiles[folder][fileName];