1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-06 09:19:22 +02:00

Tools: Implement "prefer-object-spread" eslint rule

This commit is contained in:
Laurent Cozic
2023-06-01 12:02:36 +01:00
parent 804d674d37
commit c89edd7b22
126 changed files with 588 additions and 909 deletions

View File

@@ -25,7 +25,7 @@ const themes: any = {
export function themeById(themeId: string) {
if (!themes[themeId]) throw new Error(`Invalid theme ID: ${themeId}`);
const output = Object.assign({}, themes[themeId]);
const output = { ...themes[themeId] };
if (!output.headerBackgroundColor) {
output.headerBackgroundColor = output.appearance === 'light' ? '#F0F0F0' : '#2D3136';
@@ -164,54 +164,45 @@ function addExtraStyles(style: any) {
style.configScreenPadding = style.mainPadding * 2;
style.icon = Object.assign({},
style.icon,
{ color: style.color }
);
style.icon = {
...style.icon,
color: style.color,
};
style.lineInput = Object.assign({},
style.lineInput,
{
color: style.color,
backgroundColor: style.backgroundColor,
}
);
style.lineInput = {
...style.lineInput,
color: style.color,
backgroundColor: style.backgroundColor,
};
style.headerStyle = Object.assign({},
style.headerStyle,
{
color: style.color,
backgroundColor: style.backgroundColor,
}
);
style.headerStyle = {
...style.headerStyle,
color: style.color,
backgroundColor: style.backgroundColor,
};
style.inputStyle = Object.assign({},
style.inputStyle,
{
color: style.color,
backgroundColor: style.backgroundColor,
borderColor: style.dividerColor,
}
);
style.inputStyle = {
...style.inputStyle,
color: style.color,
backgroundColor: style.backgroundColor,
borderColor: style.dividerColor,
};
style.containerStyle = Object.assign({},
style.containerStyle,
{
color: style.color,
backgroundColor: style.backgroundColor,
}
);
style.containerStyle = {
...style.containerStyle,
color: style.color,
backgroundColor: style.backgroundColor,
};
style.buttonStyle = Object.assign({},
style.buttonStyle,
{
color: style.color4,
backgroundColor: style.backgroundColor4,
borderColor: style.borderColor4,
userSelect: 'none',
// cursor: 'pointer',
}
);
style.buttonStyle = {
...style.buttonStyle,
color: style.color4,
backgroundColor: style.backgroundColor4,
borderColor: style.borderColor4,
userSelect: 'none',
// cursor: 'pointer',
};
style.tagStyle = {
fontSize: style.fontSize,
@@ -254,45 +245,35 @@ function addExtraStyles(style: any) {
color: style.color,
};
style.clickableTextStyle = Object.assign({}, style.textStyle, {
userSelect: 'none',
});
style.clickableTextStyle = { ...style.textStyle, userSelect: 'none' };
style.textStyle2 = Object.assign({}, style.textStyle,
{ color: style.color2 }
);
style.textStyle2 = { ...style.textStyle,
color: style.color2,
};
style.textStyleMinor = Object.assign({}, style.textStyle,
{
color: style.colorFaded,
fontSize: style.fontSize * 0.8,
}
);
style.textStyleMinor = { ...style.textStyle,
color: style.colorFaded,
fontSize: style.fontSize * 0.8,
};
style.urlStyle = Object.assign({}, style.textStyle,
{
textDecoration: 'underline',
color: style.urlColor,
}
);
style.urlStyle = { ...style.textStyle,
textDecoration: 'underline',
color: style.urlColor,
};
style.h1Style = Object.assign({},
style.textStyle,
{
color: style.color,
fontSize: style.textStyle.fontSize * 1.5,
fontWeight: 'bold',
}
);
style.h1Style = {
...style.textStyle,
color: style.color,
fontSize: style.textStyle.fontSize * 1.5,
fontWeight: 'bold',
};
style.h2Style = Object.assign({},
style.textStyle,
{
color: style.color,
fontSize: style.textStyle.fontSize * 1.3,
fontWeight: 'bold',
}
);
style.h2Style = {
...style.textStyle,
color: style.color,
fontSize: style.textStyle.fontSize * 1.3,
fontWeight: 'bold',
};
style.dialogModalLayer = {
zIndex: 9999,
@@ -349,9 +330,9 @@ function addExtraStyles(style: any) {
fontSize: style.fontSize,
};
style.dialogTitle = Object.assign({}, style.h1Style, { marginBottom: '1.2em' });
style.dialogTitle = { ...style.h1Style, marginBottom: '1.2em' };
style.dropdownList = Object.assign({}, style.inputStyle);
style.dropdownList = { ...style.inputStyle };
style.colorHover = style.color;
style.backgroundHover = `${style.selectedColor2}44`;
@@ -389,7 +370,7 @@ export function themeStyle(themeId: number) {
// All theme are based on the light style, and just override the
// relevant properties
output = Object.assign({}, globalStyle, fontSizes, themes[themeId]);
output = { ...globalStyle, ...fontSizes, ...themes[themeId] };
output = addMissingProperties(output);
output = addExtraStyles(output);
output.cacheKey = cacheKey;