You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-03 23:50:33 +02:00
Tools: Apply eslint rule multiline-comment-style with checkJSDoc option
This commit is contained in:
@ -137,7 +137,7 @@ module.exports = {
|
|||||||
'named': 'never',
|
'named': 'never',
|
||||||
'asyncArrow': 'always',
|
'asyncArrow': 'always',
|
||||||
}],
|
}],
|
||||||
'multiline-comment-style': ['error', 'separate-lines'],
|
'multiline-comment-style': ['error', 'separate-lines', { checkJSDoc: true }],
|
||||||
'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 }],
|
||||||
@ -183,7 +183,7 @@ module.exports = {
|
|||||||
'project': './tsconfig.eslint.json',
|
'project': './tsconfig.eslint.json',
|
||||||
},
|
},
|
||||||
'rules': {
|
'rules': {
|
||||||
'github/array-foreach': ['error'],
|
|
||||||
'@typescript-eslint/explicit-member-accessibility': ['error'],
|
'@typescript-eslint/explicit-member-accessibility': ['error'],
|
||||||
'@typescript-eslint/type-annotation-spacing': ['error', { 'before': false, 'after': true }],
|
'@typescript-eslint/type-annotation-spacing': ['error', { 'before': false, 'after': true }],
|
||||||
'@typescript-eslint/array-type': 'error',
|
'@typescript-eslint/array-type': 'error',
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
/**
|
/**
|
||||||
* @jest-environment jsdom
|
* @jest-environment jsdom
|
||||||
*/
|
*/
|
||||||
|
/* eslint-enable multiline-comment-style */
|
||||||
|
|
||||||
import { EditorSettings } from '../types';
|
import { EditorSettings } from '../types';
|
||||||
import { initCodeMirror } from './CodeMirror';
|
import { initCodeMirror } from './CodeMirror';
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
/**
|
/**
|
||||||
* @jest-environment jsdom
|
* @jest-environment jsdom
|
||||||
*/
|
*/
|
||||||
|
/* eslint-enable multiline-comment-style */
|
||||||
import { EditorSelection } from '@codemirror/state';
|
import { EditorSelection } from '@codemirror/state';
|
||||||
import { ListType } from '../types';
|
import { ListType } from '../types';
|
||||||
import createEditor from './testUtil/createEditor';
|
import createEditor from './testUtil/createEditor';
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
/**
|
/**
|
||||||
* @jest-environment jsdom
|
* @jest-environment jsdom
|
||||||
*/
|
*/
|
||||||
|
/* eslint-enable multiline-comment-style */
|
||||||
|
|
||||||
import { EditorSelection } from '@codemirror/state';
|
import { EditorSelection } from '@codemirror/state';
|
||||||
import {
|
import {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
/**
|
/**
|
||||||
* @jest-environment jsdom
|
* @jest-environment jsdom
|
||||||
*/
|
*/
|
||||||
|
/* eslint-enable multiline-comment-style */
|
||||||
|
|
||||||
import { EditorSelection, EditorState } from '@codemirror/state';
|
import { EditorSelection, EditorState } from '@codemirror/state';
|
||||||
import {
|
import {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
/**
|
/**
|
||||||
* @jest-environment jsdom
|
* @jest-environment jsdom
|
||||||
*/
|
*/
|
||||||
|
/* eslint-enable multiline-comment-style */
|
||||||
|
|
||||||
import { syntaxTree } from '@codemirror/language';
|
import { syntaxTree } from '@codemirror/language';
|
||||||
import { SyntaxNode } from '@lezer/common';
|
import { SyntaxNode } from '@lezer/common';
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
/**
|
// Search for $s and $$s in markdown and mark the regions between them as math.
|
||||||
* Search for $s and $$s in markdown and mark the regions between them as math.
|
//
|
||||||
*
|
// Text between single $s is marked as InlineMath and text between $$s is marked
|
||||||
* Text between single $s is marked as InlineMath and text between $$s is marked
|
// as BlockMath.
|
||||||
* as BlockMath.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { tags, Tag } from '@lezer/highlight';
|
import { tags, Tag } from '@lezer/highlight';
|
||||||
import { parseMixed, SyntaxNodeRef, Input, NestedParse, ParseWrapper } from '@lezer/common';
|
import { parseMixed, SyntaxNodeRef, Input, NestedParse, ParseWrapper } from '@lezer/common';
|
||||||
@ -34,13 +32,11 @@ export const inlineMathContentTagName = 'InlineMathContent';
|
|||||||
export const mathTag = Tag.define(tags.monospace);
|
export const mathTag = Tag.define(tags.monospace);
|
||||||
export const inlineMathTag = Tag.define(mathTag);
|
export const inlineMathTag = Tag.define(mathTag);
|
||||||
|
|
||||||
/**
|
// Wraps a TeX math-mode parser. This removes [nodeTag] from the syntax tree
|
||||||
* Wraps a TeX math-mode parser. This removes [nodeTag] from the syntax tree
|
// and replaces it with a region handled by the sTeXMath parser.
|
||||||
* and replaces it with a region handled by the sTeXMath parser.
|
//
|
||||||
*
|
// @param nodeTag Name of the nodes to replace with regions parsed by the sTeX parser.
|
||||||
* @param nodeTag Name of the nodes to replace with regions parsed by the sTeX parser.
|
// @returns a wrapped sTeX parser.
|
||||||
* @returns a wrapped sTeX parser.
|
|
||||||
*/
|
|
||||||
const wrappedTeXParser = (nodeTag: string): ParseWrapper => {
|
const wrappedTeXParser = (nodeTag: string): ParseWrapper => {
|
||||||
return parseMixed((node: SyntaxNodeRef, _input: Input): NestedParse => {
|
return parseMixed((node: SyntaxNodeRef, _input: Input): NestedParse => {
|
||||||
if (node.name !== nodeTag) {
|
if (node.name !== nodeTag) {
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
/**
|
// Metro configuration for React Native
|
||||||
* Metro configuration for React Native
|
// https://github.com/facebook/react-native
|
||||||
* https://github.com/facebook/react-native
|
|
||||||
*
|
|
||||||
* @format
|
|
||||||
*/
|
|
||||||
|
|
||||||
// The technique below to get the symlinked packages to work with the Metro
|
// The technique below to get the symlinked packages to work with the Metro
|
||||||
// bundler comes from this comment:
|
// bundler comes from this comment:
|
||||||
|
@ -6,9 +6,7 @@ import { CachesDirectoryPath } from 'react-native-fs';
|
|||||||
// when refactoring this name, make sure to refactor the `SharePackage.java` (in android) as well
|
// when refactoring this name, make sure to refactor the `SharePackage.java` (in android) as well
|
||||||
const DIR_NAME = 'sharedFiles';
|
const DIR_NAME = 'sharedFiles';
|
||||||
|
|
||||||
/**
|
// Copy a file to be shared to cache, renaming it to its orignal name
|
||||||
* Copy a file to be shared to cache, renaming it to its orignal name
|
|
||||||
*/
|
|
||||||
export async function copyToCache(resource: ResourceEntity): Promise<string> {
|
export async function copyToCache(resource: ResourceEntity): Promise<string> {
|
||||||
const filename = Resource.friendlySafeFilename(resource);
|
const filename = Resource.friendlySafeFilename(resource);
|
||||||
|
|
||||||
@ -22,9 +20,7 @@ export async function copyToCache(resource: ResourceEntity): Promise<string> {
|
|||||||
return targetFile;
|
return targetFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Clear previously shared files from cache
|
||||||
* Clear previously shared files from cache
|
|
||||||
*/
|
|
||||||
export async function clearSharedFilesCache(): Promise<void> {
|
export async function clearSharedFilesCache(): Promise<void> {
|
||||||
return shim.fsDriver().remove(`${CachesDirectoryPath}/sharedFiles`);
|
return shim.fsDriver().remove(`${CachesDirectoryPath}/sharedFiles`);
|
||||||
}
|
}
|
||||||
|
@ -28,17 +28,15 @@ const beautifyHtml = (html) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
// Tests the importer for a single note, checking that the result of
|
||||||
* Tests the importer for a single note, checking that the result of
|
// processing the given `.enex` input file matches the contents of the given
|
||||||
* processing the given `.enex` input file matches the contents of the given
|
// `.html` file.
|
||||||
* `.html` file.
|
//
|
||||||
*
|
// Note that this does not test the importing of an entire exported `.enex`
|
||||||
* Note that this does not test the importing of an entire exported `.enex`
|
// archive, but rather a single node of such a file. Thus, the test data files
|
||||||
* archive, but rather a single node of such a file. Thus, the test data files
|
// (e.g. `./enex_to_html/code1.enex`) correspond to the contents of a single
|
||||||
* (e.g. `./enex_to_html/code1.enex`) correspond to the contents of a single
|
// `<note>...</note>` node in an `.enex` file already extracted from
|
||||||
* `<note>...</note>` node in an `.enex` file already extracted from
|
// `<content><![CDATA[...]]</content>`.
|
||||||
* `<content><![CDATA[...]]</content>`.
|
|
||||||
*/
|
|
||||||
const compareOutputToExpected = (options) => {
|
const compareOutputToExpected = (options) => {
|
||||||
options = {
|
options = {
|
||||||
resources: [],
|
resources: [],
|
||||||
|
@ -196,13 +196,11 @@ export default class InteropService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// NOTE TO FUTURE SELF: It might make sense to simply move all the existing
|
||||||
* NOTE TO FUTURE SELF: It might make sense to simply move all the existing
|
// formatters to the `newModuleFromPath_` approach, so that there's only one way
|
||||||
* formatters to the `newModuleFromPath_` approach, so that there's only one way
|
// to do this mapping. This isn't a priority right now (per the convo in:
|
||||||
* to do this mapping. This isn't a priority right now (per the convo in:
|
// https://github.com/laurent22/joplin/pull/1795#discussion_r322379121) but
|
||||||
* https://github.com/laurent22/joplin/pull/1795#discussion_r322379121) but
|
// we can do it if it ever becomes necessary.
|
||||||
* we can do it if it ever becomes necessary.
|
|
||||||
*/
|
|
||||||
private newModuleByFormat_(type: ModuleType, format: string, outputFormat: ImportModuleOutputFormat = ImportModuleOutputFormat.Markdown) {
|
private newModuleByFormat_(type: ModuleType, format: string, outputFormat: ImportModuleOutputFormat = ImportModuleOutputFormat.Markdown) {
|
||||||
const moduleMetadata = this.findModuleByFormat_(type, format, null, outputFormat);
|
const moduleMetadata = this.findModuleByFormat_(type, format, null, outputFormat);
|
||||||
if (!moduleMetadata) throw new Error(_('Cannot load "%s" module for format "%s" and output "%s"', type, format, outputFormat));
|
if (!moduleMetadata) throw new Error(_('Cannot load "%s" module for format "%s" and output "%s"', type, format, outputFormat));
|
||||||
@ -221,14 +219,12 @@ export default class InteropService {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// The existing `newModuleByFormat_` fn would load by the input format. This
|
||||||
* The existing `newModuleByFormat_` fn would load by the input format. This
|
// was fine when there was a 1-1 mapping of input formats to output formats,
|
||||||
* was fine when there was a 1-1 mapping of input formats to output formats,
|
// but now that we have 2 possible outputs for an `enex` input, we need to be
|
||||||
* but now that we have 2 possible outputs for an `enex` input, we need to be
|
// explicit with which importer we want to use.
|
||||||
* explicit with which importer we want to use.
|
//
|
||||||
*
|
// https://github.com/laurent22/joplin/pull/1795#pullrequestreview-281574417
|
||||||
* https://github.com/laurent22/joplin/pull/1795#pullrequestreview-281574417
|
|
||||||
*/
|
|
||||||
private newModuleFromPath_(type: ModuleType, options: any) {
|
private newModuleFromPath_(type: ModuleType, options: any) {
|
||||||
const moduleMetadata = this.findModuleByFormat_(type, options.format, options.target);
|
const moduleMetadata = this.findModuleByFormat_(type, options.format, options.target);
|
||||||
if (!moduleMetadata) throw new Error(_('Cannot load "%s" module for format "%s" and target "%s"', type, options.format, options.target));
|
if (!moduleMetadata) throw new Error(_('Cannot load "%s" module for format "%s" and target "%s"', type, options.format, options.target));
|
||||||
|
@ -90,10 +90,8 @@ export default class InteropService_Importer_Md extends InteropService_Importer_
|
|||||||
return splitted.join('#');
|
return splitted.join('#');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Parse text for links, attempt to find local file, if found create Joplin resource
|
||||||
* Parse text for links, attempt to find local file, if found create Joplin resource
|
// and update link accordingly.
|
||||||
* and update link accordingly.
|
|
||||||
*/
|
|
||||||
public async importLocalFiles(filePath: string, md: string, parentFolderId: string) {
|
public async importLocalFiles(filePath: string, md: string, parentFolderId: string) {
|
||||||
let updated = md;
|
let updated = md;
|
||||||
const markdownLinks = markdownUtils.extractFileUrls(md);
|
const markdownLinks = markdownUtils.extractFileUrls(md);
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
|
|
||||||
import Plugin from '../Plugin';
|
import Plugin from '../Plugin';
|
||||||
import Joplin from './Joplin';
|
import Joplin from './Joplin';
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
|
|
||||||
import Plugin from '../Plugin';
|
import Plugin from '../Plugin';
|
||||||
import JoplinData from './JoplinData';
|
import JoplinData from './JoplinData';
|
||||||
import JoplinPlugins from './JoplinPlugins';
|
import JoplinPlugins from './JoplinPlugins';
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
|
|
||||||
export default class JoplinClipboard {
|
export default class JoplinClipboard {
|
||||||
|
|
||||||
private electronClipboard_: any = null;
|
private electronClipboard_: any = null;
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
|
|
||||||
import CommandService, { CommandContext, CommandDeclaration, CommandRuntime } from '../../CommandService';
|
import CommandService, { CommandContext, CommandDeclaration, CommandRuntime } from '../../CommandService';
|
||||||
import { Command } from './types';
|
import { Command } from './types';
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
|
|
||||||
import Plugin from '../Plugin';
|
import Plugin from '../Plugin';
|
||||||
import { ContentScriptType } from './types';
|
import { ContentScriptType } from './types';
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
|
|
||||||
import { ModelType } from '../../../BaseModel';
|
import { ModelType } from '../../../BaseModel';
|
||||||
import BaseItem from '../../../models/BaseItem';
|
import BaseItem from '../../../models/BaseItem';
|
||||||
import Resource from '../../../models/Resource';
|
import Resource from '../../../models/Resource';
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
|
|
||||||
import eventManager from '../../../eventManager';
|
import eventManager from '../../../eventManager';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
|
|
||||||
import InteropService from '../../interop/InteropService';
|
import InteropService from '../../interop/InteropService';
|
||||||
import { Module, ModuleType } from '../../interop/types';
|
import { Module, ModuleType } from '../../interop/types';
|
||||||
import { ExportModule, ImportModule } from './types';
|
import { ExportModule, ImportModule } from './types';
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
|
|
||||||
import Plugin from '../Plugin';
|
import Plugin from '../Plugin';
|
||||||
import Logger from '../../../Logger';
|
import Logger from '../../../Logger';
|
||||||
import { ContentScriptType, Script } from './types';
|
import { ContentScriptType, Script } from './types';
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
|
|
||||||
import eventManager from '../../../eventManager';
|
import eventManager from '../../../eventManager';
|
||||||
import Setting, { SettingItem as InternalSettingItem, SettingSectionSource } from '../../../models/Setting';
|
import Setting, { SettingItem as InternalSettingItem, SettingSectionSource } from '../../../models/Setting';
|
||||||
import Plugin from '../Plugin';
|
import Plugin from '../Plugin';
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
|
|
||||||
import Plugin from '../Plugin';
|
import Plugin from '../Plugin';
|
||||||
import JoplinViewsDialogs from './JoplinViewsDialogs';
|
import JoplinViewsDialogs from './JoplinViewsDialogs';
|
||||||
import JoplinViewsMenuItems from './JoplinViewsMenuItems';
|
import JoplinViewsMenuItems from './JoplinViewsMenuItems';
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
|
|
||||||
import Plugin from '../Plugin';
|
import Plugin from '../Plugin';
|
||||||
import createViewHandle from '../utils/createViewHandle';
|
import createViewHandle from '../utils/createViewHandle';
|
||||||
import WebviewController, { ContainerType } from '../WebviewController';
|
import WebviewController, { ContainerType } from '../WebviewController';
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
|
|
||||||
import KeymapService from '../../KeymapService';
|
import KeymapService from '../../KeymapService';
|
||||||
import { CreateMenuItemOptions, MenuItemLocation } from './types';
|
import { CreateMenuItemOptions, MenuItemLocation } from './types';
|
||||||
import MenuItemController from '../MenuItemController';
|
import MenuItemController from '../MenuItemController';
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
|
|
||||||
import KeymapService from '../../KeymapService';
|
import KeymapService from '../../KeymapService';
|
||||||
import { MenuItem, MenuItemLocation } from './types';
|
import { MenuItem, MenuItemLocation } from './types';
|
||||||
import MenuController from '../MenuController';
|
import MenuController from '../MenuController';
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
|
|
||||||
import Plugin from '../Plugin';
|
import Plugin from '../Plugin';
|
||||||
import createViewHandle from '../utils/createViewHandle';
|
import createViewHandle from '../utils/createViewHandle';
|
||||||
import WebviewController, { ContainerType } from '../WebviewController';
|
import WebviewController, { ContainerType } from '../WebviewController';
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
|
|
||||||
import { ToolbarButtonLocation } from './types';
|
import { ToolbarButtonLocation } from './types';
|
||||||
import Plugin from '../Plugin';
|
import Plugin from '../Plugin';
|
||||||
import ToolbarButtonController from '../ToolbarButtonController';
|
import ToolbarButtonController from '../ToolbarButtonController';
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
|
|
||||||
import Plugin from '../Plugin';
|
import Plugin from '../Plugin';
|
||||||
import * as fs from 'fs-extra';
|
import * as fs from 'fs-extra';
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
|
|
||||||
import { ModelType } from '../../../BaseModel';
|
import { ModelType } from '../../../BaseModel';
|
||||||
import eventManager from '../../../eventManager';
|
import eventManager from '../../../eventManager';
|
||||||
import Setting from '../../../models/Setting';
|
import Setting from '../../../models/Setting';
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
|
|
||||||
// =================================================================
|
// =================================================================
|
||||||
// Command API types
|
// Command API types
|
||||||
// =================================================================
|
// =================================================================
|
||||||
|
@ -92,10 +92,8 @@ export type CreateDocumentOptions = FileOperationOptions & {
|
|||||||
initialName?: string;
|
initialName?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
// Open the Document Picker to select a folder. Read/Write Permission will be granted to the selected folder.
|
||||||
* Open the Document Picker to select a folder. Read/Write Permission will be granted to the selected folder.
|
// Returns an object of type `DocumentFileDetail` or `null` if user did not select a folder.
|
||||||
* Returns an object of type `DocumentFileDetail` or `null` if user did not select a folder.
|
|
||||||
*/
|
|
||||||
export function openDocumentTree(persist: boolean) {
|
export function openDocumentTree(persist: boolean) {
|
||||||
return SafX.openDocumentTree(persist);
|
return SafX.openDocumentTree(persist);
|
||||||
}
|
}
|
||||||
@ -107,20 +105,16 @@ export type OpenDocumentOptions = {
|
|||||||
multiple?: boolean;
|
multiple?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
// Open the Document Picker to select a file.
|
||||||
* Open the Document Picker to select a file.
|
// DocumentFileDetail is always an array.
|
||||||
* DocumentFileDetail is always an array.
|
// @returns `DocumentFileDetail[]` or `null` if user did not select a file.
|
||||||
* @returns `DocumentFileDetail[]` or `null` if user did not select a file.
|
|
||||||
*/
|
|
||||||
export function openDocument(options: OpenDocumentOptions) {
|
export function openDocument(options: OpenDocumentOptions) {
|
||||||
const { persist = false, multiple = false } = options;
|
const { persist = false, multiple = false } = options;
|
||||||
return SafX.openDocument(persist, multiple);
|
return SafX.openDocument(persist, multiple);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Open the Document Picker to save a file.
|
||||||
* Open the Document Picker to save a file.
|
// Returns an object of type `DocumentFileDetail` or `null` if user did not select a file.
|
||||||
* Returns an object of type `DocumentFileDetail` or `null` if user did not select a file.
|
|
||||||
*/
|
|
||||||
export function createDocument(data: string, options?: CreateDocumentOptions) {
|
export function createDocument(data: string, options?: CreateDocumentOptions) {
|
||||||
if (!options) options = {};
|
if (!options) options = {};
|
||||||
const { encoding, initialName, mimeType } = options;
|
const { encoding, initialName, mimeType } = options;
|
||||||
@ -147,11 +141,9 @@ export function readFile(
|
|||||||
return SafX.readFile(uriString, encoding);
|
return SafX.readFile(uriString, encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Writes the given data to the file at given uri.
|
||||||
* Writes the given data to the file at given uri.
|
// Tries to create the file if does not already exist before writing to it.
|
||||||
* Tries to create the file if does not already exist before writing to it.
|
// Resolves with given uriString if successful.
|
||||||
* Resolves with given uriString if successful.
|
|
||||||
*/
|
|
||||||
export function writeFile(
|
export function writeFile(
|
||||||
uriString: string,
|
uriString: string,
|
||||||
data: string,
|
data: string,
|
||||||
@ -162,10 +154,8 @@ export function writeFile(
|
|||||||
return SafX.writeFile(uriString, data, encoding, mimeType, !!append);
|
return SafX.writeFile(uriString, data, encoding, mimeType, !!append);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Creates an empty file at given uri.
|
||||||
* Creates an empty file at given uri.
|
// Rejects if a file or directory exist at given uri.
|
||||||
* Rejects if a file or directory exist at given uri.
|
|
||||||
*/
|
|
||||||
export function createFile(
|
export function createFile(
|
||||||
uriString: string,
|
uriString: string,
|
||||||
options?: Pick<FileOperationOptions, 'mimeType'>
|
options?: Pick<FileOperationOptions, 'mimeType'>
|
||||||
@ -175,29 +165,23 @@ export function createFile(
|
|||||||
return SafX.createFile(uriString, mimeType);
|
return SafX.createFile(uriString, mimeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Removes the file or directory at given uri.
|
||||||
* Removes the file or directory at given uri.
|
// Resolves with `true` if delete is successful, throws otherwise.
|
||||||
* Resolves with `true` if delete is successful, throws otherwise.
|
|
||||||
*/
|
|
||||||
export function unlink(uriString: string) {
|
export function unlink(uriString: string) {
|
||||||
return SafX.unlink(uriString);
|
return SafX.unlink(uriString);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Create a directory at given uri.
|
||||||
* Create a directory at given uri.
|
// Automatically creates folders in path if needed.
|
||||||
* Automatically creates folders in path if needed.
|
// You can use it to create nested directories easily.
|
||||||
* You can use it to create nested directories easily.
|
// Rejects if it fails.
|
||||||
* Rejects if it fails.
|
|
||||||
*/
|
|
||||||
export function mkdir(uriString: string) {
|
export function mkdir(uriString: string) {
|
||||||
return SafX.mkdir(uriString);
|
return SafX.mkdir(uriString);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Renames the document at given uri.
|
||||||
* Renames the document at given uri.
|
// uri can be file or folder.
|
||||||
* uri can be file or folder.
|
// Resolves with `true` if successful and `false` otherwise.
|
||||||
* Resolves with `true` if successful and `false` otherwise.
|
|
||||||
*/
|
|
||||||
export function rename(uriString: string, newName: string) {
|
export function rename(uriString: string, newName: string) {
|
||||||
return SafX.rename(uriString, newName);
|
return SafX.rename(uriString, newName);
|
||||||
}
|
}
|
||||||
@ -226,11 +210,9 @@ type FileTransferOptions = {
|
|||||||
replaceIfDestinationExists?: boolean;
|
replaceIfDestinationExists?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
// Copy file from source uri to destination uri.
|
||||||
* Copy file from source uri to destination uri.
|
// promise Rejects if destination already exists and `replaceIfDestinationExists` option is not set to true.
|
||||||
* promise Rejects if destination already exists and `replaceIfDestinationExists` option is not set to true.
|
// Does not support moving directories.
|
||||||
* Does not support moving directories.
|
|
||||||
*/
|
|
||||||
export function copyFile(
|
export function copyFile(
|
||||||
srcUri: string,
|
srcUri: string,
|
||||||
destUri: string,
|
destUri: string,
|
||||||
@ -241,11 +223,9 @@ export function copyFile(
|
|||||||
return SafX.transferFile(srcUri, destUri, replaceIfDestinationExists, true);
|
return SafX.transferFile(srcUri, destUri, replaceIfDestinationExists, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Move file from source uri to destination uri.
|
||||||
* Move file from source uri to destination uri.
|
// promise Rejects if destination already exists and `replaceIfDestinationExists` option is not set to true.
|
||||||
* promise Rejects if destination already exists and `replaceIfDestinationExists` option is not set to true.
|
// Does not support moving directories.
|
||||||
* Does not support moving directories.
|
|
||||||
*/
|
|
||||||
export function moveFile(
|
export function moveFile(
|
||||||
srcUri: string,
|
srcUri: string,
|
||||||
destUri: string,
|
destUri: string,
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
/* eslint-disable multiline-comment-style */
|
||||||
/**
|
/**
|
||||||
* @jest-environment jsdom
|
* @jest-environment jsdom
|
||||||
*/
|
*/
|
||||||
|
/* eslint-enable multiline-comment-style */
|
||||||
|
|
||||||
import { createEventHandlingListeners, Options } from './createEventHandlingAttrs';
|
import { createEventHandlingListeners, Options } from './createEventHandlingAttrs';
|
||||||
import { describe, beforeAll, it, jest, expect } from '@jest/globals';
|
import { describe, beforeAll, it, jest, expect } from '@jest/globals';
|
||||||
|
Reference in New Issue
Block a user