1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-02 12:47:41 +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", // "react-hooks/exhaustive-deps": "warn",
'promise/prefer-await-to-then': 'error', 'promise/prefer-await-to-then': 'error',
'no-unneeded-ternary': 'error',
// ------------------------------- // -------------------------------
// Formatting // Formatting

View File

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

View File

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

View File

@ -11,5 +11,5 @@ export default function(url: string) {
return true; 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;
} }