Skip to content

Commit

Permalink
Fix ESLint Errors (#1596)
Browse files Browse the repository at this point in the history
* Fixes eslint errors

* Include new file

* jsx files can have eslint problems too
fix import
  • Loading branch information
Robert “Beau” Collins authored and belcherj committed Oct 1, 2019
1 parent dabbf03 commit b515264
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 59 deletions.
4 changes: 2 additions & 2 deletions lib/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,12 @@ let props = {
};

// If we sign in with a different username, ensure storage is reset
const resetStorageIfAccountChanged = newAccountName => {
function resetStorageIfAccountChanged(newAccountName) {
const accountName = get(store.getState(), 'settings.accountName', '');
if (accountName !== newAccountName) {
client.reset();
}
};
}

// Set account email if app engine provided it
if (cookie.email && config.is_app_engine) {
Expand Down
34 changes: 17 additions & 17 deletions lib/dialogs/import/dropzone/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,23 @@ function ImporterDropzone({
const [acceptedFile, setAcceptedFile] = useState();
const [errorMessage, setErrorMessage] = useState();

const handleAccept = acceptedFiles => {
const fileCount = acceptedFiles.length;
const label = fileCount > 1 ? `${fileCount} files` : acceptedFiles[0].name;
setAcceptedFile(label);
onAccept(acceptedFiles);
};

const handleReject = rejectedFiles => {
if (!multiple && rejectedFiles.length > 1) {
setErrorMessage('Choose a single file');
} else {
setErrorMessage('File type is incorrect');
}
setAcceptedFile(undefined);
onReset();
};

const onDrop = useCallback((acceptedFiles, rejectedFiles) => {
if (acceptedFiles.length === 0) {
handleReject(rejectedFiles);
Expand All @@ -32,13 +49,6 @@ function ImporterDropzone({
onDrop,
});

const handleAccept = acceptedFiles => {
const fileCount = acceptedFiles.length;
const label = fileCount > 1 ? `${fileCount} files` : acceptedFiles[0].name;
setAcceptedFile(label);
onAccept(acceptedFiles);
};

useEffect(() => {
if (!errorMessage) {
return;
Expand All @@ -47,16 +57,6 @@ function ImporterDropzone({
return () => clearTimeout(timer);
}, [errorMessage]);

const handleReject = rejectedFiles => {
if (!multiple && rejectedFiles.length > 1) {
setErrorMessage('Choose a single file');
} else {
setErrorMessage('File type is incorrect');
}
setAcceptedFile(undefined);
onReset();
};

const text = errorMessage ? errorMessage : 'Drag a file, or click to choose';

const DropzonePlaceholder = () => (
Expand Down
31 changes: 1 addition & 30 deletions lib/simperium/bucket-store.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,4 @@
class StoreProvider {
constructor(config) {
this.setup = new Promise((resolve, reject) => config(resolve, reject));
}

provider = () => bucket => new BucketStore(bucket, this.setup);

reset = () =>
this.setup
.then(db =>
Promise.all(
Array.prototype.map.call(
db.objectStoreNames,
name =>
new Promise((resolve, reject) => {
const tx = db.transaction(name, 'readwrite');
const request = tx.objectStore(name).clear();

request.onsuccess = () => resolve(name);
request.onerror = e => reject(e);
})
)
)
)
.catch(e => console.error('Failed to reset stores', e)); // eslint-disable-line no-console
}

class BucketStore {
export class BucketStore {
constructor(bucket, setup) {
this.bucket = bucket;
this.setup = setup;
Expand Down Expand Up @@ -85,5 +58,3 @@ class BucketStore {
request.onerror = e => callback(e);
});
}

export default config => new StoreProvider(config);
4 changes: 2 additions & 2 deletions lib/simperium/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import simperium, { Client } from 'simperium';
import bucket_store from './bucket-store';
import store_provider from './store-provider';
import ghost_store from './ghost-store';
import localQueueStore from './local-queue-store';
import util from 'util';
Expand All @@ -25,7 +25,7 @@ function BrowserClient({ appID, token, bucketConfig, database, version }) {
this.databaseName = database || 'simperium-objects';
this.databaseVersion = version || 1;
let config = (this.bucketConfig = bucketConfig);
this.bucketDB = bucket_store(this.configureDb.bind(this));
this.bucketDB = store_provider(this.configureDb.bind(this));
this.buckets = {};

let objectStoreProvider = this.bucketDB.provider();
Expand Down
9 changes: 7 additions & 2 deletions lib/simperium/local-queue-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ function restoreTo(bucket) {
);
}

export const getKey = bucket => `localQueue:${bucket.name}`;
export const getLocalQueue = bucket => bucket.channel.localQueue;
export function getKey(bucket) {
return `localQueue:${bucket.name}`;
}

export function getLocalQueue(bucket) {
return bucket.channel.localQueue;
}

const localQueueStore = { persist, restoreTo };

Expand Down
30 changes: 30 additions & 0 deletions lib/simperium/store-provider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { BucketStore } from './bucket-store';

export class StoreProvider {
constructor(config) {
this.setup = new Promise((resolve, reject) => config(resolve, reject));
}

provider = () => bucket => new BucketStore(bucket, this.setup);

reset = () =>
this.setup
.then(db =>
Promise.all(
Array.prototype.map.call(
db.objectStoreNames,
name =>
new Promise((resolve, reject) => {
const tx = db.transaction(name, 'readwrite');
const request = tx.objectStore(name).clear();

request.onsuccess = () => resolve(name);
request.onerror = e => reject(e);
})
)
)
)
.catch(e => console.error('Failed to reset stores', e)); // eslint-disable-line no-console
}

export default config => new StoreProvider(config);
4 changes: 2 additions & 2 deletions lib/utils/import/simplenote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class SimplenoteImporter extends EventEmitter {
};
}

export const convertModificationDates = notes => {
export function convertModificationDates(notes) {
return notes.map(({ lastModified, ...note }) => {
// Account for Simplenote's exported `lastModified` date
let modificationDate = note.modificationDate || lastModified;
Expand All @@ -76,6 +76,6 @@ export const convertModificationDates = notes => {
}
return resultNote;
});
};
}

export default SimplenoteImporter;
4 changes: 2 additions & 2 deletions lib/utils/note-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ export const noteTitleAndPreview = note => {
return { title, preview };
};

export const isMarkdown = note => {
export function isMarkdown(note) {
return note && note.data && note.data.systemTags.includes('markdown');
};
}

/**
* Clean the text so it is ready to be sorted alphabetically.
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/sync/nudge-unsynced.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const nudgeUnsynced = ({ noteBucket, notes, client }) => {
});
};

const updateUnsyncedNotes = ({ noteBucket, notes }) => {
function updateUnsyncedNotes({ noteBucket, notes }) {
const noteHasSynced = note =>
new Promise(resolve =>
noteBucket.getVersion(note.id, (e, v) => {
Expand All @@ -48,6 +48,6 @@ const updateUnsyncedNotes = ({ noteBucket, notes }) => {
debug(`${unsyncedNotes.length} unsynced notes`);
unsyncedNotes.forEach(note => noteBucket.update(note.id, note.data));
});
};
}

export default nudgeUnsynced;

0 comments on commit b515264

Please sign in to comment.