1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-26 22:41:17 +02:00

Chore: Apply eslint rules

This commit is contained in:
Laurent Cozic
2019-09-19 22:51:18 +01:00
parent ab29d7e872
commit e648392330
185 changed files with 1196 additions and 1196 deletions

View File

@@ -80,7 +80,7 @@ class ActionButtonComponent extends React.Component {
for (let i = 0; i < buttons.length; i++) {
let button = buttons[i];
let buttonTitle = button.title ? button.title : '';
let key = buttonTitle.replace(/\s/g, '_') + '_' + button.icon;
let key = `${buttonTitle.replace(/\s/g, '_')}_${button.icon}`;
buttonComps.push(
<ReactNativeActionButton.Item key={key} buttonColor={button.color} title={buttonTitle} onPress={button.onPress}>
<Icon name={button.icon} style={styles.actionButtonIcon} />
@@ -97,7 +97,7 @@ class ActionButtonComponent extends React.Component {
if (this.props.multiStates) {
if (!this.props.buttons || !this.props.buttons.length) throw new Error('Multi-state button requires at least one state');
if (this.state.buttonIndex < 0 || this.state.buttonIndex >= this.props.buttons.length) throw new Error('Button index out of bounds: ' + this.state.buttonIndex + '/' + this.props.buttons.length);
if (this.state.buttonIndex < 0 || this.state.buttonIndex >= this.props.buttons.length) throw new Error(`Button index out of bounds: ${this.state.buttonIndex}/${this.props.buttons.length}`);
let button = this.props.buttons[this.state.buttonIndex];
let mainIcon = <Icon name={button.icon} style={styles.actionButtonIcon} />;
return (

View File

@@ -45,7 +45,7 @@ globalStyle.marginRight = globalStyle.margin;
globalStyle.marginLeft = globalStyle.margin;
globalStyle.marginTop = globalStyle.margin;
globalStyle.marginBottom = globalStyle.margin;
globalStyle.htmlMarginLeft = ((globalStyle.marginLeft / 10) * 0.6).toFixed(2) + 'em';
globalStyle.htmlMarginLeft = `${((globalStyle.marginLeft / 10) * 0.6).toFixed(2)}em`;
let themeCache_ = {};

View File

@@ -66,7 +66,7 @@ class NoteBodyViewer extends Component {
// If the length of the body has changed, then it's something other than a checkbox that has changed,
// for example a resource that has been attached to the note while in View mode. In that case, update.
return (safeGetNoteProp(this.props, 'body') + '').length !== (safeGetNoteProp(nextProps, 'body') + '').length;
return (`${safeGetNoteProp(this.props, 'body')}`).length !== (`${safeGetNoteProp(nextProps, 'body')}`).length;
}
rebuildMd() {
@@ -140,9 +140,9 @@ class NoteBodyViewer extends Component {
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
` +
html +
`
${
html
}
</body>
</html>
`;
@@ -176,7 +176,7 @@ class NoteBodyViewer extends Component {
// `baseUrl` is where the images will be loaded from. So images must use a path relative to resourceDir.
const source = {
html: html,
baseUrl: 'file://' + Setting.value('resourceDir') + '/',
baseUrl: `file://${Setting.value('resourceDir')}/`,
};
// Note: useWebKit={false} is needed to go around this bug:

View File

@@ -263,10 +263,10 @@ class ScreenHeaderComponent extends React.PureComponent {
let o = this.props.menuOptions[i];
if (o.isDivider) {
menuOptionComponents.push(<View key={'menuOption_' + key++} style={this.styles().divider} />);
menuOptionComponents.push(<View key={`menuOption_${key++}`} style={this.styles().divider} />);
} else {
menuOptionComponents.push(
<MenuOption value={o.onPress} key={'menuOption_' + key++} style={this.styles().contextMenuItem}>
<MenuOption value={o.onPress} key={`menuOption_${key++}`} style={this.styles().contextMenuItem}>
<Text style={this.styles().contextMenuItemText}>{o.title}</Text>
</MenuOption>
);
@@ -274,7 +274,7 @@ class ScreenHeaderComponent extends React.PureComponent {
}
if (menuOptionComponents.length) {
menuOptionComponents.push(<View key={'menuOption_' + key++} style={this.styles().divider} />);
menuOptionComponents.push(<View key={`menuOption_${key++}`} style={this.styles().divider} />);
}
} else {
menuOptionComponents.push(
@@ -299,7 +299,7 @@ class ScreenHeaderComponent extends React.PureComponent {
for (let i = 0; i < folders.length; i++) {
const f = folders[i];
pickerItems.push({ label: ' '.repeat(indent) + ' ' + Folder.displayTitle(f), value: f.id });
pickerItems.push({ label: `${' '.repeat(indent)} ${Folder.displayTitle(f)}`, value: f.id });
pickerItems = addFolderChildren(f.children, pickerItems, indent + 1);
}

View File

@@ -68,12 +68,12 @@ class ConfigScreenComponent extends BaseScreenComponent {
const logItemCsv = service.csvCreate(logItemRows);
const itemListCsv = await service.basicItemList({ format: 'csv' });
const filePath = RNFS.ExternalDirectoryPath + '/syncReport-' + new Date().getTime() + '.txt';
const filePath = `${RNFS.ExternalDirectoryPath}/syncReport-${new Date().getTime()}.txt`;
const finalText = [logItemCsv, itemListCsv].join('\n================================================================================\n');
await RNFS.writeFile(filePath, finalText);
alert('Debug report exported to ' + filePath);
alert(`Debug report exported to ${filePath}`);
this.setState({ creatingReport: false });
};
@@ -454,7 +454,7 @@ class ConfigScreenComponent extends BaseScreenComponent {
settingComps.push(
<View key="version_info_app" style={this.styles().settingContainer}>
<Text style={this.styles().settingText}>{'Joplin ' + VersionInfo.appVersion}</Text>
<Text style={this.styles().settingText}>{`Joplin ${VersionInfo.appVersion}`}</Text>
</View>
);

View File

@@ -97,7 +97,7 @@ class LogScreenComponent extends BaseScreenComponent {
return (
<View style={this.styles().row}>
<Text style={textStyle}>{time.formatMsToLocal(item.timestamp, 'MM-DDTHH:mm:ss') + ': ' + item.message}</Text>
<Text style={textStyle}>{`${time.formatMsToLocal(item.timestamp, 'MM-DDTHH:mm:ss')}: ${item.message}`}</Text>
</View>
);
};

View File

@@ -409,12 +409,12 @@ class NoteScreenComponent extends BaseScreenComponent {
reg.logger().info('New dimensions ', dimensions);
const format = mimeType == 'image/png' ? 'PNG' : 'JPEG';
reg.logger().info('Resizing image ' + localFilePath);
reg.logger().info(`Resizing image ${localFilePath}`);
const resizedImage = await ImageResizer.createResizedImage(localFilePath, dimensions.width, dimensions.height, format, 85); //, 0, targetPath);
const resizedImagePath = resizedImage.uri;
reg.logger().info('Resized image ', resizedImagePath);
reg.logger().info('Moving ' + resizedImagePath + ' => ' + targetPath);
reg.logger().info(`Moving ${resizedImagePath} => ${targetPath}`);
await RNFS.copyFile(resizedImagePath, targetPath);
@@ -462,8 +462,8 @@ class NoteScreenComponent extends BaseScreenComponent {
mimeType = 'image/jpg';
}
reg.logger().info('Got file: ' + localFilePath);
reg.logger().info('Got type: ' + mimeType);
reg.logger().info(`Got file: ${localFilePath}`);
reg.logger().info(`Got type: ${mimeType}`);
let resource = Resource.new();
resource.id = uuid.create();
@@ -499,7 +499,7 @@ class NoteScreenComponent extends BaseScreenComponent {
}
const itDoes = await shim.fsDriver().waitTillExists(targetPath);
if (!itDoes) throw new Error('Resource file was not created: ' + targetPath);
if (!itDoes) throw new Error(`Resource file was not created: ${targetPath}`);
const fileStat = await shim.fsDriver().stat(targetPath);
resource.size = fileStat.size;
@@ -509,7 +509,7 @@ class NoteScreenComponent extends BaseScreenComponent {
const resourceTag = Resource.markdownTag(resource);
const newNote = Object.assign({}, this.state.note);
newNote.body += '\n' + resourceTag;
newNote.body += `\n${resourceTag}`;
this.setState({ note: newNote });
this.refreshResource(resource);
@@ -563,7 +563,7 @@ class NoteScreenComponent extends BaseScreenComponent {
async share_onPress() {
await Share.share({
message: this.state.note.title + '\n\n' + this.state.note.body,
message: `${this.state.note.title}\n\n${this.state.note.body}`,
title: this.state.note.title,
});
}

View File

@@ -37,7 +37,7 @@ class NotesScreenComponent extends BaseScreenComponent {
const makeCheckboxText = function(selected, sign, label) {
const s = sign === 'tick' ? '✓' : '⬤';
return (selected ? s + ' ' : '') + label;
return (selected ? `${s} ` : '') + label;
};
for (let field in sortNoteOptions) {
@@ -49,17 +49,17 @@ class NotesScreenComponent extends BaseScreenComponent {
}
buttons.push({
text: makeCheckboxText(Setting.value('notes.sortOrder.reverse'), 'tick', '[ ' + Setting.settingMetadata('notes.sortOrder.reverse').label() + ' ]'),
text: makeCheckboxText(Setting.value('notes.sortOrder.reverse'), 'tick', `[ ${Setting.settingMetadata('notes.sortOrder.reverse').label()} ]`),
id: { name: 'notes.sortOrder.reverse', value: !Setting.value('notes.sortOrder.reverse') },
});
buttons.push({
text: makeCheckboxText(Setting.value('uncompletedTodosOnTop'), 'tick', '[ ' + Setting.settingMetadata('uncompletedTodosOnTop').label() + ' ]'),
text: makeCheckboxText(Setting.value('uncompletedTodosOnTop'), 'tick', `[ ${Setting.settingMetadata('uncompletedTodosOnTop').label()} ]`),
id: { name: 'uncompletedTodosOnTop', value: !Setting.value('uncompletedTodosOnTop') },
});
buttons.push({
text: makeCheckboxText(Setting.value('showCompletedTodos'), 'tick', '[ ' + Setting.settingMetadata('showCompletedTodos').label() + ' ]'),
text: makeCheckboxText(Setting.value('showCompletedTodos'), 'tick', `[ ${Setting.settingMetadata('showCompletedTodos').label()} ]`),
id: { name: 'showCompletedTodos', value: !Setting.value('showCompletedTodos') },
});

View File

@@ -59,7 +59,7 @@ class OneDriveLoginScreenComponent extends BaseScreenComponent {
this.props.dispatch({ type: 'NAV_BACK' });
reg.scheduleSync(0);
} catch (error) {
alert('Could not login to OneDrive. Please try again\n\n' + error.message + '\n\n' + url);
alert(`Could not login to OneDrive. Please try again\n\n${error.message}\n\n${url}`);
}
this.authCode_ = null;

View File

@@ -125,7 +125,7 @@ class SearchScreenComponent extends BaseScreenComponent {
}
notes = await Note.previews(null, {
anywherePattern: '*' + temp.join('*') + '*',
anywherePattern: `*${temp.join('*')}*`,
});
}
}

View File

@@ -60,7 +60,7 @@ class StatusScreenComponent extends BaseScreenComponent {
let style = Object.assign({}, baseStyle);
style.fontWeight = 'bold';
if (i > 0) style.paddingTop = 20;
lines.push({ key: 'section_' + i, isSection: true, text: section.title });
lines.push({ key: `section_${i}`, isSection: true, text: section.title });
for (let n in section.body) {
if (!section.body.hasOwnProperty(n)) continue;
@@ -82,10 +82,10 @@ class StatusScreenComponent extends BaseScreenComponent {
text = item;
}
lines.push({ key: 'item_' + i + '_' + n, text: text, retryHandler: retryHandler });
lines.push({ key: `item_${i}_${n}`, text: text, retryHandler: retryHandler });
}
lines.push({ key: 'divider2_' + i, isDivider: true });
lines.push({ key: `divider2_${i}`, isDivider: true });
}
return (

View File

@@ -16,7 +16,7 @@ shared.init = function(comp) {
shared.checkSyncConfig = async function(comp, settings) {
const syncTargetId = settings['sync.target'];
const SyncTargetClass = SyncTargetRegistry.classById(syncTargetId);
const options = Setting.subValues('sync.' + syncTargetId, settings);
const options = Setting.subValues(`sync.${syncTargetId}`, settings);
comp.setState({ checkSyncConfigResult: 'checking' });
const result = await SyncTargetClass.checkConfig(ObjectUtils.convertValuesToFunctions(options));
comp.setState({ checkSyncConfigResult: result });

View File

@@ -34,7 +34,7 @@ class Shared {
try {
const response = await api.execAuthToken(this.comp_.state.authCode);
Setting.setValue('sync.' + this.syncTargetId() + '.auth', response.access_token);
Setting.setValue(`sync.${this.syncTargetId()}.auth`, response.access_token);
api.setAuthToken(response.access_token);
await showInfoMessageBox(_('The application has been authorised!'));
this.comp_.props.dispatch({ type: 'NAV_BACK' });

View File

@@ -16,7 +16,7 @@ function folderIsVisible(folders, folderId, collapsedFolderIds) {
while (true) {
let folder = BaseModel.byId(folders, folderId);
if (!folder) throw new Error('No folder with id ' + folder.id);
if (!folder) throw new Error(`No folder with id ${folder.id}`);
if (!folder.parent_id) return true;
if (collapsedFolderIds.indexOf(folder.parent_id) >= 0) return false;
folderId = folder.parent_id;

View File

@@ -76,7 +76,7 @@ class SideMenuContentNoteComponent extends Component {
for (const option of options) {
if (option.isDivider) {
items.push(this.renderDivider('divider_' + dividerIndex++));
items.push(this.renderDivider(`divider_${dividerIndex++}`));
} else {
items.push(this.renderSideBarButton(option.title, option.title, null, option.onPress));
}