1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-30 23:44:55 +02:00

Tools: Apply rule @typescript-eslint/type-annotation-spacing

This commit is contained in:
Laurent Cozic
2020-11-12 19:13:28 +00:00
parent 62feb7ff60
commit d20694e52c
291 changed files with 2205 additions and 2203 deletions

View File

@ -17,20 +17,20 @@ interface MenuItems {
}
interface MenuItemProps {
[key:string]: any,
[key: string]: any,
}
interface MenuItemPropsCache {
[key:string]: any,
[key: string]: any,
}
interface MenuItemCache {
[key:string]: MenuItems,
[key: string]: MenuItems,
}
const createShallowObjectEqualSelector = createSelectorCreator(
defaultMemoize,
(prev:any, next:any) => {
(prev: any, next: any) => {
if (Object.keys(prev).length !== Object.keys(next).length) return false;
for (const n in prev) {
if (prev[n] !== next[n]) return false;
@ -42,10 +42,10 @@ const createShallowObjectEqualSelector = createSelectorCreator(
// This selector ensures that for the given command names, the same toolbar
// button array is returned if the underlying toolbar buttons have not changed.
const selectObjectByCommands = createCachedSelector(
(state:any) => state.array,
(array:any[]) => array
(state: any) => state.array,
(array: any[]) => array
)({
keySelector: (_state:any, commandNames:string[]) => {
keySelector: (_state: any, commandNames: string[]) => {
return commandNames.join('_');
},
selectorCreator: createShallowObjectEqualSelector,
@ -53,26 +53,26 @@ const selectObjectByCommands = createCachedSelector(
export default class MenuUtils {
private service_:CommandService;
private menuItemCache_:MenuItemCache = {};
private menuItemPropsCache_:MenuItemPropsCache = {};
private service_: CommandService;
private menuItemCache_: MenuItemCache = {};
private menuItemPropsCache_: MenuItemPropsCache = {};
constructor(service:CommandService) {
constructor(service: CommandService) {
this.service_ = service;
}
private get service():CommandService {
private get service(): CommandService {
return this.service_;
}
private get keymapService():KeymapService {
private get keymapService(): KeymapService {
return KeymapService.instance();
}
public commandToMenuItem(commandName:string, onClick:Function):MenuItem {
public commandToMenuItem(commandName: string, onClick: Function): MenuItem {
const command = this.service.commandByName(commandName);
const item:MenuItem = {
const item: MenuItem = {
id: command.declaration.name,
label: this.service.label(commandName),
click: () => onClick(command.declaration.name),
@ -87,17 +87,17 @@ export default class MenuUtils {
return item;
}
public commandToStatefulMenuItem(commandName:string, ...args:any[]):MenuItem {
public commandToStatefulMenuItem(commandName: string, ...args: any[]): MenuItem {
return this.commandToMenuItem(commandName, () => {
return this.service.execute(commandName, ...args);
});
}
public commandsToMenuItems(commandNames:string[], onClick:Function):MenuItems {
const key:string = `${this.keymapService.lastSaveTime}_${commandNames.join('_')}`;
public commandsToMenuItems(commandNames: string[], onClick: Function): MenuItems {
const key: string = `${this.keymapService.lastSaveTime}_${commandNames.join('_')}`;
if (this.menuItemCache_[key]) return this.menuItemCache_[key];
const output:MenuItems = {};
const output: MenuItems = {};
for (const commandName of commandNames) {
output[commandName] = this.commandToMenuItem(commandName, onClick);
@ -108,8 +108,8 @@ export default class MenuUtils {
return output;
}
public commandsToMenuItemProps(commandNames:string[], whenClauseContext:any):MenuItemProps {
const output:MenuItemProps = {};
public commandsToMenuItemProps(commandNames: string[], whenClauseContext: any): MenuItemProps {
const output: MenuItemProps = {};
for (const commandName of commandNames) {
const newProps = {

View File

@ -8,7 +8,7 @@ export interface ToolbarButtonInfo {
tooltip: string,
iconName: string,
enabled: boolean,
onClick():void,
onClick(): void,
title: string,
}
@ -17,23 +17,23 @@ interface ToolbarButtonCacheItem {
}
interface ToolbarButtonCache {
[key:string]: ToolbarButtonCacheItem,
[key: string]: ToolbarButtonCacheItem,
}
export default class ToolbarButtonUtils {
private service_:CommandService;
private toolbarButtonCache_:ToolbarButtonCache = {};
private service_: CommandService;
private toolbarButtonCache_: ToolbarButtonCache = {};
constructor(service:CommandService) {
constructor(service: CommandService) {
this.service_ = service;
}
private get service():CommandService {
private get service(): CommandService {
return this.service_;
}
private commandToToolbarButton(commandName:string, whenClauseContext:any):ToolbarButtonInfo {
private commandToToolbarButton(commandName: string, whenClauseContext: any): ToolbarButtonInfo {
const newEnabled = this.service.isEnabled(commandName, whenClauseContext);
const newTitle = this.service.title(commandName);
@ -68,8 +68,8 @@ export default class ToolbarButtonUtils {
// This method ensures that if the provided commandNames and state hasn't changed
// the output also won't change. Invididual toolbarButtonInfo also won't changed
// if the state they use hasn't changed. This is to avoid useless renders of the toolbars.
public commandsToToolbarButtons(commandNames:string[], whenClauseContext:any):ToolbarButtonInfo[] {
const output:ToolbarButtonInfo[] = [];
public commandsToToolbarButtons(commandNames: string[], whenClauseContext: any): ToolbarButtonInfo[] {
const output: ToolbarButtonInfo[] = [];
for (const commandName of commandNames) {
if (commandName === '-') {

View File

@ -1,7 +1,7 @@
import markdownUtils, { MarkdownTableHeader, MarkdownTableRow } from '../../markdownUtils';
export default function commandsToMarkdownTable():string {
const headers:MarkdownTableHeader[] = [
export default function commandsToMarkdownTable(): string {
const headers: MarkdownTableHeader[] = [
{
name: 'commandName',
label: 'Name',
@ -16,11 +16,11 @@ export default function commandsToMarkdownTable():string {
},
];
const rows:MarkdownTableRow[] = [];
const rows: MarkdownTableRow[] = [];
for (const commandName in this.commands_) {
const row:MarkdownTableRow = {
const row: MarkdownTableRow = {
commandName: commandName,
description: this.label(commandName),
};

View File

@ -1,4 +1,4 @@
export default function propsHaveChanged(previous:any, next:any):boolean {
export default function propsHaveChanged(previous: any, next: any): boolean {
if (!previous && next) return true;
if (previous && !next) return true;
if (!previous && !next) return false;

View File

@ -4,7 +4,7 @@ const BaseModel = require('../../BaseModel').default;
const Folder = require('../../models/Folder');
const MarkupToHtml = require('@joplin/renderer/MarkupToHtml').default;
export default function stateToWhenClauseContext(state:any) {
export default function stateToWhenClauseContext(state: any) {
const noteId = state.selectedNoteIds.length === 1 ? state.selectedNoteIds[0] : null;
const note = noteId ? BaseModel.byId(state.notes, noteId) : null;