1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Tools: Apply eslint rule "no-multi-spaces"

This commit is contained in:
Laurent Cozic 2021-01-23 15:51:19 +00:00
parent 0e2351e79e
commit 63559ac8b9
50 changed files with 95 additions and 92 deletions

View File

@ -125,6 +125,7 @@ module.exports = {
'space-before-blocks': 'error', 'space-before-blocks': 'error',
'spaced-comment': ['error', 'always'], 'spaced-comment': ['error', 'always'],
'keyword-spacing': ['error', { 'before': true, 'after': true }], 'keyword-spacing': ['error', { 'before': true, 'after': true }],
'no-multi-spaces': ['error'],
}, },
'plugins': [ 'plugins': [
'react', 'react',

View File

@ -14,7 +14,7 @@ function newTestMdToHtml(options: any = null) {
...options, ...options,
}; };
return new MdToHtml(options); return new MdToHtml(options);
} }
describe('MdToHtml', function() { describe('MdToHtml', function() {

View File

@ -6,7 +6,7 @@ const { synchronizerStart, allSyncTargetItemsEncrypted, kvStore, setupDatabaseAn
import Folder from '@joplin/lib/models/Folder'; import Folder from '@joplin/lib/models/Folder';
import Note from '@joplin/lib/models/Note'; import Note from '@joplin/lib/models/Note';
import Resource from '@joplin/lib/models/Resource'; import Resource from '@joplin/lib/models/Resource';
import ResourceFetcher from '@joplin/lib/services/ResourceFetcher'; import ResourceFetcher from '@joplin/lib/services/ResourceFetcher';
import MasterKey from '@joplin/lib/models/MasterKey'; import MasterKey from '@joplin/lib/models/MasterKey';
import BaseItem from '@joplin/lib/models/BaseItem'; import BaseItem from '@joplin/lib/models/BaseItem';

View File

@ -8,7 +8,7 @@ const { synchronizerStart, tempFilePath, resourceFetcher, setupDatabaseAndSynchr
import Folder from '@joplin/lib/models/Folder'; import Folder from '@joplin/lib/models/Folder';
import Note from '@joplin/lib/models/Note'; import Note from '@joplin/lib/models/Note';
import Resource from '@joplin/lib/models/Resource'; import Resource from '@joplin/lib/models/Resource';
import ResourceFetcher from '@joplin/lib/services/ResourceFetcher'; import ResourceFetcher from '@joplin/lib/services/ResourceFetcher';
import BaseItem from '@joplin/lib/models/BaseItem'; import BaseItem from '@joplin/lib/models/BaseItem';
let insideBeforeEach = false; let insideBeforeEach = false;
@ -246,7 +246,7 @@ describe('Synchronizer.resources', function() {
// the content from client 2 // the content from client 2
await resourceFetcher().start(); await resourceFetcher().start();
await resourceFetcher().waitForAllFinished(); await resourceFetcher().waitForAllFinished();
const localContent = await Resource.resourceBlobContent(resource.id, 'utf8'); const localContent = await Resource.resourceBlobContent(resource.id, 'utf8');
expect(localContent).toBe('1234 MOD 2'); expect(localContent).toBe('1234 MOD 2');
// Check that the Conflict note has been generated, with the conflict resource // Check that the Conflict note has been generated, with the conflict resource
@ -259,7 +259,7 @@ describe('Synchronizer.resources', function() {
expect(!!conflictNote).toBe(true); expect(!!conflictNote).toBe(true);
const resourceIds = await Note.linkedResourceIds(conflictNote.body); const resourceIds = await Note.linkedResourceIds(conflictNote.body);
expect(resourceIds.length).toBe(1); expect(resourceIds.length).toBe(1);
const conflictContent = await Resource.resourceBlobContent(resourceIds[0], 'utf8'); const conflictContent = await Resource.resourceBlobContent(resourceIds[0], 'utf8');
expect(conflictContent).toBe('1234 MOD 1'); expect(conflictContent).toBe('1234 MOD 1');
} }
})); }));

View File

@ -141,7 +141,7 @@ describe('services_CommandService', function() {
expect(toolbarInfos1[0] === toolbarInfos2[0]).toBe(true); expect(toolbarInfos1[0] === toolbarInfos2[0]).toBe(true);
expect(toolbarInfos1[1] === toolbarInfos2[1]).toBe(true); expect(toolbarInfos1[1] === toolbarInfos2[1]).toBe(true);
const toolbarInfos3 = toolbarButtonUtils.commandsToToolbarButtons(['test1', 'test2'], { const toolbarInfos3 = toolbarButtonUtils.commandsToToolbarButtons(['test1', 'test2'], {
cond1: true, cond1: true,
cond2: true, cond2: true,
}); });

View File

@ -21,7 +21,7 @@ describe('services_EncryptionService', function() {
beforeEach(async (done) => { beforeEach(async (done) => {
await setupDatabaseAndSynchronizer(1); await setupDatabaseAndSynchronizer(1);
await switchClient(1); await switchClient(1);
service = new EncryptionService(); service = new EncryptionService();
BaseItem.encryptionService_ = service; BaseItem.encryptionService_ = service;
Setting.setValue('encryption.enabled', true); Setting.setValue('encryption.enabled', true);
done(); done();

View File

@ -513,8 +513,8 @@ describe('services_SearchFilter', function() {
const today = parseInt(time.goBackInTime(Date.now(), 0, 'day'), 10); const today = parseInt(time.goBackInTime(Date.now(), 0, 'day'), 10);
const yesterday = parseInt(time.goBackInTime(Date.now(), 1, 'day'), 10); const yesterday = parseInt(time.goBackInTime(Date.now(), 1, 'day'), 10);
const dayBeforeYesterday = parseInt(time.goBackInTime(Date.now(), 2, 'day'), 10); const dayBeforeYesterday = parseInt(time.goBackInTime(Date.now(), 2, 'day'), 10);
const n1 = await Note.save({ title: 'I made this', body: 'today', updated_time: today, user_updated_time: today }, { autoTimestamp: false }); const n1 = await Note.save({ title: 'I made this', body: 'today', updated_time: today, user_updated_time: today }, { autoTimestamp: false });
const n11 = await Note.save({ title: 'I also made this', body: 'today', updated_time: today, user_updated_time: today }, { autoTimestamp: false }); const n11 = await Note.save({ title: 'I also made this', body: 'today', updated_time: today, user_updated_time: today }, { autoTimestamp: false });
const n2 = await Note.save({ title: 'I made this', body: 'yesterday', updated_time: yesterday, user_updated_time: yesterday }, { autoTimestamp: false }); const n2 = await Note.save({ title: 'I made this', body: 'yesterday', updated_time: yesterday, user_updated_time: yesterday }, { autoTimestamp: false });
const n3 = await Note.save({ title: 'I made this', body: 'day before yesterday', updated_time: dayBeforeYesterday ,user_updated_time: dayBeforeYesterday }, { autoTimestamp: false }); const n3 = await Note.save({ title: 'I made this', body: 'day before yesterday', updated_time: dayBeforeYesterday ,user_updated_time: dayBeforeYesterday }, { autoTimestamp: false });
@ -582,9 +582,9 @@ describe('services_SearchFilter', function() {
it('should support filtering by latitude, longitude, altitude', (async () => { it('should support filtering by latitude, longitude, altitude', (async () => {
let rows; let rows;
const n1 = await Note.save({ title: 'I made this', body: 'this week', latitude: 12.97, longitude: 88.88, altitude: 69.96 }); const n1 = await Note.save({ title: 'I made this', body: 'this week', latitude: 12.97, longitude: 88.88, altitude: 69.96 });
const n2 = await Note.save({ title: 'I made this', body: 'the week before', latitude: 42.11, longitude: 77.77, altitude: 42.00 }); const n2 = await Note.save({ title: 'I made this', body: 'the week before', latitude: 42.11, longitude: 77.77, altitude: 42.00 });
const n3 = await Note.save({ title: 'I made this', body: 'before before week', latitude: 82.01, longitude: 66.66, altitude: 13.13 }); const n3 = await Note.save({ title: 'I made this', body: 'before before week', latitude: 82.01, longitude: 66.66, altitude: 13.13 });
await engine.syncTables(); await engine.syncTables();

View File

@ -8,7 +8,7 @@ import Resource from '@joplin/lib/models/Resource';
import Note from '@joplin/lib/models/Note'; import Note from '@joplin/lib/models/Note';
import Tag from '@joplin/lib/models/Tag'; import Tag from '@joplin/lib/models/Tag';
import NoteTag from '@joplin/lib/models/NoteTag'; import NoteTag from '@joplin/lib/models/NoteTag';
import ResourceService from '@joplin/lib/services/ResourceService'; import ResourceService from '@joplin/lib/services/ResourceService';
import SearchEngine from '@joplin/lib/services/searchengine/SearchEngine'; import SearchEngine from '@joplin/lib/services/searchengine/SearchEngine';
const createFolderForPagination = async (num: number, time: number) => { const createFolderForPagination = async (num: number, time: number) => {

View File

@ -46,10 +46,10 @@ const SyncTargetNextcloud = require('@joplin/lib/SyncTargetNextcloud.js');
const SyncTargetDropbox = require('@joplin/lib/SyncTargetDropbox.js'); const SyncTargetDropbox = require('@joplin/lib/SyncTargetDropbox.js');
const SyncTargetAmazonS3 = require('@joplin/lib/SyncTargetAmazonS3.js'); const SyncTargetAmazonS3 = require('@joplin/lib/SyncTargetAmazonS3.js');
import SyncTargetJoplinServer from '@joplin/lib/SyncTargetJoplinServer'; import SyncTargetJoplinServer from '@joplin/lib/SyncTargetJoplinServer';
import EncryptionService from '@joplin/lib/services/EncryptionService'; import EncryptionService from '@joplin/lib/services/EncryptionService';
import DecryptionWorker from '@joplin/lib/services/DecryptionWorker'; import DecryptionWorker from '@joplin/lib/services/DecryptionWorker';
import RevisionService from '@joplin/lib/services/RevisionService'; import RevisionService from '@joplin/lib/services/RevisionService';
import ResourceFetcher from '@joplin/lib/services/ResourceFetcher'; import ResourceFetcher from '@joplin/lib/services/ResourceFetcher';
const WebDavApi = require('@joplin/lib/WebDavApi'); const WebDavApi = require('@joplin/lib/WebDavApi');
const DropboxApi = require('@joplin/lib/DropboxApi'); const DropboxApi = require('@joplin/lib/DropboxApi');
import JoplinServerApi from '@joplin/lib/JoplinServerApi2'; import JoplinServerApi from '@joplin/lib/JoplinServerApi2';

View File

@ -18,7 +18,7 @@ describe('timeUtils', function() {
expect(time.goBackInTime(startDate, 1, 'day')).toBe(endDate.getTime().toString()); expect(time.goBackInTime(startDate, 1, 'day')).toBe(endDate.getTime().toString());
// We're always subtracting time from the beginning of the current period. // We're always subtracting time from the beginning of the current period.
startDate = new Date('3 Aug 2020 07:30:20'); startDate = new Date('3 Aug 2020 07:30:20');
expect(time.goBackInTime(startDate, 1, 'day')).toBe(endDate.getTime().toString()); expect(time.goBackInTime(startDate, 1, 'day')).toBe(endDate.getTime().toString());
// Note: this test randomly fails - https://github.com/laurent22/joplin/issues/3722 // Note: this test randomly fails - https://github.com/laurent22/joplin/issues/3722
@ -42,7 +42,7 @@ describe('timeUtils', function() {
expect(time.goForwardInTime(startDate, 1, 'day')).toBe(endDate.getTime().toString()); expect(time.goForwardInTime(startDate, 1, 'day')).toBe(endDate.getTime().toString());
startDate = new Date('2 Aug 2020 07:30:20'); startDate = new Date('2 Aug 2020 07:30:20');
expect(time.goForwardInTime(startDate, 1, 'day')).toBe(endDate.getTime().toString()); expect(time.goForwardInTime(startDate, 1, 'day')).toBe(endDate.getTime().toString());

View File

@ -33,13 +33,13 @@ const fs = require('fs-extra');
import Tag from '@joplin/lib/models/Tag'; import Tag from '@joplin/lib/models/Tag';
const { reg } = require('@joplin/lib/registry.js'); const { reg } = require('@joplin/lib/registry.js');
const packageInfo = require('./packageInfo.js'); const packageInfo = require('./packageInfo.js');
import DecryptionWorker from '@joplin/lib/services/DecryptionWorker'; import DecryptionWorker from '@joplin/lib/services/DecryptionWorker';
const ClipperServer = require('@joplin/lib/ClipperServer'); const ClipperServer = require('@joplin/lib/ClipperServer');
const { webFrame } = require('electron'); const { webFrame } = require('electron');
const Menu = bridge().Menu; const Menu = bridge().Menu;
const PluginManager = require('@joplin/lib/services/PluginManager'); const PluginManager = require('@joplin/lib/services/PluginManager');
import RevisionService from '@joplin/lib/services/RevisionService'; import RevisionService from '@joplin/lib/services/RevisionService';
import MigrationService from '@joplin/lib/services/MigrationService'; import MigrationService from '@joplin/lib/services/MigrationService';
const TemplateUtils = require('@joplin/lib/TemplateUtils'); const TemplateUtils = require('@joplin/lib/TemplateUtils');
const CssUtils = require('@joplin/lib/CssUtils'); const CssUtils = require('@joplin/lib/CssUtils');
// import populateDatabase from '@joplin/lib/services/debug/populateDatabase'; // import populateDatabase from '@joplin/lib/services/debug/populateDatabase';

View File

@ -198,7 +198,7 @@ function Button(props: Props) {
function renderTitle() { function renderTitle() {
if (!props.title) return null; if (!props.title) return null;
return <StyledTitle color={props.color}>{props.title}</StyledTitle>; return <StyledTitle color={props.color}>{props.title}</StyledTitle>;
} }
function onClick() { function onClick() {

View File

@ -29,7 +29,7 @@ export const StyledListItem = styled.a`
opacity: ${(props: any) => props.selected ? 1 : 0.8}; opacity: ${(props: any) => props.selected ? 1 : 0.8};
&:hover { &:hover {
background-color: ${(props: any) => props.theme.backgroundColorHover2}; background-color: ${(props: any) => props.theme.backgroundColorHover2};
} }
`; `;

View File

@ -34,7 +34,7 @@ const { connect } = require('react-redux');
const { PromptDialog } = require('../PromptDialog.min.js'); const { PromptDialog } = require('../PromptDialog.min.js');
const NotePropertiesDialog = require('../NotePropertiesDialog.min.js'); const NotePropertiesDialog = require('../NotePropertiesDialog.min.js');
const PluginManager = require('@joplin/lib/services/PluginManager'); const PluginManager = require('@joplin/lib/services/PluginManager');
import EncryptionService from '@joplin/lib/services/EncryptionService'; import EncryptionService from '@joplin/lib/services/EncryptionService';
const ipcRenderer = require('electron').ipcRenderer; const ipcRenderer = require('electron').ipcRenderer;
interface LayerModalState { interface LayerModalState {

View File

@ -133,7 +133,7 @@ function useMenu(props: Props) {
if (Array.isArray(path)) path = path[0]; if (Array.isArray(path)) path = path[0];
const modalMessage = _('Importing from "%s" as "%s" format. Please wait...', path, module.format); const modalMessage = _('Importing from "%s" as "%s" format. Please wait...', path, module.format);
void CommandService.instance().execute('showModalMessage', modalMessage); void CommandService.instance().execute('showModalMessage', modalMessage);

View File

@ -9,7 +9,7 @@ import { useScrollHandler, usePrevious, cursorPositionToTextOffset, useRootSize
import Toolbar from './Toolbar'; import Toolbar from './Toolbar';
import styles_ from './styles'; import styles_ from './styles';
import { RenderedBody, defaultRenderedBody } from './utils/types'; import { RenderedBody, defaultRenderedBody } from './utils/types';
import NoteTextViewer from '../../../NoteTextViewer'; import NoteTextViewer from '../../../NoteTextViewer';
import Editor from './Editor'; import Editor from './Editor';
import usePluginServiceRegistration from '../../utils/usePluginServiceRegistration'; import usePluginServiceRegistration from '../../utils/usePluginServiceRegistration';
import Setting from '@joplin/lib/models/Setting'; import Setting from '@joplin/lib/models/Setting';

View File

@ -158,7 +158,7 @@ export default function useCursorUtils(CodeMirror: any) {
CodeMirror.defineExtension('isAfterTrailingWhitespace', function() { CodeMirror.defineExtension('isAfterTrailingWhitespace', function() {
const { line, ch } = this.getCursor('head'); const { line, ch } = this.getCursor('head');
const beforeCursor = this.charCoords({ line: line, ch: ch - 1 }); const beforeCursor = this.charCoords({ line: line, ch: ch - 1 });
const afterCursor = this.charCoords({ line: line, ch: ch }); const afterCursor = this.charCoords({ line: line, ch: ch });
const currentLine = this.getLine(line); const currentLine = this.getLine(line);

View File

@ -19,9 +19,9 @@ export default function useKeymap(CodeMirror: any) {
function setupVim() { function setupVim() {
CodeMirror.Vim.defineAction('swapLineDown', CodeMirror.commands.swapLineDown); CodeMirror.Vim.defineAction('swapLineDown', CodeMirror.commands.swapLineDown);
CodeMirror.Vim.mapCommand('<A-j>', 'action', 'swapLineDown', {}, { context: 'normal', isEdit: true }); CodeMirror.Vim.mapCommand('<A-j>', 'action', 'swapLineDown', {}, { context: 'normal', isEdit: true });
CodeMirror.Vim.defineAction('swapLineUp', CodeMirror.commands.swapLineUp); CodeMirror.Vim.defineAction('swapLineUp', CodeMirror.commands.swapLineUp);
CodeMirror.Vim.mapCommand('<A-k>', 'action', 'swapLineUp', {}, { context: 'normal', isEdit: true }); CodeMirror.Vim.mapCommand('<A-k>', 'action', 'swapLineUp', {}, { context: 'normal', isEdit: true });
CodeMirror.Vim.defineAction('insertListElement', CodeMirror.commands.vimInsertListElement); CodeMirror.Vim.defineAction('insertListElement', CodeMirror.commands.vimInsertListElement);
CodeMirror.Vim.mapCommand('o', 'action', 'insertListElement', { after: true }, { context: 'normal', isEdit: true, interlaceInsertRepeat: true }); CodeMirror.Vim.mapCommand('o', 'action', 'insertListElement', { after: true }, { context: 'normal', isEdit: true, interlaceInsertRepeat: true });
} }

View File

@ -84,7 +84,7 @@ export default function useListIdent(CodeMirror: any) {
const tokens = cm.getLineTokens(anchor.line); const tokens = cm.getLineTokens(anchor.line);
const { start, end } = getListSpan(tokens, line); const { start, end } = getListSpan(tokens, line);
// Resets numbered list to 1. // Resets numbered list to 1.
cm.replaceRange('1. ', { line: anchor.line, ch: start }, { line: anchor.line, ch: end }); cm.replaceRange('1. ', { line: anchor.line, ch: start }, { line: anchor.line, ch: end });
} }
cm.indentLine(anchor.line, 'add'); cm.indentLine(anchor.line, 'add');

View File

@ -1,7 +1,7 @@
import * as React from 'react'; import * as React from 'react';
import { useState, useEffect, useCallback, useRef } from 'react'; import { useState, useEffect, useCallback, useRef } from 'react';
import TinyMCE from './NoteBody/TinyMCE/TinyMCE'; import TinyMCE from './NoteBody/TinyMCE/TinyMCE';
import CodeMirror from './NoteBody/CodeMirror/CodeMirror'; import CodeMirror from './NoteBody/CodeMirror/CodeMirror';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import MultiNoteActions from '../MultiNoteActions'; import MultiNoteActions from '../MultiNoteActions';
import { htmlToMarkdown, formNoteToNote } from './utils'; import { htmlToMarkdown, formNoteToNote } from './utils';

View File

@ -4,7 +4,7 @@ import Note from '@joplin/lib/models/Note';
import BaseModel from '@joplin/lib/BaseModel'; import BaseModel from '@joplin/lib/BaseModel';
import Resource from '@joplin/lib/models/Resource'; import Resource from '@joplin/lib/models/Resource';
const bridge = require('electron').remote.require('./bridge').default; const bridge = require('electron').remote.require('./bridge').default;
import ResourceFetcher from '@joplin/lib/services/ResourceFetcher'; import ResourceFetcher from '@joplin/lib/services/ResourceFetcher';
const { reg } = require('@joplin/lib/registry.js'); const { reg } = require('@joplin/lib/registry.js');
const joplinRendererUtils = require('@joplin/renderer').utils; const joplinRendererUtils = require('@joplin/renderer').utils;
const { clipboard } = require('electron'); const { clipboard } = require('electron');

View File

@ -11,8 +11,8 @@ import ResourceEditWatcher from '@joplin/lib/services/ResourceEditWatcher/index'
const { MarkupToHtml } = require('@joplin/renderer'); const { MarkupToHtml } = require('@joplin/renderer');
import Note from '@joplin/lib/models/Note'; import Note from '@joplin/lib/models/Note';
const { reg } = require('@joplin/lib/registry.js'); const { reg } = require('@joplin/lib/registry.js');
import ResourceFetcher from '@joplin/lib/services/ResourceFetcher'; import ResourceFetcher from '@joplin/lib/services/ResourceFetcher';
import DecryptionWorker from '@joplin/lib/services/DecryptionWorker'; import DecryptionWorker from '@joplin/lib/services/DecryptionWorker';
export interface OnLoadEvent { export interface OnLoadEvent {
formNote: FormNote; formNote: FormNote;

View File

@ -11,7 +11,7 @@ import Resource from '@joplin/lib/models/Resource';
const bridge = require('electron').remote.require('./bridge').default; const bridge = require('electron').remote.require('./bridge').default;
const { urlDecode } = require('@joplin/lib/string-utils'); const { urlDecode } = require('@joplin/lib/string-utils');
const urlUtils = require('@joplin/lib/urlUtils'); const urlUtils = require('@joplin/lib/urlUtils');
import ResourceFetcher from '@joplin/lib/services/ResourceFetcher'; import ResourceFetcher from '@joplin/lib/services/ResourceFetcher';
const { reg } = require('@joplin/lib/registry.js'); const { reg } = require('@joplin/lib/registry.js');
export default function useMessageHandler(scrollWhenReady: any, setScrollWhenReady: Function, editorRef: any, setLocalSearchResultCount: Function, dispatch: Function, formNote: FormNote) { export default function useMessageHandler(scrollWhenReady: any, setScrollWhenReady: Function, editorRef: any, setLocalSearchResultCount: Function, dispatch: Function, formNote: FormNote) {

View File

@ -1,6 +1,6 @@
import { useEffect } from 'react'; import { useEffect } from 'react';
import { FormNote, ScrollOptionTypes } from './types'; import { FormNote, ScrollOptionTypes } from './types';
import CommandService, { CommandDeclaration, CommandRuntime, CommandContext } from '@joplin/lib/services/CommandService'; import CommandService, { CommandDeclaration, CommandRuntime, CommandContext } from '@joplin/lib/services/CommandService';
import time from '@joplin/lib/time'; import time from '@joplin/lib/time';
const { reg } = require('@joplin/lib/registry.js'); const { reg } = require('@joplin/lib/registry.js');

View File

@ -121,7 +121,7 @@ class NoteSearchBarComponent extends React.Component {
// For more info: https://github.com/laurent22/joplin/pull/2329#issuecomment-578376835 // For more info: https://github.com/laurent22/joplin/pull/2329#issuecomment-578376835
const theme = themeStyle(this.props.themeId); const theme = themeStyle(this.props.themeId);
if (!this.props.searching) { if (!this.props.searching) {
if (this.props.resultCount === 0 && query.length > 0) { if (this.props.resultCount === 0 && query.length > 0) {
this.backgroundColor = theme.warningBackgroundColor; this.backgroundColor = theme.warningBackgroundColor;
} else { } else {
this.backgroundColor = theme.backgroundColor; this.backgroundColor = theme.backgroundColor;

View File

@ -56,7 +56,7 @@ export const StyledListItem = styled.div`
transition: 0.1s; transition: 0.1s;
&:hover { &:hover {
background-color: ${(props: any) => props.theme.backgroundColorHover2}; background-color: ${(props: any) => props.theme.backgroundColorHover2};
} }
`; `;

View File

@ -7,7 +7,7 @@ const { connect } = require('react-redux');
import Setting from '@joplin/lib/models/Setting'; import Setting from '@joplin/lib/models/Setting';
const bridge = require('electron').remote.require('./bridge').default; const bridge = require('electron').remote.require('./bridge').default;
const { themeStyle } = require('@joplin/lib/theme'); const { themeStyle } = require('@joplin/lib/theme');
import ReportService from '@joplin/lib/services/ReportService'; import ReportService from '@joplin/lib/services/ReportService';
const fs = require('fs-extra'); const fs = require('fs-extra');
interface Props { interface Props {

View File

@ -26,7 +26,7 @@ module.exports = async function() {
try { try {
// Use stdio: 'pipe' so that execSync doesn't print error directly to stdout // Use stdio: 'pipe' so that execSync doesn't print error directly to stdout
branch = execSync('git rev-parse --abbrev-ref HEAD', { stdio: 'pipe' }).toString().trim(); branch = execSync('git rev-parse --abbrev-ref HEAD', { stdio: 'pipe' }).toString().trim();
hash = execSync('git log --pretty="%h" -1', { stdio: 'pipe' }).toString().trim(); hash = execSync('git log --pretty="%h" -1', { stdio: 'pipe' }).toString().trim();
// The builds in CI are done from a 'detached HEAD' state // The builds in CI are done from a 'detached HEAD' state
if (branch === 'HEAD') branch = 'master'; if (branch === 'HEAD') branch = 'master';
} catch (err) { } catch (err) {

View File

@ -2,7 +2,7 @@ import shim from '@joplin/lib/shim';
const { dirname } = require('@joplin/lib/path-utils'); const { dirname } = require('@joplin/lib/path-utils');
import Setting from '@joplin/lib/models/Setting'; import Setting from '@joplin/lib/models/Setting';
const pluginAssets = require('./pluginAssets/index'); const pluginAssets = require('./pluginAssets/index');
import KvStore from '@joplin/lib/services/KvStore'; import KvStore from '@joplin/lib/services/KvStore';
export default class PluginAssetsLoader { export default class PluginAssetsLoader {

View File

@ -19,7 +19,7 @@ import Folder from '@joplin/lib/models/Folder';
const Clipboard = require('@react-native-community/clipboard').default; const Clipboard = require('@react-native-community/clipboard').default;
const md5 = require('md5'); const md5 = require('md5');
const { BackButtonService } = require('../../services/back-button.js'); const { BackButtonService } = require('../../services/back-button.js');
import NavService from '@joplin/lib/services/NavService'; import NavService from '@joplin/lib/services/NavService';
import BaseModel from '@joplin/lib/BaseModel'; import BaseModel from '@joplin/lib/BaseModel';
const { ActionButton } = require('../action-button.js'); const { ActionButton } = require('../action-button.js');
const { fileExtension, safeFileExtension } = require('@joplin/lib/path-utils'); const { fileExtension, safeFileExtension } = require('@joplin/lib/path-utils');
@ -30,7 +30,7 @@ import time from '@joplin/lib/time';
const { Checkbox } = require('../checkbox.js'); const { Checkbox } = require('../checkbox.js');
const { _ } = require('@joplin/lib/locale'); const { _ } = require('@joplin/lib/locale');
const { reg } = require('@joplin/lib/registry.js'); const { reg } = require('@joplin/lib/registry.js');
import ResourceFetcher from '@joplin/lib/services/ResourceFetcher'; import ResourceFetcher from '@joplin/lib/services/ResourceFetcher';
const { BaseScreenComponent } = require('../base-screen.js'); const { BaseScreenComponent } = require('../base-screen.js');
const { themeStyle, editorFont } = require('../global-style.js'); const { themeStyle, editorFont } = require('../global-style.js');
const { dialogs } = require('../../utils/dialogs.js'); const { dialogs } = require('../../utils/dialogs.js');

View File

@ -34,7 +34,7 @@ const AlarmServiceDriver = require('./services/AlarmServiceDriver');
const SafeAreaView = require('./components/SafeAreaView'); const SafeAreaView = require('./components/SafeAreaView');
const { connect, Provider } = require('react-redux'); const { connect, Provider } = require('react-redux');
const { BackButtonService } = require('./services/back-button.js'); const { BackButtonService } = require('./services/back-button.js');
import NavService from '@joplin/lib/services/NavService'; import NavService from '@joplin/lib/services/NavService';
const { createStore, applyMiddleware } = require('redux'); const { createStore, applyMiddleware } = require('redux');
const reduxSharedMiddleware = require('@joplin/lib/components/shared/reduxSharedMiddleware'); const reduxSharedMiddleware = require('@joplin/lib/components/shared/reduxSharedMiddleware');
const { shimInit } = require('./utils/shim-init-react.js'); const { shimInit } = require('./utils/shim-init-react.js');
@ -49,7 +49,7 @@ import NoteTag from '@joplin/lib/models/NoteTag';
import BaseItem from '@joplin/lib/models/BaseItem'; import BaseItem from '@joplin/lib/models/BaseItem';
import MasterKey from '@joplin/lib/models/MasterKey'; import MasterKey from '@joplin/lib/models/MasterKey';
import Revision from '@joplin/lib/models/Revision'; import Revision from '@joplin/lib/models/Revision';
import RevisionService from '@joplin/lib/services/RevisionService'; import RevisionService from '@joplin/lib/services/RevisionService';
const { JoplinDatabase } = require('@joplin/lib/joplin-database.js'); const { JoplinDatabase } = require('@joplin/lib/joplin-database.js');
const { Database } = require('@joplin/lib/database.js'); const { Database } = require('@joplin/lib/database.js');
const { NotesScreen } = require('./components/screens/notes.js'); const { NotesScreen } = require('./components/screens/notes.js');
@ -70,7 +70,7 @@ const { DatabaseDriverReactNative } = require('./utils/database-driver-react-nat
const { reg } = require('@joplin/lib/registry.js'); const { reg } = require('@joplin/lib/registry.js');
const { defaultState } = require('@joplin/lib/reducer'); const { defaultState } = require('@joplin/lib/reducer');
const { FileApiDriverLocal } = require('@joplin/lib/file-api-driver-local.js'); const { FileApiDriverLocal } = require('@joplin/lib/file-api-driver-local.js');
import ResourceFetcher from '@joplin/lib/services/ResourceFetcher'; import ResourceFetcher from '@joplin/lib/services/ResourceFetcher';
import SearchEngine from '@joplin/lib/services/searchengine/SearchEngine'; import SearchEngine from '@joplin/lib/services/searchengine/SearchEngine';
const WelcomeUtils = require('@joplin/lib/WelcomeUtils'); const WelcomeUtils = require('@joplin/lib/WelcomeUtils');
const { themeStyle } = require('./components/global-style.js'); const { themeStyle } = require('./components/global-style.js');
@ -91,9 +91,9 @@ SyncTargetRegistry.addClass(SyncTargetAmazonS3);
SyncTargetRegistry.addClass(SyncTargetJoplinServer); SyncTargetRegistry.addClass(SyncTargetJoplinServer);
const FsDriverRN = require('./utils/fs-driver-rn.js').FsDriverRN; const FsDriverRN = require('./utils/fs-driver-rn.js').FsDriverRN;
import DecryptionWorker from '@joplin/lib/services/DecryptionWorker'; import DecryptionWorker from '@joplin/lib/services/DecryptionWorker';
import EncryptionService from '@joplin/lib/services/EncryptionService'; import EncryptionService from '@joplin/lib/services/EncryptionService';
import MigrationService from '@joplin/lib/services/MigrationService'; import MigrationService from '@joplin/lib/services/MigrationService';
let storeDispatch = function(_action: any) {}; let storeDispatch = function(_action: any) {};

View File

@ -1,6 +1,6 @@
import { Notification } from '@joplin/lib/models/Alarm'; import { Notification } from '@joplin/lib/models/Alarm';
import Logger from '@joplin/lib/Logger'; import Logger from '@joplin/lib/Logger';
const PushNotificationIOS = require('@react-native-community/push-notification-ios').default; const PushNotificationIOS = require('@react-native-community/push-notification-ios').default;
export default class AlarmServiceDriver { export default class AlarmServiceDriver {

View File

@ -35,15 +35,15 @@ const SyncTargetNextcloud = require('./SyncTargetNextcloud.js');
const SyncTargetWebDAV = require('./SyncTargetWebDAV.js'); const SyncTargetWebDAV = require('./SyncTargetWebDAV.js');
const SyncTargetDropbox = require('./SyncTargetDropbox.js'); const SyncTargetDropbox = require('./SyncTargetDropbox.js');
const SyncTargetAmazonS3 = require('./SyncTargetAmazonS3.js'); const SyncTargetAmazonS3 = require('./SyncTargetAmazonS3.js');
import EncryptionService from './services/EncryptionService'; import EncryptionService from './services/EncryptionService';
import ResourceFetcher from './services/ResourceFetcher'; import ResourceFetcher from './services/ResourceFetcher';
import SearchEngineUtils from './services/searchengine/SearchEngineUtils'; import SearchEngineUtils from './services/searchengine/SearchEngineUtils';
import SearchEngine from './services/searchengine/SearchEngine'; import SearchEngine from './services/searchengine/SearchEngine';
import RevisionService from './services/RevisionService'; import RevisionService from './services/RevisionService';
import ResourceService from './services/ResourceService'; import ResourceService from './services/ResourceService';
import DecryptionWorker from './services/DecryptionWorker'; import DecryptionWorker from './services/DecryptionWorker';
const { loadKeychainServiceAndSettings } = require('./services/SettingUtils'); const { loadKeychainServiceAndSettings } = require('./services/SettingUtils');
import MigrationService from './services/MigrationService'; import MigrationService from './services/MigrationService';
const { toSystemSlashes } = require('./path-utils'); const { toSystemSlashes } = require('./path-utils');
const { setAutoFreeze } = require('immer'); const { setAutoFreeze } = require('immer');

View File

@ -49,22 +49,22 @@ class BaseModel {
['TYPE_COMMAND', ModelType.Command], ['TYPE_COMMAND', ModelType.Command],
]; ];
public static TYPE_NOTE = ModelType.Note; public static TYPE_NOTE = ModelType.Note;
public static TYPE_FOLDER = ModelType.Folder; public static TYPE_FOLDER = ModelType.Folder;
public static TYPE_SETTING = ModelType.Setting; public static TYPE_SETTING = ModelType.Setting;
public static TYPE_RESOURCE = ModelType.Resource; public static TYPE_RESOURCE = ModelType.Resource;
public static TYPE_TAG = ModelType.Tag; public static TYPE_TAG = ModelType.Tag;
public static TYPE_NOTE_TAG = ModelType.NoteTag; public static TYPE_NOTE_TAG = ModelType.NoteTag;
public static TYPE_SEARCH = ModelType.Search; public static TYPE_SEARCH = ModelType.Search;
public static TYPE_ALARM = ModelType.Alarm; public static TYPE_ALARM = ModelType.Alarm;
public static TYPE_MASTER_KEY = ModelType.MasterKey; public static TYPE_MASTER_KEY = ModelType.MasterKey;
public static TYPE_ITEM_CHANGE = ModelType.ItemChange; public static TYPE_ITEM_CHANGE = ModelType.ItemChange;
public static TYPE_NOTE_RESOURCE = ModelType.NoteResource; public static TYPE_NOTE_RESOURCE = ModelType.NoteResource;
public static TYPE_RESOURCE_LOCAL_STATE = ModelType.ResourceLocalState; public static TYPE_RESOURCE_LOCAL_STATE = ModelType.ResourceLocalState;
public static TYPE_REVISION = ModelType.Revision; public static TYPE_REVISION = ModelType.Revision;
public static TYPE_MIGRATION = ModelType.Migration; public static TYPE_MIGRATION = ModelType.Migration;
public static TYPE_SMART_FILTER = ModelType.SmartFilter; public static TYPE_SMART_FILTER = ModelType.SmartFilter;
public static TYPE_COMMAND = ModelType.Command; public static TYPE_COMMAND = ModelType.Command;
public static dispatch: Function = function() {}; public static dispatch: Function = function() {};
private static saveMutexes_: any = {}; private static saveMutexes_: any = {};

View File

@ -1,5 +1,5 @@
import BaseModel from '../BaseModel'; import BaseModel from '../BaseModel';
import Note from './Note'; import Note from './Note';
export interface Notification { export interface Notification {
id: number; id: number;

View File

@ -7,7 +7,7 @@ import markdownUtils from '../markdownUtils';
import { _ } from '../locale'; import { _ } from '../locale';
const { Database } = require('../database.js'); const { Database } = require('../database.js');
import ItemChange from './ItemChange'; import ItemChange from './ItemChange';
const JoplinError = require('../JoplinError.js'); const JoplinError = require('../JoplinError.js');
const { sprintf } = require('sprintf-js'); const { sprintf } = require('sprintf-js');
const moment = require('moment'); const moment = require('moment');

View File

@ -3,9 +3,9 @@ import BaseModel from '../BaseModel';
import time from '../time'; import time from '../time';
import { _ } from '../locale'; import { _ } from '../locale';
import Note from './Note'; import Note from './Note';
const { Database } = require('../database.js'); const { Database } = require('../database.js');
import BaseItem from './BaseItem'; import BaseItem from './BaseItem';
const { substrWithEllipsis } = require('../string-utils.js'); const { substrWithEllipsis } = require('../string-utils.js');
interface FolderEntityWithChildren extends FolderEntity { interface FolderEntityWithChildren extends FolderEntity {

View File

@ -8,7 +8,7 @@ import markdownUtils from '../markdownUtils';
import { NoteEntity } from '../services/database/types'; import { NoteEntity } from '../services/database/types';
const { sprintf } = require('sprintf-js'); const { sprintf } = require('sprintf-js');
import Resource from './Resource'; import Resource from './Resource';
const { pregQuote } = require('../string-utils.js'); const { pregQuote } = require('../string-utils.js');
const { _ } = require('../locale'); const { _ } = require('../locale');
const ArrayUtils = require('../ArrayUtils.js'); const ArrayUtils = require('../ArrayUtils.js');

View File

@ -6,7 +6,7 @@ import Setting from './Setting';
import markdownUtils from '../markdownUtils'; import markdownUtils from '../markdownUtils';
import { _ } from '../locale'; import { _ } from '../locale';
import { ResourceEntity, ResourceLocalStateEntity } from '../services/database/types'; import { ResourceEntity, ResourceLocalStateEntity } from '../services/database/types';
import ResourceLocalState from './ResourceLocalState'; import ResourceLocalState from './ResourceLocalState';
const pathUtils = require('../path-utils'); const pathUtils = require('../path-utils');
const { mime } = require('../mime-utils.js'); const { mime } = require('../mime-utils.js');
const { filename, safeFilename } = require('../path-utils'); const { filename, safeFilename } = require('../path-utils');

View File

@ -277,7 +277,7 @@ export default class OneDriveApi {
if (path.includes('/createUploadSession')) { if (path.includes('/createUploadSession')) {
response = await this.uploadBigFile(url, options); response = await this.uploadBigFile(url, options);
} else if (options.source == 'file' && (method == 'POST' || method == 'PUT')) { } else if (options.source == 'file' && (method == 'POST' || method == 'PUT')) {
response = await shim.uploadBlob(url, options); response = await shim.uploadBlob(url, options);
} else if (options.target == 'string') { } else if (options.target == 'string') {
response = await shim.fetch(url, options); response = await shim.fetch(url, options);
} else { } else {

View File

@ -350,7 +350,7 @@ function handleItemDelete(draft: Draft<State>, action: any) {
if (newItems.length == 0) { if (newItems.length == 0) {
newSelectedIndexes = []; // no remaining items so no selection newSelectedIndexes = []; // no remaining items so no selection
} else if (newSelectedIndexes.length == 0) { } else if (newSelectedIndexes.length == 0) {
newSelectedIndexes.push(0); // no selection exists so select the top newSelectedIndexes.push(0); // no selection exists so select the top
} else { } else {
@ -580,7 +580,7 @@ function handleHistory(draft: Draft<State>, action: any) {
break; break;
} }
case 'NOTE_SELECT': case 'NOTE_SELECT':
if (currentNote != null && action.id != currentNote.id) { if (currentNote != null && action.id != currentNote.id) {
draft.forwardHistoryNotes = []; draft.forwardHistoryNotes = [];
draft.backwardHistoryNotes = draft.backwardHistoryNotes.concat(currentNote).slice(-MAX_HISTORY); draft.backwardHistoryNotes = draft.backwardHistoryNotes.concat(currentNote).slice(-MAX_HISTORY);
} }

View File

@ -155,7 +155,7 @@ export default class AlarmServiceDriverNode {
// https://stackoverflow.com/questions/3468607/why-does-settimeout-break-for-large-millisecond-delay-values/3468699 // https://stackoverflow.com/questions/3468607/why-does-settimeout-break-for-large-millisecond-delay-values/3468699
const maxInterval = 60 * 60 * 1000; const maxInterval = 60 * 60 * 1000;
if (interval >= maxInterval) { if (interval >= maxInterval) {
this.logger().info(`AlarmServiceDriverNode::scheduleNotification: Notification interval is greater than ${maxInterval}ms - will reschedule in ${maxInterval}ms`); this.logger().info(`AlarmServiceDriverNode::scheduleNotification: Notification interval is greater than ${maxInterval}ms - will reschedule in ${maxInterval}ms`);
timeoutId = shim.setTimeout(() => { timeoutId = shim.setTimeout(() => {

View File

@ -1,3 +1,5 @@
/* eslint-disable no-multi-spaces */
// This is the keycode map for Electron. // This is the keycode map for Electron.
const keycodeToElectronMap = [ const keycodeToElectronMap = [

View File

@ -69,7 +69,7 @@ export default class InteropService_Importer_Md extends InteropService_Importer_
await Promise.all(imageLinks.map(async (encodedLink: string) => { await Promise.all(imageLinks.map(async (encodedLink: string) => {
const link = decodeURI(encodedLink); const link = decodeURI(encodedLink);
const attachmentPath = filename(`${dirname(filePath)}/${link}`, true); const attachmentPath = filename(`${dirname(filePath)}/${link}`, true);
const pathWithExtension = `${attachmentPath}.${fileExtension(link)}`; const pathWithExtension = `${attachmentPath}.${fileExtension(link)}`;
const stat = await shim.fsDriver().stat(pathWithExtension); const stat = await shim.fsDriver().stat(pathWithExtension);
const isDir = stat ? stat.isDirectory() : false; const isDir = stat ? stat.isDirectory() : false;
if (stat && !isDir) { if (stat && !isDir) {

View File

@ -2,7 +2,7 @@ import Plugin from './Plugin';
import manifestFromObject from './utils/manifestFromObject'; import manifestFromObject from './utils/manifestFromObject';
import Global from './api/Global'; import Global from './api/Global';
import BasePluginRunner from './BasePluginRunner'; import BasePluginRunner from './BasePluginRunner';
import BaseService from '../BaseService'; import BaseService from '../BaseService';
import shim from '../../shim'; import shim from '../../shim';
import { filename, dirname, rtrimSlashes } from '../../path-utils'; import { filename, dirname, rtrimSlashes } from '../../path-utils';
import Setting from '../../models/Setting'; import Setting from '../../models/Setting';

View File

@ -139,7 +139,7 @@ const trimQuotes = (str: string): string => str.startsWith('"') ? str.substr(1,
export default function filterParser(searchString: string) { export default function filterParser(searchString: string) {
searchString = searchString.trim(); searchString = searchString.trim();
const result = parseQuery(searchString); const result = parseQuery(searchString);
return result; return result;
} }

View File

@ -29,7 +29,7 @@ const notebookFilter = (terms: Term[], conditions: string[], params: string[], w
for (let i = 0; i < notebooks.length; i++) { for (let i = 0; i < notebooks.length; i++) {
likes.push('folders.title LIKE ?'); likes.push('folders.title LIKE ?');
} }
const relevantFolders = likes.join(' OR '); const relevantFolders = likes.join(' OR ');
const withInNotebook = ` const withInNotebook = `
notebooks_in_scope(id) notebooks_in_scope(id)

View File

@ -245,7 +245,7 @@ function shimInit(sharp = null, keytar = null, React = null) {
const fileStat = await shim.fsDriver().stat(targetPath); const fileStat = await shim.fsDriver().stat(targetPath);
resource.size = fileStat.size; resource.size = fileStat.size;
const saveOptions = { isNew: true }; const saveOptions = { isNew: true };
if (options.userSideValidation) saveOptions.userSideValidation = true; if (options.userSideValidation) saveOptions.userSideValidation = true;
return Resource.save(resource, saveOptions); return Resource.save(resource, saveOptions);
}; };

View File

@ -37,7 +37,7 @@ function plugin(markdownIt: any) {
// May be, one day we will add .clone() for token and simplify this part, but // May be, one day we will add .clone() for token and simplify this part, but
// now we prefer to keep things local. // now we prefer to keep things local.
if (info) { if (info) {
i = token.attrIndex('class'); i = token.attrIndex('class');
tmpAttrs = token.attrs ? token.attrs.slice() : []; tmpAttrs = token.attrs ? token.attrs.slice() : [];
if (i < 0) { if (i < 0) {
@ -51,13 +51,13 @@ function plugin(markdownIt: any) {
attrs: tmpAttrs, attrs: tmpAttrs,
}; };
return `<pre><code${slf.renderAttrs(tmpToken)}>${ return `<pre><code${slf.renderAttrs(tmpToken)}>${
highlighted highlighted
}</code></pre>\n`; }</code></pre>\n`;
} }
return `<pre><code${slf.renderAttrs(token)}>${ return `<pre><code${slf.renderAttrs(token)}>${
highlighted highlighted
}</code></pre>\n`; }</code></pre>\n`;
}; };

View File

@ -10,7 +10,7 @@ const router = new Router();
router.public = true; router.public = true;
router.post('api/sessions', async (_path: SubPath, ctx: AppContext) => { router.post('api/sessions', async (_path: SubPath, ctx: AppContext) => {
const fields: User = await bodyFields(ctx.req); const fields: User = await bodyFields(ctx.req);
const user = await ctx.models.user().login(fields.email, fields.password); const user = await ctx.models.user().login(fields.email, fields.password);
if (!user) throw new ErrorForbidden('Invalid username or password'); if (!user) throw new ErrorForbidden('Invalid username or password');