Fix some linting errors
This commit is contained in:
parent
bbce1c30de
commit
7713c4c6f8
@ -4,7 +4,6 @@ import NetlifyGitBackend from './netlify-git/implementation';
|
|||||||
import { resolveFormat } from '../formats/formats';
|
import { resolveFormat } from '../formats/formats';
|
||||||
import { createEntry } from '../valueObjects/Entry';
|
import { createEntry } from '../valueObjects/Entry';
|
||||||
import Collection from '../valueObjects/Collection';
|
import Collection from '../valueObjects/Collection';
|
||||||
import { FILES, FOLDER } from '../constants/collectionTypes';
|
|
||||||
|
|
||||||
class LocalStorageAuthStore {
|
class LocalStorageAuthStore {
|
||||||
storageKey = 'nf-cms-user';
|
storageKey = 'nf-cms-user';
|
||||||
@ -43,7 +42,7 @@ class Backend {
|
|||||||
this.implementation = implementation;
|
this.implementation = implementation;
|
||||||
this.authStore = authStore;
|
this.authStore = authStore;
|
||||||
if (this.implementation === null) {
|
if (this.implementation === null) {
|
||||||
throw 'Cannot instantiate a Backend with no implementation';
|
throw new Error('Cannot instantiate a Backend with no implementation');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,13 +93,12 @@ class Backend {
|
|||||||
lookupEntry(collection, slug) {
|
lookupEntry(collection, slug) {
|
||||||
const collectionModel = new Collection(collection);
|
const collectionModel = new Collection(collection);
|
||||||
return this.implementation.getEntry(collection, slug, collectionModel.entryPath(slug))
|
return this.implementation.getEntry(collection, slug, collectionModel.entryPath(slug))
|
||||||
.then(loadedEntry => {
|
.then(loadedEntry => this.entryWithFormat(collection)(createEntry(
|
||||||
return this.entryWithFormat(collection)(createEntry(
|
|
||||||
collection.get('name'),
|
collection.get('name'),
|
||||||
slug,
|
slug,
|
||||||
loadedEntry.file.path,
|
loadedEntry.file.path,
|
||||||
{ raw: loadedEntry.data, label: loadedEntry.file.label }
|
{ raw: loadedEntry.data, label: loadedEntry.file.label }
|
||||||
))}
|
))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,21 +110,17 @@ class Backend {
|
|||||||
return (entry) => {
|
return (entry) => {
|
||||||
const format = resolveFormat(collectionOrEntity, entry);
|
const format = resolveFormat(collectionOrEntity, entry);
|
||||||
if (entry && entry.raw) {
|
if (entry && entry.raw) {
|
||||||
entry.data = format && format.fromFile(entry.raw);
|
return Object.assign(entry, { data: format && format.fromFile(entry.raw) });
|
||||||
return entry;
|
|
||||||
} else {
|
|
||||||
return format.fromFile(entry);
|
|
||||||
}
|
}
|
||||||
|
return format.fromFile(entry);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
unpublishedEntries(page, perPage) {
|
unpublishedEntries(page, perPage) {
|
||||||
return this.implementation.unpublishedEntries(page, perPage).then((response) => {
|
return this.implementation.unpublishedEntries(page, perPage).then(response => ({
|
||||||
return {
|
pagination: response.pagination,
|
||||||
pagination: response.pagination,
|
entries: response.entries.map(this.entryWithFormat('editorialWorkflow')),
|
||||||
entries: response.entries.map(this.entryWithFormat('editorialWorkflow')),
|
}));
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unpublishedEntry(collection, slug) {
|
unpublishedEntry(collection, slug) {
|
||||||
@ -146,7 +140,7 @@ class Backend {
|
|||||||
let entryObj;
|
let entryObj;
|
||||||
if (newEntry) {
|
if (newEntry) {
|
||||||
if (!collectionModel.allowNewEntries()) {
|
if (!collectionModel.allowNewEntries()) {
|
||||||
throw ('Not allowed to create new entries in this collection');
|
throw (new Error('Not allowed to create new entries in this collection'));
|
||||||
}
|
}
|
||||||
const slug = slugFormatter(collection.get('slug'), entryDraft.getIn(['entry', 'data']));
|
const slug = slugFormatter(collection.get('slug'), entryDraft.getIn(['entry', 'data']));
|
||||||
entryObj = {
|
entryObj = {
|
||||||
@ -197,7 +191,7 @@ class Backend {
|
|||||||
export function resolveBackend(config) {
|
export function resolveBackend(config) {
|
||||||
const name = config.getIn(['backend', 'name']);
|
const name = config.getIn(['backend', 'name']);
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
throw 'No backend defined in configuration';
|
throw new Error('No backend defined in configuration');
|
||||||
}
|
}
|
||||||
|
|
||||||
const authStore = new LocalStorageAuthStore();
|
const authStore = new LocalStorageAuthStore();
|
||||||
@ -210,7 +204,7 @@ export function resolveBackend(config) {
|
|||||||
case 'netlify-git':
|
case 'netlify-git':
|
||||||
return new Backend(new NetlifyGitBackend(config, slugFormatter), authStore);
|
return new Backend(new NetlifyGitBackend(config, slugFormatter), authStore);
|
||||||
default:
|
default:
|
||||||
throw `Backend not found: ${ name }`;
|
throw new Error(`Backend not found: ${ name }`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user