You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-12 22:57:38 +02:00
Tools: Enforce and apply eslint rules prefer-const and no-var
This commit is contained in:
@ -35,7 +35,7 @@ class Note extends BaseItem {
|
||||
|
||||
static async unserializeForEdit(content) {
|
||||
content += `\n\ntype_: ${BaseModel.TYPE_NOTE}`;
|
||||
let output = await super.unserialize(content);
|
||||
const output = await super.unserialize(content);
|
||||
if (!output.title) output.title = '';
|
||||
if (!output.body) output.body = '';
|
||||
output.body = await this.replaceResourceExternalToInternalLinks(output.body);
|
||||
@ -43,16 +43,16 @@ class Note extends BaseItem {
|
||||
}
|
||||
|
||||
static async serializeAllProps(note) {
|
||||
let fieldNames = this.fieldNames();
|
||||
const fieldNames = this.fieldNames();
|
||||
fieldNames.push('type_');
|
||||
lodash.pull(fieldNames, 'title', 'body');
|
||||
return super.serialize(note, fieldNames);
|
||||
}
|
||||
|
||||
static minimalSerializeForDisplay(note) {
|
||||
let n = Object.assign({}, note);
|
||||
const n = Object.assign({}, note);
|
||||
|
||||
let fieldNames = this.fieldNames();
|
||||
const fieldNames = this.fieldNames();
|
||||
|
||||
if (!n.is_conflict) lodash.pull(fieldNames, 'is_conflict');
|
||||
if (!Number(n.latitude)) lodash.pull(fieldNames, 'latitude');
|
||||
@ -193,13 +193,13 @@ class Note extends BaseItem {
|
||||
}
|
||||
|
||||
static new(parentId = '') {
|
||||
let output = super.new();
|
||||
const output = super.new();
|
||||
output.parent_id = parentId;
|
||||
return output;
|
||||
}
|
||||
|
||||
static newTodo(parentId = '') {
|
||||
let output = this.new(parentId);
|
||||
const output = this.new(parentId);
|
||||
output.is_todo = true;
|
||||
return output;
|
||||
}
|
||||
@ -269,13 +269,13 @@ class Note extends BaseItem {
|
||||
static async loadFolderNoteByField(folderId, field, value) {
|
||||
if (!folderId) throw new Error('folderId is undefined');
|
||||
|
||||
let options = {
|
||||
const options = {
|
||||
conditions: [`\`${field}\` = ?`],
|
||||
conditionsParams: [value],
|
||||
fields: '*',
|
||||
};
|
||||
|
||||
let results = await this.previews(folderId, options);
|
||||
const results = await this.previews(folderId, options);
|
||||
return results.length ? results[0] : null;
|
||||
}
|
||||
|
||||
@ -302,7 +302,7 @@ class Note extends BaseItem {
|
||||
}
|
||||
|
||||
if (options.anywherePattern) {
|
||||
let pattern = options.anywherePattern.replace(/\*/g, '%');
|
||||
const pattern = options.anywherePattern.replace(/\*/g, '%');
|
||||
options.conditions.push('(title LIKE ? OR body LIKE ?)');
|
||||
options.conditionsParams.push(pattern);
|
||||
options.conditionsParams.push(pattern);
|
||||
@ -329,7 +329,7 @@ class Note extends BaseItem {
|
||||
let tempOptions = Object.assign({}, options);
|
||||
tempOptions.conditions = cond;
|
||||
|
||||
let uncompletedTodos = await this.search(tempOptions);
|
||||
const uncompletedTodos = await this.search(tempOptions);
|
||||
|
||||
cond = options.conditions.slice();
|
||||
if (hasNotes && hasTodos) {
|
||||
@ -341,7 +341,7 @@ class Note extends BaseItem {
|
||||
tempOptions = Object.assign({}, options);
|
||||
tempOptions.conditions = cond;
|
||||
if ('limit' in tempOptions) tempOptions.limit -= uncompletedTodos.length;
|
||||
let theRest = await this.search(tempOptions);
|
||||
const theRest = await this.search(tempOptions);
|
||||
|
||||
return uncompletedTodos.concat(theRest);
|
||||
}
|
||||
@ -381,7 +381,7 @@ class Note extends BaseItem {
|
||||
}
|
||||
|
||||
static async conflictedCount() {
|
||||
let r = await this.db().selectOne('SELECT count(*) as total FROM notes WHERE is_conflict = 1');
|
||||
const r = await this.db().selectOne('SELECT count(*) as total FROM notes WHERE is_conflict = 1');
|
||||
return r && r.total ? r.total : 0;
|
||||
}
|
||||
|
||||
@ -393,7 +393,7 @@ class Note extends BaseItem {
|
||||
if (!Setting.value('trackLocation')) return;
|
||||
if (!Note.updateGeolocationEnabled_) return;
|
||||
|
||||
let startWait = time.unixMs();
|
||||
const startWait = time.unixMs();
|
||||
while (true) {
|
||||
if (!this.geolocationUpdating_) break;
|
||||
this.logger().info('Waiting for geolocation update...');
|
||||
@ -428,7 +428,7 @@ class Note extends BaseItem {
|
||||
|
||||
this.logger().info(`Updating lat/long of note ${noteId}`);
|
||||
|
||||
let note = await Note.load(noteId);
|
||||
const note = await Note.load(noteId);
|
||||
if (!note) return; // Race condition - note has been deleted in the meantime
|
||||
|
||||
note.longitude = geoData.coords.longitude;
|
||||
@ -440,7 +440,7 @@ class Note extends BaseItem {
|
||||
static filter(note) {
|
||||
if (!note) return note;
|
||||
|
||||
let output = super.filter(note);
|
||||
const output = super.filter(note);
|
||||
if ('longitude' in output) output.longitude = Number(!output.longitude ? 0 : output.longitude).toFixed(8);
|
||||
if ('latitude' in output) output.latitude = Number(!output.latitude ? 0 : output.latitude).toFixed(8);
|
||||
if ('altitude' in output) output.altitude = Number(!output.altitude ? 0 : output.altitude).toFixed(4);
|
||||
@ -530,14 +530,14 @@ class Note extends BaseItem {
|
||||
const originalNote = await Note.load(noteId);
|
||||
if (!originalNote) throw new Error(`Unknown note: ${noteId}`);
|
||||
|
||||
let newNote = Object.assign({}, originalNote);
|
||||
const newNote = Object.assign({}, originalNote);
|
||||
const fieldsToReset = ['id', 'created_time', 'updated_time', 'user_created_time', 'user_updated_time'];
|
||||
|
||||
for (let field of fieldsToReset) {
|
||||
for (const field of fieldsToReset) {
|
||||
delete newNote[field];
|
||||
}
|
||||
|
||||
for (let n in changes) {
|
||||
for (const n in changes) {
|
||||
if (!changes.hasOwnProperty(n)) continue;
|
||||
newNote[n] = changes[n];
|
||||
}
|
||||
@ -557,7 +557,7 @@ class Note extends BaseItem {
|
||||
}
|
||||
|
||||
static async save(o, options = null) {
|
||||
let isNew = this.isNew(o, options);
|
||||
const isNew = this.isNew(o, options);
|
||||
const isProvisional = options && !!options.provisional;
|
||||
if (isNew && !o.source) o.source = Setting.value('appName');
|
||||
if (isNew && !o.source_application) o.source_application = Setting.value('appId');
|
||||
|
Reference in New Issue
Block a user