You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-29 22:48:10 +02:00
Tools: Enforce and apply eslint rules prefer-const and no-var
This commit is contained in:
@@ -44,7 +44,7 @@ class Setting extends BaseModel {
|
||||
isEnum: true,
|
||||
label: () => _('Keyboard Mode'),
|
||||
options: () => {
|
||||
let output = {};
|
||||
const output = {};
|
||||
output['default'] = _('Default');
|
||||
output['emacs'] = _('Emacs');
|
||||
output['vim'] = _('Vim');
|
||||
@@ -204,7 +204,7 @@ class Setting extends BaseModel {
|
||||
public: true,
|
||||
label: () => _('Date format'),
|
||||
options: () => {
|
||||
let options = {};
|
||||
const options = {};
|
||||
const now = new Date('2017-01-30T12:00:00').getTime();
|
||||
options[Setting.DATE_FORMAT_1] = time.formatMsToLocal(now, Setting.DATE_FORMAT_1);
|
||||
options[Setting.DATE_FORMAT_2] = time.formatMsToLocal(now, Setting.DATE_FORMAT_2);
|
||||
@@ -223,7 +223,7 @@ class Setting extends BaseModel {
|
||||
public: true,
|
||||
label: () => _('Time format'),
|
||||
options: () => {
|
||||
let options = {};
|
||||
const options = {};
|
||||
const now = new Date('2017-01-30T20:30:00').getTime();
|
||||
options[Setting.TIME_FORMAT_1] = time.formatMsToLocal(now, Setting.TIME_FORMAT_1);
|
||||
options[Setting.TIME_FORMAT_2] = time.formatMsToLocal(now, Setting.TIME_FORMAT_2);
|
||||
@@ -239,7 +239,7 @@ class Setting extends BaseModel {
|
||||
label: () => _('Theme'),
|
||||
section: 'appearance',
|
||||
options: () => {
|
||||
let output = {};
|
||||
const output = {};
|
||||
output[Setting.THEME_LIGHT] = _('Light');
|
||||
output[Setting.THEME_DARK] = _('Dark');
|
||||
if (platform !== mobilePlatform) {
|
||||
@@ -603,7 +603,7 @@ class Setting extends BaseModel {
|
||||
static settingMetadata(key) {
|
||||
const metadata = this.metadata();
|
||||
if (!(key in metadata)) throw new Error(`Unknown key: ${key}`);
|
||||
let output = Object.assign({}, metadata[key]);
|
||||
const output = Object.assign({}, metadata[key]);
|
||||
output.key = key;
|
||||
return output;
|
||||
}
|
||||
@@ -622,14 +622,14 @@ class Setting extends BaseModel {
|
||||
if (!this.keys_) {
|
||||
const metadata = this.metadata();
|
||||
this.keys_ = [];
|
||||
for (let n in metadata) {
|
||||
for (const n in metadata) {
|
||||
if (!metadata.hasOwnProperty(n)) continue;
|
||||
this.keys_.push(n);
|
||||
}
|
||||
}
|
||||
|
||||
if (appType || publicOnly) {
|
||||
let output = [];
|
||||
const output = [];
|
||||
for (let i = 0; i < this.keys_.length; i++) {
|
||||
const md = this.settingMetadata(this.keys_[i]);
|
||||
if (publicOnly && !md.public) continue;
|
||||
@@ -653,7 +653,7 @@ class Setting extends BaseModel {
|
||||
this.cache_ = [];
|
||||
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
let c = rows[i];
|
||||
const c = rows[i];
|
||||
|
||||
if (!this.keyExists(c.key)) continue;
|
||||
c.value = this.formatValue(c.key, c.value);
|
||||
@@ -668,7 +668,7 @@ class Setting extends BaseModel {
|
||||
|
||||
static toPlainObject() {
|
||||
const keys = this.keys();
|
||||
let keyToValues = {};
|
||||
const keyToValues = {};
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
keyToValues[keys[i]] = this.value(keys[i]);
|
||||
}
|
||||
@@ -694,7 +694,7 @@ class Setting extends BaseModel {
|
||||
value = this.filterValue(key, value);
|
||||
|
||||
for (let i = 0; i < this.cache_.length; i++) {
|
||||
let c = this.cache_[i];
|
||||
const c = this.cache_[i];
|
||||
if (c.key == key) {
|
||||
const md = this.settingMetadata(key);
|
||||
|
||||
@@ -849,8 +849,8 @@ class Setting extends BaseModel {
|
||||
|
||||
static enumOptionValues(key) {
|
||||
const options = this.enumOptions(key);
|
||||
let output = [];
|
||||
for (let n in options) {
|
||||
const output = [];
|
||||
for (const n in options) {
|
||||
if (!options.hasOwnProperty(n)) continue;
|
||||
output.push(n);
|
||||
}
|
||||
@@ -859,7 +859,7 @@ class Setting extends BaseModel {
|
||||
|
||||
static enumOptionLabel(key, value) {
|
||||
const options = this.enumOptions(key);
|
||||
for (let n in options) {
|
||||
for (const n in options) {
|
||||
if (n == value) return options[n];
|
||||
}
|
||||
return '';
|
||||
@@ -875,8 +875,8 @@ class Setting extends BaseModel {
|
||||
static enumOptionsDoc(key, templateString = null) {
|
||||
if (templateString === null) templateString = '%s: %s';
|
||||
const options = this.enumOptions(key);
|
||||
let output = [];
|
||||
for (let n in options) {
|
||||
const output = [];
|
||||
for (const n in options) {
|
||||
if (!options.hasOwnProperty(n)) continue;
|
||||
output.push(sprintf(templateString, n, options[n]));
|
||||
}
|
||||
@@ -895,8 +895,8 @@ class Setting extends BaseModel {
|
||||
static subValues(baseKey, settings, options = null) {
|
||||
const includeBaseKeyInName = !!options && !!options.includeBaseKeyInName;
|
||||
|
||||
let output = {};
|
||||
for (let key in settings) {
|
||||
const output = {};
|
||||
for (const key in settings) {
|
||||
if (!settings.hasOwnProperty(key)) continue;
|
||||
if (key.indexOf(baseKey) === 0) {
|
||||
const subKey = includeBaseKeyInName ? key : key.substr(baseKey.length + 1);
|
||||
@@ -913,10 +913,10 @@ class Setting extends BaseModel {
|
||||
clearTimeout(this.saveTimeoutId_);
|
||||
this.saveTimeoutId_ = null;
|
||||
|
||||
let queries = [];
|
||||
const queries = [];
|
||||
queries.push('DELETE FROM settings');
|
||||
for (let i = 0; i < this.cache_.length; i++) {
|
||||
let s = Object.assign({}, this.cache_[i]);
|
||||
const s = Object.assign({}, this.cache_[i]);
|
||||
s.value = this.valueToString(s.key, s.value);
|
||||
queries.push(Database.insertQuery(this.tableName(), s));
|
||||
}
|
||||
@@ -946,10 +946,10 @@ class Setting extends BaseModel {
|
||||
|
||||
const metadata = this.metadata();
|
||||
|
||||
let output = {};
|
||||
for (let key in metadata) {
|
||||
const output = {};
|
||||
for (const key in metadata) {
|
||||
if (!metadata.hasOwnProperty(key)) continue;
|
||||
let s = Object.assign({}, metadata[key]);
|
||||
const s = Object.assign({}, metadata[key]);
|
||||
if (!s.public) continue;
|
||||
if (s.appTypes && s.appTypes.indexOf(appType) < 0) continue;
|
||||
s.value = this.value(key);
|
||||
@@ -967,7 +967,7 @@ class Setting extends BaseModel {
|
||||
}
|
||||
|
||||
static groupMetadatasBySections(metadatas) {
|
||||
let sections = [];
|
||||
const sections = [];
|
||||
const generalSection = { name: 'general', metadatas: [] };
|
||||
const nameToSections = {};
|
||||
nameToSections['general'] = generalSection;
|
||||
|
||||
Reference in New Issue
Block a user