1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-21 09:38:01 +02:00

Tools: Add eslint rule "no-unneeded-ternary"

This commit is contained in:
Laurent Cozic 2023-02-21 17:10:53 +00:00
parent 08c9a25182
commit 9e73d3590b
4 changed files with 15 additions and 14 deletions

View File

@ -92,6 +92,7 @@ module.exports = {
// "react-hooks/exhaustive-deps": "warn",
'promise/prefer-await-to-then': 'error',
'no-unneeded-ternary': 'error',
// -------------------------------
// Formatting

View File

@ -512,14 +512,14 @@ function useMenu(props: Props) {
// Issue: https://github.com/laurent22/joplin/issues/934
submenu: [{
label: _('About Joplin'),
visible: shim.isMac() ? true : false,
visible: !!shim.isMac(),
click: () => _showAbout(),
}, {
type: 'separator',
visible: shim.isMac() ? true : false,
visible: !!shim.isMac(),
}, {
label: _('Preferences...'),
visible: shim.isMac() ? true : false,
visible: !!shim.isMac(),
accelerator: shim.isMac() && keymapService.getAccelerator('config'),
click: () => {
props.dispatch({
@ -529,11 +529,11 @@ function useMenu(props: Props) {
},
}, {
label: _('Check for updates...'),
visible: shim.isMac() ? true : false,
visible: !!shim.isMac(),
click: () => _checkForUpdates(),
}, {
type: 'separator',
visible: shim.isMac() ? true : false,
visible: !!shim.isMac(),
},
shim.isMac() ? noItem : newNoteItem,
shim.isMac() ? noItem : newTodoItem,
@ -541,14 +541,14 @@ function useMenu(props: Props) {
shim.isMac() ? noItem : newSubFolderItem,
{
type: 'separator',
visible: shim.isMac() ? false : true,
visible: !shim.isMac(),
}, {
label: _('Import'),
visible: shim.isMac() ? false : true,
visible: !shim.isMac(),
submenu: importItems,
}, {
label: _('Export all'),
visible: shim.isMac() ? false : true,
visible: !shim.isMac(),
submenu: exportItems,
}, {
type: 'separator',
@ -586,7 +586,7 @@ function useMenu(props: Props) {
const rootMenuFileMacOs = {
label: _('&File'),
visible: shim.isMac() ? true : false,
visible: !!shim.isMac(),
submenu: [
newNoteItem,
newTodoItem,
@ -796,7 +796,7 @@ function useMenu(props: Props) {
click() { void bridge().openExternal('https://joplinapp.org/donate/'); },
}, {
label: _('Check for updates...'),
visible: shim.isMac() ? false : true,
visible: !shim.isMac(),
click: () => _checkForUpdates(),
},
separator(),
@ -818,10 +818,10 @@ function useMenu(props: Props) {
{
type: 'separator',
visible: shim.isMac() ? false : true,
visible: !shim.isMac(),
}, {
label: _('About Joplin'),
visible: shim.isMac() ? false : true,
visible: !shim.isMac(),
click: () => _showAbout(),
}],
},

View File

@ -236,7 +236,7 @@ shared.initState = async function(comp: any) {
mode: mode,
folder: folder,
isLoading: false,
fromShare: comp.props.sharedData ? true : false,
fromShare: !!comp.props.sharedData,
noteResources: await shared.attachedResources(note ? note.body : ''),
});

View File

@ -11,5 +11,5 @@ export default function(url: string) {
return true;
}
return BAD_PROTO_RE.test(str) ? (GOOD_DATA_RE.test(str) ? true : false) : true;
return BAD_PROTO_RE.test(str) ? (!!GOOD_DATA_RE.test(str)) : true;
}