You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-27 23:28:38 +02:00
Tools: Add prefer-arrow-callbacks to ESlint rules (#7810)
This commit is contained in:
@ -143,6 +143,7 @@ module.exports = {
|
||||
// - notebook: In code, it should always be "folder" (not "notebook").
|
||||
// In user-facing text, it should be "notebook".
|
||||
'id-denylist': ['error', 'err', 'notebook', 'notebooks'],
|
||||
'prefer-arrow-callback': ['error'],
|
||||
},
|
||||
'plugins': [
|
||||
'react',
|
||||
|
@ -125,14 +125,14 @@ async function handleAutocompletionPromise(line) {
|
||||
}
|
||||
function handleAutocompletion(str, callback) {
|
||||
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
|
||||
handleAutocompletionPromise(str).then(function(res) {
|
||||
handleAutocompletionPromise(str).then((res) => {
|
||||
callback(undefined, res);
|
||||
});
|
||||
}
|
||||
function toCommandLine(args) {
|
||||
if (Array.isArray(args)) {
|
||||
return args
|
||||
.map(function(a) {
|
||||
.map((a) => {
|
||||
if (a.indexOf('"') !== -1 || a.indexOf(' ') !== -1) {
|
||||
return `'${a}'`;
|
||||
} else if (a.indexOf('\'') !== -1) {
|
||||
|
@ -75,12 +75,12 @@ if (process.platform === 'win32') {
|
||||
output: process.stdout,
|
||||
});
|
||||
|
||||
rl.on('SIGINT', function() {
|
||||
rl.on('SIGINT', () => {
|
||||
process.emit('SIGINT');
|
||||
});
|
||||
}
|
||||
|
||||
process.stdout.on('error', function(error) {
|
||||
process.stdout.on('error', (error) => {
|
||||
// https://stackoverflow.com/questions/12329816/error-write-epipe-when-piping-node-output-to-head#15884508
|
||||
if (error.code === 'EPIPE') {
|
||||
process.exit(0);
|
||||
|
@ -12,7 +12,7 @@ const shim = require('@joplin/lib/shim').default;
|
||||
const HtmlToHtml = require('@joplin/renderer/HtmlToHtml').default;
|
||||
const { enexXmlToMd } = require('@joplin/lib/import-enex-md-gen.js');
|
||||
|
||||
describe('HtmlToHtml', function() {
|
||||
describe('HtmlToHtml', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -3,7 +3,7 @@ const os = require('os');
|
||||
const { filename } = require('@joplin/lib/path-utils');
|
||||
import HtmlToMd from '@joplin/lib/HtmlToMd';
|
||||
|
||||
describe('HtmlToMd', function() {
|
||||
describe('HtmlToMd', () => {
|
||||
|
||||
it('should convert from Html to Markdown', (async () => {
|
||||
const basePath = `${__dirname}/html_to_md`;
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
const MarkupToHtml = require('@joplin/renderer/MarkupToHtml').default;
|
||||
|
||||
describe('MarkupToHtml', function() {
|
||||
describe('MarkupToHtml', () => {
|
||||
|
||||
it('should strip markup', (async () => {
|
||||
const service = new MarkupToHtml();
|
||||
|
@ -16,7 +16,7 @@ function newTestMdToHtml(options: any = null) {
|
||||
return new MdToHtml(options);
|
||||
}
|
||||
|
||||
describe('MdToHtml', function() {
|
||||
describe('MdToHtml', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -22,7 +22,7 @@ const goToNote = (testApp, note) => {
|
||||
testApp.dispatch({ type: 'NOTE_SELECT', id: note.id });
|
||||
};
|
||||
|
||||
describe('feature_NoteHistory', function() {
|
||||
describe('feature_NoteHistory', () => {
|
||||
beforeEach(async () => {
|
||||
testApp = new TestApp();
|
||||
await testApp.start(['--no-welcome']);
|
||||
|
@ -8,7 +8,7 @@ const time = require('@joplin/lib/time').default;
|
||||
|
||||
let testApp = null;
|
||||
|
||||
describe('integration_NoteList', function() {
|
||||
describe('integration_NoteList', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
testApp = new TestApp();
|
||||
|
@ -22,7 +22,7 @@ const { ALL_NOTES_FILTER_ID } = require('@joplin/lib/reserved-ids.js');
|
||||
|
||||
let testApp = null;
|
||||
|
||||
describe('integration_ShowAllNotes', function() {
|
||||
describe('integration_ShowAllNotes', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
testApp = new TestApp();
|
||||
|
@ -8,7 +8,7 @@ const time = require('@joplin/lib/time').default;
|
||||
|
||||
let testApp = null;
|
||||
|
||||
describe('integration_TagList', function() {
|
||||
describe('integration_TagList', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
testApp = new TestApp();
|
||||
|
@ -11,7 +11,7 @@ function describeIfCompatible(name: string, fn: any, elseFn: any) {
|
||||
}
|
||||
}
|
||||
|
||||
describeIfCompatible('services_KeychainService', function() {
|
||||
describeIfCompatible('services_KeychainService', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1, { keychainEnabled: true });
|
||||
|
@ -29,7 +29,7 @@ function newPluginService(appVersion: string = '1.4') {
|
||||
return service;
|
||||
}
|
||||
|
||||
describe('services_PluginService', function() {
|
||||
describe('services_PluginService', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -8,7 +8,7 @@ async function newRepoApi(): Promise<RepositoryApi> {
|
||||
return repo;
|
||||
}
|
||||
|
||||
describe('services_plugins_RepositoryApi', function() {
|
||||
describe('services_plugins_RepositoryApi', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -24,7 +24,7 @@ function newPluginService(appVersion: string = '1.4') {
|
||||
return service;
|
||||
}
|
||||
|
||||
describe('defaultPluginsUtils', function() {
|
||||
describe('defaultPluginsUtils', () => {
|
||||
|
||||
const pluginsId = ['joplin.plugin.ambrt.backlinksToNote', 'org.joplinapp.plugins.ToggleSidebars'];
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
const sandboxProxy = require('@joplin/lib/services/plugins/sandboxProxy');
|
||||
import { setupDatabaseAndSynchronizer, switchClient } from '@joplin/lib/testing/test-utils';
|
||||
|
||||
describe('services_plugins_sandboxProxy', function() {
|
||||
describe('services_plugins_sandboxProxy', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -50,7 +50,7 @@ async function browserGetZoom(tabId) {
|
||||
});
|
||||
}
|
||||
|
||||
browser_.runtime.onInstalled.addListener(function() {
|
||||
browser_.runtime.onInstalled.addListener(() => {
|
||||
if (window.joplinEnv() === 'dev') {
|
||||
browser_.browserAction.setIcon({
|
||||
path: 'icons/32-dev.png',
|
||||
@ -165,7 +165,7 @@ async function sendClipMessage(clipType) {
|
||||
}
|
||||
}
|
||||
|
||||
browser_.commands.onCommand.addListener(function(command) {
|
||||
browser_.commands.onCommand.addListener((command) => {
|
||||
// We could enumerate these twice, but since we're in here first,
|
||||
// why not save ourselves the trouble with this convention
|
||||
if (command.startsWith('clip')) {
|
||||
|
@ -130,8 +130,8 @@ checkBrowsers(paths.appPath, isInteractive)
|
||||
openBrowser(urls.localUrlForBrowser);
|
||||
});
|
||||
|
||||
['SIGINT', 'SIGTERM'].forEach(function(sig) {
|
||||
process.on(sig, function() {
|
||||
['SIGINT', 'SIGTERM'].forEach((sig) => {
|
||||
process.on(sig, () => {
|
||||
devServer.close();
|
||||
process.exit();
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { AppState } from './app.reducer';
|
||||
import appReducer, { createAppDefaultState } from './app.reducer';
|
||||
|
||||
describe('app.reducer', function() {
|
||||
describe('app.reducer', () => {
|
||||
|
||||
it('DIALOG_OPEN', async () => {
|
||||
const state: AppState = createAppDefaultState({}, {});
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Helper commands added to the the CodeMirror instance
|
||||
export default function useJoplinCommands(CodeMirror: any) {
|
||||
|
||||
CodeMirror.defineExtension('commandExists', function(name: string) {
|
||||
CodeMirror.defineExtension('commandExists', (name: string) => {
|
||||
return !!CodeMirror.commands[name];
|
||||
});
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ export default function useKeymap(CodeMirror: any) {
|
||||
}
|
||||
|
||||
|
||||
CodeMirror.defineExtension('supportsCommand', function(cmd: EditorCommand) {
|
||||
CodeMirror.defineExtension('supportsCommand', (cmd: EditorCommand) => {
|
||||
return isEditorCommand(cmd.name) && editorCommandToCodeMirror(cmd.name) in CodeMirror.commands;
|
||||
});
|
||||
|
||||
|
@ -674,7 +674,7 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
|
||||
props_onDrop.current(event);
|
||||
});
|
||||
|
||||
editor.on('ObjectResized', function(event: any) {
|
||||
editor.on('ObjectResized', (event: any) => {
|
||||
if (event.target.nodeName === 'IMG') {
|
||||
editor.fire(TinyMceEditorEvents.JoplinChange);
|
||||
dispatchDidUpdate(editor);
|
||||
|
@ -51,7 +51,7 @@ export default function(editor: any) {
|
||||
editor.execCommand('mceToggleFormat', false, def.name);
|
||||
},
|
||||
onSetup: function(api: any) {
|
||||
editor.formatter.formatChanged(def.name, function(state: boolean) {
|
||||
editor.formatter.formatChanged(def.name, (state: boolean) => {
|
||||
api.setActive(state);
|
||||
});
|
||||
},
|
||||
|
@ -9,7 +9,7 @@ export default function(dependencies: HookDependencies) {
|
||||
const { folderId } = dependencies;
|
||||
const [folder, setFolder] = useState(null);
|
||||
|
||||
useEffect(function() {
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
|
||||
async function loadFolder() {
|
||||
|
@ -192,7 +192,7 @@ export default function useFormNote(dependencies: HookDependencies) {
|
||||
// eslint-disable-next-line @seiyab/react-hooks/exhaustive-deps -- Old code before rule was applied
|
||||
}, [noteId, isProvisional, formNote]);
|
||||
|
||||
const onResourceChange = useCallback(async function(event: any = null) {
|
||||
const onResourceChange = useCallback(async (event: any = null) => {
|
||||
const resourceIds = await Note.linkedResourceIds(formNote.body);
|
||||
if (!event || resourceIds.indexOf(event.id) >= 0) {
|
||||
clearResourceCache();
|
||||
|
@ -69,7 +69,7 @@ const SortOrderButtonsContainer = styled.div`
|
||||
function NoteListControls(props: Props) {
|
||||
const searchBarRef = useRef(null);
|
||||
|
||||
useEffect(function() {
|
||||
useEffect(() => {
|
||||
CommandService.instance().registerRuntime('focusSearch', focusSearchRuntime(searchBarRef));
|
||||
|
||||
return function() {
|
||||
|
@ -98,7 +98,7 @@ const GlobalStyle = createGlobalStyle`
|
||||
let wcsTimeoutId_: any = null;
|
||||
|
||||
async function initialize() {
|
||||
bridge().window().on('resize', function() {
|
||||
bridge().window().on('resize', () => {
|
||||
if (wcsTimeoutId_) shim.clearTimeout(wcsTimeoutId_);
|
||||
|
||||
wcsTimeoutId_ = shim.setTimeout(() => {
|
||||
|
@ -8,7 +8,7 @@ import Setting from '@joplin/lib/models/Setting';
|
||||
import restart from '../services/restart';
|
||||
|
||||
function useAppCloseHandler(upgradeResult: SyncTargetUpgradeResult) {
|
||||
useEffect(function() {
|
||||
useEffect(() => {
|
||||
async function onAppClose() {
|
||||
let canClose = true;
|
||||
|
||||
@ -38,7 +38,7 @@ function useAppCloseHandler(upgradeResult: SyncTargetUpgradeResult) {
|
||||
}
|
||||
|
||||
function useStyle() {
|
||||
useEffect(function() {
|
||||
useEffect(() => {
|
||||
const element = document.createElement('style');
|
||||
element.appendChild(document.createTextNode(`
|
||||
body {
|
||||
@ -62,7 +62,7 @@ function useStyle() {
|
||||
}
|
||||
|
||||
function useRestartOnDone(upgradeResult: SyncTargetUpgradeResult) {
|
||||
useEffect(function() {
|
||||
useEffect(() => {
|
||||
if (upgradeResult.done && !upgradeResult.error) {
|
||||
void restart();
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ webviewLib.initialize = function(options) {
|
||||
webviewLib.options_ = options;
|
||||
};
|
||||
|
||||
document.addEventListener('click', function(event) {
|
||||
document.addEventListener('click', (event) => {
|
||||
const anchor = webviewLib.getParentAnchorElement(event.target);
|
||||
if (!anchor) return;
|
||||
|
||||
|
@ -8,7 +8,7 @@ const outputDir = `${rootDir}/pluginAssets`;
|
||||
const walk = function(dir) {
|
||||
let results = [];
|
||||
const list = fs.readdirSync(dir);
|
||||
list.forEach(function(file) {
|
||||
list.forEach((file) => {
|
||||
file = `${dir}/${file}`;
|
||||
const stat = fs.statSync(file);
|
||||
if (stat && stat.isDirectory()) {
|
||||
|
@ -215,8 +215,8 @@ function shimInit() {
|
||||
};
|
||||
|
||||
shim.waitForFrame = () => {
|
||||
return new Promise(function(resolve) {
|
||||
requestAnimationFrame(function() {
|
||||
return new Promise((resolve) => {
|
||||
requestAnimationFrame(() => {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
@ -43,7 +43,7 @@ function mergePackageKey(parentKey, source, dest) {
|
||||
function mergeIgnoreFile(source, dest) {
|
||||
const output = dest.trim().split(/\r?\n/).concat(source.trim().split(/\r?\n/));
|
||||
|
||||
return `${output.filter(function(item, pos) {
|
||||
return `${output.filter((item, pos) => {
|
||||
if (!item) return true; // Leave blank lines
|
||||
return output.indexOf(item) === pos;
|
||||
}).join('\n').trim()}\n`;
|
||||
|
@ -1,6 +1,6 @@
|
||||
const ArrayUtils = require('./ArrayUtils');
|
||||
|
||||
describe('ArrayUtils', function() {
|
||||
describe('ArrayUtils', () => {
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
export const unique = function(array: any[]) {
|
||||
return array.filter(function(elem, index, self) {
|
||||
return array.filter((elem, index, self) => {
|
||||
return index === self.indexOf(elem);
|
||||
});
|
||||
};
|
||||
|
@ -198,7 +198,7 @@ export default class ClipperServer {
|
||||
if (contentType.indexOf('multipart/form-data') === 0) {
|
||||
const form = new multiparty.Form();
|
||||
|
||||
form.parse(request, function(error: any, fields: any, files: any) {
|
||||
form.parse(request, (error: any, fields: any, files: any) => {
|
||||
if (error) {
|
||||
writeResponse(error.httpCode ? error.httpCode : 500, error.message);
|
||||
return;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import InMemoryCache from './InMemoryCache';
|
||||
import time from './time';
|
||||
|
||||
describe('InMemoryCache', function() {
|
||||
describe('InMemoryCache', () => {
|
||||
|
||||
it('should get and set values', () => {
|
||||
const cache = new InMemoryCache();
|
||||
|
@ -8,7 +8,7 @@ export function sortByValue(object: any) {
|
||||
});
|
||||
}
|
||||
|
||||
temp.sort(function(a, b) {
|
||||
temp.sort((a, b) => {
|
||||
let v1 = a.value;
|
||||
let v2 = b.value;
|
||||
if (typeof v1 === 'string') v1 = v1.toLowerCase();
|
||||
|
@ -3,7 +3,7 @@
|
||||
const { splitCommandBatch } = require('./string-utils');
|
||||
const StringUtils = require('./string-utils');
|
||||
|
||||
describe('StringUtils', function() {
|
||||
describe('StringUtils', () => {
|
||||
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
const { setupDatabaseAndSynchronizer, sleep, switchClient } = require('./testing/test-utils.js');
|
||||
const TaskQueue = require('./TaskQueue').default;
|
||||
|
||||
describe('TaskQueue', function() {
|
||||
describe('TaskQueue', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -10,7 +10,7 @@ export function shuffle<T>(array: T[]): T[] {
|
||||
}
|
||||
|
||||
export function unique<T>(array: T[]): T[] {
|
||||
return array.filter(function(elem, index, self) {
|
||||
return array.filter((elem, index, self) => {
|
||||
return index === self.indexOf(elem);
|
||||
});
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import * as callbackUrlUtils from './callbackUrlUtils';
|
||||
|
||||
describe('callbackUrlUtils', function() {
|
||||
describe('callbackUrlUtils', () => {
|
||||
|
||||
it('should identify valid callback urls', () => {
|
||||
const url = 'joplin://x-callback-url/123?a=b';
|
||||
|
@ -1,7 +1,7 @@
|
||||
const { setupDatabaseAndSynchronizer, switchClient } = require('./testing/test-utils.js');
|
||||
const BaseModel = require('./BaseModel').default;
|
||||
|
||||
describe('database', function() {
|
||||
describe('database', () => {
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
await switchClient(1);
|
||||
|
@ -4,7 +4,7 @@
|
||||
const { checkThrow } = require('./testing/test-utils.js');
|
||||
const eventManager = require('./eventManager').default;
|
||||
|
||||
describe('eventManager', function() {
|
||||
describe('eventManager', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
eventManager.reset();
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { afterAllCleanUp, setupDatabaseAndSynchronizer, switchClient, fileApi } from './testing/test-utils';
|
||||
|
||||
describe('file-api-driver', function() {
|
||||
describe('file-api-driver', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -422,7 +422,7 @@ async function basicDelta(path: string, getDirStatFn: Function, options: any) {
|
||||
// Stats are cached until all items have been processed (until hasMore is false)
|
||||
if (newContext.statsCache === null) {
|
||||
newContext.statsCache = await getDirStatFn(path);
|
||||
newContext.statsCache.sort(function(a: any, b: any) {
|
||||
newContext.statsCache.sort((a: any, b: any) => {
|
||||
return a.updated_time - b.updated_time;
|
||||
});
|
||||
newContext.statIdsCache = newContext.statsCache.filter((item: any) => BaseItem.isSystemPath(item.path)).map((item: any) => BaseItem.pathToId(item.path));
|
||||
|
@ -12,7 +12,7 @@ function platformPath(path: string) {
|
||||
}
|
||||
}
|
||||
|
||||
describe('fsDriver', function() {
|
||||
describe('fsDriver', () => {
|
||||
|
||||
it('should resolveRelativePathWithinDir', async () => {
|
||||
const fsDriver = new FsDriverNode();
|
||||
|
@ -1,6 +1,6 @@
|
||||
import htmlUtils from './htmlUtils';
|
||||
|
||||
describe('htmlUtils', function() {
|
||||
describe('htmlUtils', () => {
|
||||
|
||||
|
||||
|
||||
|
@ -69,12 +69,12 @@ function enexXmlToHtml_(stream, resources) {
|
||||
parent: null,
|
||||
};
|
||||
|
||||
saxStream.on('error', function(e) {
|
||||
saxStream.on('error', (e) => {
|
||||
console.warn(e);
|
||||
});
|
||||
|
||||
|
||||
saxStream.on('text', function(text) {
|
||||
saxStream.on('text', (text) => {
|
||||
section.lines.push(htmlentities(text));
|
||||
});
|
||||
|
||||
@ -135,14 +135,14 @@ function enexXmlToHtml_(stream, resources) {
|
||||
}
|
||||
});
|
||||
|
||||
saxStream.on('closetag', function(node) {
|
||||
saxStream.on('closetag', (node) => {
|
||||
const tagName = node ? node.toLowerCase() : node;
|
||||
if (!htmlUtils.isSelfClosingTag(tagName)) section.lines.push(`</${tagName}>`);
|
||||
});
|
||||
|
||||
saxStream.on('attribute', function() {});
|
||||
saxStream.on('attribute', () => {});
|
||||
|
||||
saxStream.on('end', function() {
|
||||
saxStream.on('end', () => {
|
||||
resolve({
|
||||
content: section,
|
||||
resources: remainingResources,
|
||||
|
@ -58,7 +58,7 @@ const compareOutputToExpected = (options) => {
|
||||
}));
|
||||
};
|
||||
|
||||
describe('EnexToHtml', function() {
|
||||
describe('EnexToHtml', () => {
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
await switchClient(1);
|
||||
|
@ -13,7 +13,7 @@ import Resource from './models/Resource';
|
||||
|
||||
const enexSampleBaseDir = `${supportDir}/../enex_to_md`;
|
||||
|
||||
describe('import-enex-md-gen', function() {
|
||||
describe('import-enex-md-gen', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -587,7 +587,7 @@ function enexXmlToMdArray(stream: any, resources: ResourceEntity[]): Promise<Ene
|
||||
parent: null,
|
||||
};
|
||||
|
||||
saxStream.on('error', function(e: any) {
|
||||
saxStream.on('error', (e: any) => {
|
||||
console.warn(e);
|
||||
});
|
||||
|
||||
@ -615,7 +615,7 @@ function enexXmlToMdArray(stream: any, resources: ResourceEntity[]): Promise<Ene
|
||||
return output;
|
||||
};
|
||||
|
||||
saxStream.on('text', function(text: string) {
|
||||
saxStream.on('text', (text: string) => {
|
||||
if (['table', 'tr', 'tbody'].indexOf(section.type) >= 0) return;
|
||||
|
||||
text = !state.inPre ? unwrapInnerText(text) : text;
|
||||
@ -923,7 +923,7 @@ function enexXmlToMdArray(stream: any, resources: ResourceEntity[]): Promise<Ene
|
||||
}
|
||||
});
|
||||
|
||||
saxStream.on('closetag', function(n: string) {
|
||||
saxStream.on('closetag', (n: string) => {
|
||||
n = n ? n.toLowerCase() : n;
|
||||
|
||||
const poppedTag = state.tags.pop();
|
||||
@ -1121,9 +1121,9 @@ function enexXmlToMdArray(stream: any, resources: ResourceEntity[]): Promise<Ene
|
||||
}
|
||||
});
|
||||
|
||||
saxStream.on('attribute', function() {});
|
||||
saxStream.on('attribute', () => {});
|
||||
|
||||
saxStream.on('end', function() {
|
||||
saxStream.on('end', () => {
|
||||
resolve({
|
||||
content: section,
|
||||
resources: remainingResources,
|
||||
|
@ -53,7 +53,7 @@ async function decodeBase64File(sourceFilePath: string, destFilePath: string) {
|
||||
// would be ignored. I don't think it's happening anymore, but something to keep in mind
|
||||
// anyway.
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// Note: we manually handle closing the file so that we can
|
||||
// force flusing it before close. This is needed because
|
||||
// "end" might be called before the file has been flushed
|
||||
@ -528,7 +528,7 @@ export default async function importEnex(parentFolderId: string, filePath: strin
|
||||
}
|
||||
}));
|
||||
|
||||
saxStream.on('opentag', handleSaxStreamEvent(function(node: Node) {
|
||||
saxStream.on('opentag', handleSaxStreamEvent((node: Node) => {
|
||||
const n = node.name.toLowerCase();
|
||||
nodes.push(node);
|
||||
|
||||
@ -551,7 +551,7 @@ export default async function importEnex(parentFolderId: string, filePath: strin
|
||||
}
|
||||
}));
|
||||
|
||||
saxStream.on('cdata', handleSaxStreamEvent(function(data: any) {
|
||||
saxStream.on('cdata', handleSaxStreamEvent((data: any) => {
|
||||
const n = currentNodeName();
|
||||
|
||||
if (noteResourceRecognition) {
|
||||
@ -633,7 +633,7 @@ export default async function importEnex(parentFolderId: string, filePath: strin
|
||||
}
|
||||
}));
|
||||
|
||||
saxStream.on('end', handleSaxStreamEvent(function() {
|
||||
saxStream.on('end', handleSaxStreamEvent(() => {
|
||||
// Wait till there is no more notes to process.
|
||||
const iid = shim.setInterval(() => {
|
||||
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
import markdownUtils from './markdownUtils';
|
||||
|
||||
describe('markdownUtils', function() {
|
||||
describe('markdownUtils', () => {
|
||||
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
const mimeUtils = require('./mime-utils.js').mime;
|
||||
|
||||
describe('mimeUils', function() {
|
||||
describe('mimeUils', () => {
|
||||
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@ const { setupDatabaseAndSynchronizer, switchClient } = require('../testing/test-
|
||||
const Folder = require('../models/Folder').default;
|
||||
const Note = require('../models/Note').default;
|
||||
|
||||
describe('models/BaseItem', function() {
|
||||
describe('models/BaseItem', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -9,7 +9,7 @@ import ResourceService from '../services/ResourceService';
|
||||
|
||||
const testImagePath = `${supportDir}/photo.jpg`;
|
||||
|
||||
describe('models/Folder.sharing', function() {
|
||||
describe('models/Folder.sharing', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -9,7 +9,7 @@ async function allItems() {
|
||||
return folders.concat(notes);
|
||||
}
|
||||
|
||||
describe('models/Folder', function() {
|
||||
describe('models/Folder', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -7,7 +7,7 @@ import ItemChange from '../models/ItemChange';
|
||||
|
||||
let searchEngine: SearchEngine = null;
|
||||
|
||||
describe('models/ItemChange', function() {
|
||||
describe('models/ItemChange', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { encryptionService, msleep, setupDatabaseAndSynchronizer, switchClient } from '../testing/test-utils';
|
||||
import MasterKey from './MasterKey';
|
||||
|
||||
describe('models/MasterKey', function() {
|
||||
describe('models/MasterKey', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -18,7 +18,7 @@ async function allItems() {
|
||||
return folders.concat(notes);
|
||||
}
|
||||
|
||||
describe('models/Note', function() {
|
||||
describe('models/Note', () => {
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
await switchClient(1);
|
||||
@ -411,7 +411,7 @@ describe('models/Note', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('models/Note_replacePaths', function() {
|
||||
describe('models/Note_replacePaths', () => {
|
||||
|
||||
function testResourceReplacment(body: string, pathsToTry: string[], expected: string) {
|
||||
expect(Note['replaceResourceExternalToInternalLinks_'](pathsToTry, body)).toBe(expected);
|
||||
|
@ -3,7 +3,7 @@ const { setupDatabaseAndSynchronizer, switchClient } = require('../testing/test-
|
||||
const Folder = require('../models/Folder').default;
|
||||
const Note = require('../models/Note').default;
|
||||
|
||||
describe('models/Note_CustomSortOrder', function() {
|
||||
describe('models/Note_CustomSortOrder', () => {
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
await switchClient(1);
|
||||
|
@ -6,7 +6,7 @@ import shim from '../shim';
|
||||
|
||||
const testImagePath = `${supportDir}/photo.jpg`;
|
||||
|
||||
describe('models/Resource', function() {
|
||||
describe('models/Resource', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -2,7 +2,7 @@ import { expectNotThrow, naughtyStrings, setupDatabaseAndSynchronizer, switchCli
|
||||
import Note from '../models/Note';
|
||||
import Revision, { ObjectPatch } from '../models/Revision';
|
||||
|
||||
describe('models/Revision', function() {
|
||||
describe('models/Revision', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -24,7 +24,7 @@ const switchToSubProfileSettings = async () => {
|
||||
await Setting.load();
|
||||
};
|
||||
|
||||
describe('models/Setting', function() {
|
||||
describe('models/Setting', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -3,7 +3,7 @@ const Folder = require('../models/Folder').default;
|
||||
const Note = require('../models/Note').default;
|
||||
const Tag = require('../models/Tag').default;
|
||||
|
||||
describe('models/Tag', function() {
|
||||
describe('models/Tag', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -1,7 +1,7 @@
|
||||
import Setting from '../models/Setting';
|
||||
import time from '../time';
|
||||
|
||||
describe('dateFormats', function() {
|
||||
describe('dateFormats', () => {
|
||||
|
||||
|
||||
|
||||
|
@ -13,8 +13,8 @@ function ntpClient() {
|
||||
}
|
||||
|
||||
export async function getNetworkTime(): Promise<Date> {
|
||||
return new Promise(function(resolve: Function, reject: Function) {
|
||||
ntpClient().getNetworkTime(server.domain, server.port, function(error: any, date: Date) {
|
||||
return new Promise((resolve: Function, reject: Function) => {
|
||||
ntpClient().getNetworkTime(server.domain, server.port, (error: any, date: Date) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
|
@ -14,7 +14,7 @@ function parseUri(str) {
|
||||
while (i--) uri[o.key[i]] = m[i] || '';
|
||||
|
||||
uri[o.q.name] = {};
|
||||
uri[o.key[12]].replace(o.q.parser, function($0, $1, $2) {
|
||||
uri[o.key[12]].replace(o.q.parser, ($0, $1, $2) => {
|
||||
if ($1) uri[o.q.name][$1] = $2;
|
||||
});
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
const { extractExecutablePath, quotePath, unquotePath, friendlySafeFilename, toFileProtocolPath } = require('./path-utils');
|
||||
|
||||
describe('pathUtils', function() {
|
||||
describe('pathUtils', () => {
|
||||
|
||||
|
||||
|
||||
|
@ -81,7 +81,7 @@ function getIds(items, indexes = null) {
|
||||
return ids;
|
||||
}
|
||||
|
||||
describe('reducer', function() {
|
||||
describe('reducer', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -5,7 +5,7 @@ const sync = {
|
||||
start: jest.fn().mockReturnValue({}),
|
||||
};
|
||||
|
||||
describe('Registry', function() {
|
||||
describe('Registry', () => {
|
||||
let originalSyncTarget: typeof reg.syncTarget;
|
||||
|
||||
beforeAll(() => {
|
||||
|
@ -90,7 +90,7 @@ webviewLib.initialize = function(options) {
|
||||
webviewLib.options_ = options;
|
||||
};
|
||||
|
||||
document.addEventListener('click', function(event) {
|
||||
document.addEventListener('click', (event) => {
|
||||
const anchor = webviewLib.getParentAnchorElement(event.target);
|
||||
if (!anchor) return;
|
||||
|
||||
|
@ -40,7 +40,7 @@ function registerCommand(service: CommandService, cmd: TestCommand) {
|
||||
service.registerRuntime(cmd.declaration.name, cmd.runtime);
|
||||
}
|
||||
|
||||
describe('services_CommandService', function() {
|
||||
describe('services_CommandService', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
KeymapService.destroyInstance();
|
||||
|
@ -7,7 +7,7 @@ function setupStore() {
|
||||
return store;
|
||||
}
|
||||
|
||||
describe('services_KvStore', function() {
|
||||
describe('services_KvStore', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -9,7 +9,7 @@ import Resource from '../models/Resource';
|
||||
import SearchEngine from '../services/searchengine/SearchEngine';
|
||||
import { loadMasterKeysFromSettings, setupAndEnableEncryption } from './e2ee/utils';
|
||||
|
||||
describe('services/ResourceService', function() {
|
||||
describe('services/ResourceService', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -8,7 +8,7 @@ import BaseModel, { ModelType } from '../BaseModel';
|
||||
import RevisionService from '../services/RevisionService';
|
||||
import { MarkupLanguage } from '../../renderer';
|
||||
|
||||
describe('services/RevisionService', function() {
|
||||
describe('services/RevisionService', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -1,8 +1,8 @@
|
||||
import WhenClause from './WhenClause';
|
||||
|
||||
describe('WhenClause', function() {
|
||||
describe('WhenClause', () => {
|
||||
|
||||
test('should work with simple condition', async function() {
|
||||
test('should work with simple condition', async () => {
|
||||
const wc = new WhenClause('test1 && test2');
|
||||
|
||||
expect(wc.evaluate({
|
||||
@ -16,7 +16,7 @@ describe('WhenClause', function() {
|
||||
})).toBe(false);
|
||||
});
|
||||
|
||||
test('should work with parenthesis', async function() {
|
||||
test('should work with parenthesis', async () => {
|
||||
const wc = new WhenClause('(test1 && test2) || test3 && (test4 && !test5)');
|
||||
|
||||
expect(wc.evaluate({
|
||||
|
@ -9,7 +9,7 @@ import { setEncryptionEnabled } from '../synchronizer/syncInfoUtils';
|
||||
|
||||
let service: EncryptionService = null;
|
||||
|
||||
describe('services_EncryptionService', function() {
|
||||
describe('services_EncryptionService', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -2,7 +2,7 @@ import { afterAllCleanUp, encryptionService, expectNotThrow, expectThrow, setupD
|
||||
import { decryptPrivateKey, generateKeyPair, ppkDecryptMasterKeyContent, ppkGenerateMasterKey, ppkPasswordIsValid, mkReencryptFromPasswordToPublicKey, mkReencryptFromPublicKeyToPassword } from './ppk';
|
||||
import { runIntegrationTests } from './ppkTestUtils';
|
||||
|
||||
describe('e2ee/ppk', function() {
|
||||
describe('e2ee/ppk', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -5,7 +5,7 @@ import { localSyncInfo, masterKeyById, masterKeyEnabled, setActiveMasterKeyId, s
|
||||
import Setting from '../../models/Setting';
|
||||
import { generateKeyPair, ppkPasswordIsValid } from './ppk';
|
||||
|
||||
describe('e2ee/utils', function() {
|
||||
describe('e2ee/utils', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -80,7 +80,7 @@ function memoryExportModule() {
|
||||
return { result, module };
|
||||
}
|
||||
|
||||
describe('services_InteropService', function() {
|
||||
describe('services_InteropService', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -14,7 +14,7 @@ async function recreateExportDir() {
|
||||
await fs.mkdirp(dir);
|
||||
}
|
||||
|
||||
describe('interop/InteropService_Exporter_Html', function() {
|
||||
describe('interop/InteropService_Exporter_Html', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -11,7 +11,7 @@ import { NoteEntity, ResourceEntity } from '../database/types.js';
|
||||
import InteropService from './InteropService.js';
|
||||
import { fileExtension } from '../../path-utils.js';
|
||||
|
||||
describe('interop/InteropService_Exporter_Md', function() {
|
||||
describe('interop/InteropService_Exporter_Md', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -102,7 +102,7 @@ export default class InteropService_Exporter_Md extends InteropService_Exporter_
|
||||
|
||||
// Strip the absolute path to export dir and keep only the relative paths
|
||||
const destDir = this.destDir_;
|
||||
Object.keys(context.notePaths).map(function(id) {
|
||||
Object.keys(context.notePaths).map((id) => {
|
||||
context.notePaths[id] = context.notePaths[id].substr(destDir.length + 1);
|
||||
});
|
||||
|
||||
|
@ -13,7 +13,7 @@ async function recreateExportDir() {
|
||||
await fs.mkdirp(dir);
|
||||
}
|
||||
|
||||
describe('interop/InteropService_Exporter_Md_frontmatter', function() {
|
||||
describe('interop/InteropService_Exporter_Md_frontmatter', () => {
|
||||
async function exportAndLoad(path: string): Promise<string> {
|
||||
const service = InteropService.instance();
|
||||
|
||||
|
@ -7,7 +7,7 @@ import { MarkupToHtml } from '@joplin/renderer';
|
||||
import { FolderEntity } from '../database/types';
|
||||
|
||||
|
||||
describe('InteropService_Importer_Md', function() {
|
||||
describe('InteropService_Importer_Md', () => {
|
||||
let tempDir: string;
|
||||
async function importNote(path: string) {
|
||||
const importer = new InteropService_Importer_Md();
|
||||
@ -27,7 +27,7 @@ describe('InteropService_Importer_Md', function() {
|
||||
afterEach(async () => {
|
||||
await fs.remove(tempDir);
|
||||
});
|
||||
it('should import linked files and modify tags appropriately', async function() {
|
||||
it('should import linked files and modify tags appropriately', async () => {
|
||||
const note = await importNote(`${supportDir}/test_notes/md/sample.md`);
|
||||
|
||||
const tagNonExistentFile = '';
|
||||
@ -36,7 +36,7 @@ describe('InteropService_Importer_Md', function() {
|
||||
const inexistentLinkUnchanged = note.body.includes(tagNonExistentFile);
|
||||
expect(inexistentLinkUnchanged).toBe(true);
|
||||
});
|
||||
it('should only create 1 resource for duplicate links, all tags should be updated', async function() {
|
||||
it('should only create 1 resource for duplicate links, all tags should be updated', async () => {
|
||||
const note = await importNote(`${supportDir}/test_notes/md/sample-duplicate-links.md`);
|
||||
|
||||
const items = await Note.linkedItems(note.body);
|
||||
@ -45,20 +45,20 @@ describe('InteropService_Importer_Md', function() {
|
||||
const matched = note.body.match(reg);
|
||||
expect(matched.length).toBe(2);
|
||||
});
|
||||
it('should import linked files and modify tags appropriately when link is also in alt text', async function() {
|
||||
it('should import linked files and modify tags appropriately when link is also in alt text', async () => {
|
||||
const note = await importNote(`${supportDir}/test_notes/md/sample-link-in-alt-text.md`);
|
||||
|
||||
const items = await Note.linkedItems(note.body);
|
||||
expect(items.length).toBe(1);
|
||||
});
|
||||
it('should passthrough unchanged if no links present', async function() {
|
||||
it('should passthrough unchanged if no links present', async () => {
|
||||
const note = await importNote(`${supportDir}/test_notes/md/sample-no-links.md`);
|
||||
|
||||
const items = await Note.linkedItems(note.body);
|
||||
expect(items.length).toBe(0);
|
||||
expect(note.body).toContain('Unidentified vessel travelling at sub warp speed, bearing 235.7. Fluctuations in energy readings from it, Captain. All transporters off.');
|
||||
});
|
||||
it('should import linked image with special characters in name', async function() {
|
||||
it('should import linked image with special characters in name', async () => {
|
||||
const note = await importNote(`${supportDir}/test_notes/md/sample-special-chars.md`);
|
||||
|
||||
const items = await Note.linkedItems(note.body);
|
||||
@ -68,7 +68,7 @@ describe('InteropService_Importer_Md', function() {
|
||||
const spaceSyntaxLeft = note.body.includes('<../../photo sample.jpg>');
|
||||
expect(spaceSyntaxLeft).toBe(false);
|
||||
});
|
||||
it('should import resources and notes for files', async function() {
|
||||
it('should import resources and notes for files', async () => {
|
||||
const note = await importNote(`${supportDir}/test_notes/md/sample-files.md`);
|
||||
|
||||
const items = await Note.linkedItems(note.body);
|
||||
@ -76,7 +76,7 @@ describe('InteropService_Importer_Md', function() {
|
||||
const noteIds = await Note.linkedNoteIds(note.body);
|
||||
expect(noteIds.length).toBe(1);
|
||||
});
|
||||
it('should gracefully handle reference cycles in notes', async function() {
|
||||
it('should gracefully handle reference cycles in notes', async () => {
|
||||
const importer = new InteropService_Importer_Md();
|
||||
importer.setMetadata({ fileExtensions: ['md'] });
|
||||
const noteA = await importer.importFile(`${supportDir}/test_notes/md/sample-cycles-a.md`, 'notebook');
|
||||
@ -89,27 +89,27 @@ describe('InteropService_Importer_Md', function() {
|
||||
expect(noteAIds[0]).toEqual(noteB.id);
|
||||
expect(noteBIds[0]).toEqual(noteA.id);
|
||||
});
|
||||
it('should not import resources from file:// links', async function() {
|
||||
it('should not import resources from file:// links', async () => {
|
||||
const note = await importNote(`${supportDir}/test_notes/md/sample-file-links.md`);
|
||||
|
||||
const items = await Note.linkedItems(note.body);
|
||||
expect(items.length).toBe(0);
|
||||
expect(note.body).toContain('');
|
||||
});
|
||||
it('should attach resources that are missing the file extension', async function() {
|
||||
it('should attach resources that are missing the file extension', async () => {
|
||||
const note = await importNote(`${supportDir}/test_notes/md/sample-no-extension.md`);
|
||||
|
||||
const items = await Note.linkedItems(note.body);
|
||||
expect(items.length).toBe(1);
|
||||
});
|
||||
it('should attach resources that include anchor links', async function() {
|
||||
it('should attach resources that include anchor links', async () => {
|
||||
const note = await importNote(`${supportDir}/test_notes/md/sample-anchor-link.md`);
|
||||
|
||||
const itemIds = await Note.linkedItemIds(note.body);
|
||||
expect(itemIds.length).toBe(1);
|
||||
expect(note.body).toContain(`[Section 1](:/${itemIds[0]}#markdown)`);
|
||||
});
|
||||
it('should attach resources that include a title', async function() {
|
||||
it('should attach resources that include a title', async () => {
|
||||
const note = await importNote(`${supportDir}/test_notes/md/sample-link-title.md`);
|
||||
|
||||
const items = await Note.linkedItems(note.body);
|
||||
@ -117,7 +117,7 @@ describe('InteropService_Importer_Md', function() {
|
||||
const noteIds = await Note.linkedNoteIds(note.body);
|
||||
expect(noteIds.length).toBe(1);
|
||||
});
|
||||
it('should import notes with html file extension as html', async function() {
|
||||
it('should import notes with html file extension as html', async () => {
|
||||
const note = await importNote(`${supportDir}/test_notes/md/sample.html`);
|
||||
|
||||
const items = await Note.linkedItems(note.body);
|
||||
@ -128,7 +128,7 @@ describe('InteropService_Importer_Md', function() {
|
||||
const preservedAlt = note.body.includes('alt="../../photo.jpg"');
|
||||
expect(preservedAlt).toBe(true);
|
||||
});
|
||||
it('should import non-empty directory', async function() {
|
||||
it('should import non-empty directory', async () => {
|
||||
await fs.mkdirp(`${tempDir}/non-empty/non-empty`);
|
||||
await fs.writeFile(`${tempDir}/non-empty/non-empty/sample.md`, '# Sample');
|
||||
|
||||
@ -136,14 +136,14 @@ describe('InteropService_Importer_Md', function() {
|
||||
const allFolders = await Folder.all();
|
||||
expect(allFolders.map((f: FolderEntity) => f.title).indexOf('non-empty')).toBeGreaterThanOrEqual(0);
|
||||
});
|
||||
it('should not import empty directory', async function() {
|
||||
it('should not import empty directory', async () => {
|
||||
await fs.mkdirp(`${tempDir}/empty/empty`);
|
||||
|
||||
await importNoteDirectory(`${tempDir}/empty`);
|
||||
const allFolders = await Folder.all();
|
||||
expect(allFolders.map((f: FolderEntity) => f.title).indexOf('empty')).toBe(-1);
|
||||
});
|
||||
it('should import directory with non-empty subdirectory', async function() {
|
||||
it('should import directory with non-empty subdirectory', async () => {
|
||||
await fs.mkdirp(`${tempDir}/non-empty-subdir/non-empty-subdir/subdir-empty`);
|
||||
await fs.mkdirp(`${tempDir}/non-empty-subdir/non-empty-subdir/subdir-non-empty`);
|
||||
await fs.writeFile(`${tempDir}/non-empty-subdir/non-empty-subdir/subdir-non-empty/sample.md`, '# Sample');
|
||||
|
@ -5,7 +5,7 @@ import time from '../../time';
|
||||
import { setupDatabaseAndSynchronizer, supportDir, switchClient } from '../../testing/test-utils';
|
||||
|
||||
|
||||
describe('InteropService_Importer_Md_frontmatter: importMetadata', function() {
|
||||
describe('InteropService_Importer_Md_frontmatter: importMetadata', () => {
|
||||
async function importNote(path: string) {
|
||||
const importer = new InteropService_Importer_Md_frontmatter();
|
||||
importer.setMetadata({ fileExtensions: ['md', 'html'] });
|
||||
@ -16,7 +16,7 @@ describe('InteropService_Importer_Md_frontmatter: importMetadata', function() {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
await switchClient(1);
|
||||
});
|
||||
it('should import file and set all metadata correctly', async function() {
|
||||
it('should import file and set all metadata correctly', async () => {
|
||||
const note = await importNote(`${supportDir}/test_notes/yaml/full.md`);
|
||||
const format = 'DD/MM/YYYY HH:mm';
|
||||
|
||||
@ -41,14 +41,14 @@ describe('InteropService_Importer_Md_frontmatter: importMetadata', function() {
|
||||
expect(tagTitles).toContain('note');
|
||||
expect(tagTitles).toContain('pencil');
|
||||
});
|
||||
it('should only import data from the first yaml block', async function() {
|
||||
it('should only import data from the first yaml block', async () => {
|
||||
const note = await importNote(`${supportDir}/test_notes/yaml/split.md`);
|
||||
|
||||
expect(note.title).toBe('xxx');
|
||||
expect(note.author).not.toBe('xxx');
|
||||
expect(note.body).toBe('---\nauthor: xxx\n---\n\nnote body\n');
|
||||
});
|
||||
it('should only import, duplicate notes and tags are not created', async function() {
|
||||
it('should only import, duplicate notes and tags are not created', async () => {
|
||||
const note = await importNote(`${supportDir}/test_notes/yaml/duplicates.md`);
|
||||
|
||||
expect(note.title).toBe('ddd');
|
||||
@ -58,13 +58,13 @@ describe('InteropService_Importer_Md_frontmatter: importMetadata', function() {
|
||||
const tags = await Tag.tagsByNoteId(note.id);
|
||||
expect(tags.length).toBe(1);
|
||||
});
|
||||
it('should not import items as numbers', async function() {
|
||||
it('should not import items as numbers', async () => {
|
||||
const note = await importNote(`${supportDir}/test_notes/yaml/numbers.md`);
|
||||
|
||||
expect(note.title).toBe('001');
|
||||
expect(note.body).toBe('note body\n');
|
||||
});
|
||||
it('should normalize whitespace and load correctly', async function() {
|
||||
it('should normalize whitespace and load correctly', async () => {
|
||||
const note = await importNote(`${supportDir}/test_notes/yaml/normalize.md`);
|
||||
|
||||
expect(note.title).toBe('norm');
|
||||
@ -73,7 +73,7 @@ describe('InteropService_Importer_Md_frontmatter: importMetadata', function() {
|
||||
const tags = await Tag.tagsByNoteId(note.id);
|
||||
expect(tags.length).toBe(3);
|
||||
});
|
||||
it('should load unquoted special forms correctly', async function() {
|
||||
it('should load unquoted special forms correctly', async () => {
|
||||
const note = await importNote(`${supportDir}/test_notes/yaml/unquoted.md`);
|
||||
|
||||
expect(note.title).toBe('Unquoted');
|
||||
@ -83,19 +83,19 @@ describe('InteropService_Importer_Md_frontmatter: importMetadata', function() {
|
||||
expect(note.is_todo).toBe(1);
|
||||
expect(note.todo_completed).toBeUndefined();
|
||||
});
|
||||
it('should load notes with newline in the title', async function() {
|
||||
it('should load notes with newline in the title', async () => {
|
||||
const note = await importNote(`${supportDir}/test_notes/yaml/title_newline.md`);
|
||||
|
||||
expect(note.title).toBe('First\nSecond');
|
||||
});
|
||||
it('should import dates (without time) correctly', async function() {
|
||||
it('should import dates (without time) correctly', async () => {
|
||||
const note = await importNote(`${supportDir}/test_notes/yaml/short_date.md`);
|
||||
const format = 'YYYY-MM-DD HH:mm';
|
||||
|
||||
expect(time.formatMsToLocal(note.user_updated_time, format)).toBe('2021-01-01 00:00');
|
||||
expect(time.formatMsToLocal(note.user_created_time, format)).toBe('2017-01-01 00:00');
|
||||
});
|
||||
it('should load tags even with the inline syntax', async function() {
|
||||
it('should load tags even with the inline syntax', async () => {
|
||||
const note = await importNote(`${supportDir}/test_notes/yaml/inline_tags.md`);
|
||||
|
||||
expect(note.title).toBe('Inline Tags');
|
||||
@ -103,7 +103,7 @@ describe('InteropService_Importer_Md_frontmatter: importMetadata', function() {
|
||||
const tags = await Tag.tagsByNoteId(note.id);
|
||||
expect(tags.length).toBe(2);
|
||||
});
|
||||
it('should import r-markdown files correctly and set what metadata it can', async function() {
|
||||
it('should import r-markdown files correctly and set what metadata it can', async () => {
|
||||
const note = await importNote(`${supportDir}/test_notes/yaml/r-markdown.md`);
|
||||
const format = 'YYYY-MM-DD HH:mm';
|
||||
|
||||
@ -119,13 +119,13 @@ describe('InteropService_Importer_Md_frontmatter: importMetadata', function() {
|
||||
expect(tagTitles).toContain('yaml');
|
||||
expect(tagTitles).toContain('rmd');
|
||||
});
|
||||
it('should import r-markdown files with alternative author syntax', async function() {
|
||||
it('should import r-markdown files with alternative author syntax', async () => {
|
||||
const note = await importNote(`${supportDir}/test_notes/yaml/r-markdown_author.md`);
|
||||
|
||||
expect(note.title).toBe('Distill for R Markdown');
|
||||
expect(note.author).toBe('JJ Allaire');
|
||||
});
|
||||
it('should handle date formats with timezone information', async function() {
|
||||
it('should handle date formats with timezone information', async () => {
|
||||
const note = await importNote(`${supportDir}/test_notes/yaml/utc.md`);
|
||||
|
||||
expect(note.user_updated_time).toBe(1556729640000);
|
||||
|
@ -119,7 +119,7 @@ const createFiles = async () => {
|
||||
await writeFile(makeFilePath(tempDir, rawNote2), rawNote2);
|
||||
};
|
||||
|
||||
describe('InteropService_Importer_Raw', function() {
|
||||
describe('InteropService_Importer_Raw', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
@ -131,7 +131,7 @@ describe('InteropService_Importer_Raw', function() {
|
||||
await remove(tempDir);
|
||||
});
|
||||
|
||||
it('should import raw files', async function() {
|
||||
it('should import raw files', async () => {
|
||||
await createFiles();
|
||||
|
||||
const importOptions: ImportOptions = {
|
||||
@ -163,7 +163,7 @@ describe('InteropService_Importer_Raw', function() {
|
||||
expect(note2.parent_id).toBe(folder2.id);
|
||||
});
|
||||
|
||||
it('should handle duplicate names', async function() {
|
||||
it('should handle duplicate names', async () => {
|
||||
await createFiles();
|
||||
|
||||
const importOptions: ImportOptions = {
|
||||
|
@ -35,7 +35,7 @@ const createNoteForPagination = async (numOrTitle: number | string, time: number
|
||||
|
||||
let api: Api = null;
|
||||
|
||||
describe('services_rest_Api', function() {
|
||||
describe('services_rest_Api', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
api = new Api();
|
||||
|
@ -7,7 +7,7 @@ import Api, { RequestMethod } from '../Api';
|
||||
|
||||
let api: Api = null;
|
||||
|
||||
describe('routes/events', function() {
|
||||
describe('routes/events', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
api = new Api();
|
||||
|
@ -57,7 +57,7 @@ const calculateScore = (searchString, notes) => {
|
||||
return scores;
|
||||
};
|
||||
|
||||
describe('services_SearchEngine', function() {
|
||||
describe('services_SearchEngine', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -7,7 +7,7 @@ const Note = require('../../models/Note').default;
|
||||
|
||||
let searchEngine: any = null;
|
||||
|
||||
describe('services_SearchEngineUtils', function() {
|
||||
describe('services_SearchEngineUtils', () => {
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
await switchClient(1);
|
||||
@ -15,7 +15,7 @@ describe('services_SearchEngineUtils', function() {
|
||||
searchEngine.setDb(db());
|
||||
});
|
||||
|
||||
describe('filter todos based on showCompletedTodos', function() {
|
||||
describe('filter todos based on showCompletedTodos', () => {
|
||||
it('show completed', (async () => {
|
||||
const note1 = await Note.save({ title: 'abcd', body: 'body 1' });
|
||||
const todo1 = await Note.save({ title: 'abcd', body: 'todo 1', is_todo: 1 });
|
||||
|
@ -15,7 +15,7 @@ let engine: any = null;
|
||||
|
||||
const ids = (array: NoteEntity[]) => array.map(a => a.id);
|
||||
|
||||
describe('services_SearchFilter', function() {
|
||||
describe('services_SearchFilter', () => {
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
await switchClient(1);
|
||||
|
@ -33,7 +33,7 @@ function mockService(api: any) {
|
||||
return service;
|
||||
}
|
||||
|
||||
describe('ShareService', function() {
|
||||
describe('ShareService', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -1,6 +1,6 @@
|
||||
import cssToTheme from './cssToTheme';
|
||||
|
||||
describe('cssToTheme', function() {
|
||||
describe('cssToTheme', () => {
|
||||
|
||||
it('should convert a CSS string to a theme', async () => {
|
||||
const input = `
|
||||
|
@ -97,7 +97,7 @@ const expected = `
|
||||
--joplin-code-theme-css: atom-one-light.css;
|
||||
}`;
|
||||
|
||||
describe('themeToCss', function() {
|
||||
describe('themeToCss', () => {
|
||||
|
||||
it('should a theme to a CSS string', async () => {
|
||||
const actual = themeToCss(input);
|
||||
|
@ -41,7 +41,7 @@ function newFakeApiCall(callRecorder: ApiCall[], itemBodyCallback: Function = nu
|
||||
return apiCall;
|
||||
}
|
||||
|
||||
describe('synchronizer/ItemUploader', function() {
|
||||
describe('synchronizer/ItemUploader', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -6,7 +6,7 @@ import Note from '../../models/Note';
|
||||
import BaseItem from '../../models/BaseItem';
|
||||
const WelcomeUtils = require('../../WelcomeUtils');
|
||||
|
||||
describe('Synchronizer.basics', function() {
|
||||
describe('Synchronizer.basics', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -6,7 +6,7 @@ import Note from '../../models/Note';
|
||||
import BaseItem from '../../models/BaseItem';
|
||||
import { setEncryptionEnabled } from '../synchronizer/syncInfoUtils';
|
||||
|
||||
describe('Synchronizer.conflicts', function() {
|
||||
describe('Synchronizer.conflicts', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabaseAndSynchronizer(1);
|
||||
|
@ -18,7 +18,7 @@ function newResourceFetcher(synchronizer: Synchronizer) {
|
||||
return new ResourceFetcher(() => { return synchronizer.api(); });
|
||||
}
|
||||
|
||||
describe('Synchronizer.e2ee', function() {
|
||||
describe('Synchronizer.e2ee', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
insideBeforeEach = true;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user