1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-23 22:36:32 +02:00

Tools: Add eslint rule @typescript-eslint/array-type

This commit is contained in:
Laurent Cozic
2023-06-30 09:16:08 +01:00
parent e89b59be8e
commit c6a15b3186
8 changed files with 8 additions and 7 deletions

View File

@@ -183,6 +183,7 @@ module.exports = {
'rules': { 'rules': {
'@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/no-inferrable-types': ['error'], '@typescript-eslint/no-inferrable-types': ['error'],
'@typescript-eslint/comma-dangle': ['error', { '@typescript-eslint/comma-dangle': ['error', {
'arrays': 'always-multiline', 'arrays': 'always-multiline',

View File

@@ -10,7 +10,7 @@ export const declaration: CommandDeclaration = {
export const runtime = (): CommandRuntime => { export const runtime = (): CommandRuntime => {
return { return {
execute: async (_context: CommandContext, field?: string | Array<any>, reverse?: boolean) => { execute: async (_context: CommandContext, field?: string | any[], reverse?: boolean) => {
// field: Sort order's field. undefined means switching a field. // field: Sort order's field. undefined means switching a field.
// reverse: whether the sort order is reversed or not. undefined means toggling. // reverse: whether the sort order is reversed or not. undefined means toggling.
// //

View File

@@ -20,7 +20,7 @@ const { clipboard } = require('electron');
interface Props { interface Props {
themeId: number; themeId: number;
noteIds: Array<string>; noteIds: string[];
onClose: Function; onClose: Function;
shares: StateShare[]; shares: StateShare[];
syncTargetId: number; syncTargetId: number;

View File

@@ -6,7 +6,7 @@ type CallbackHandler<EventType> = (data: EventType)=> void;
export default class EventDispatcher<EventKeyType extends string|symbol|number, EventMessageType> { export default class EventDispatcher<EventKeyType extends string|symbol|number, EventMessageType> {
// Partial marks all fields as optional. To initialize with an empty object, this is required. // Partial marks all fields as optional. To initialize with an empty object, this is required.
// See https://stackoverflow.com/a/64526384 // See https://stackoverflow.com/a/64526384
private listeners: Partial<Record<EventKeyType, Array<Listener<EventMessageType>>>>; private listeners: Partial<Record<EventKeyType, Listener<EventMessageType>[]>>;
public constructor() { public constructor() {
this.listeners = {}; this.listeners = {};
} }

View File

@@ -69,7 +69,7 @@ const markdownUtils = {
}, },
// Returns the **encoded** URLs, so to be useful they should be decoded again before use. // Returns the **encoded** URLs, so to be useful they should be decoded again before use.
extractFileUrls(md: string, onlyType: string = null): Array<string> { extractFileUrls(md: string, onlyType: string = null): string[] {
const markdownIt = new MarkdownIt(); const markdownIt = new MarkdownIt();
markdownIt.validateLink = validateLinks; // Necessary to support file:/// links markdownIt.validateLink = validateLinks; // Necessary to support file:/// links

View File

@@ -2082,7 +2082,7 @@ class Setting extends BaseModel {
// If yes, then it just returns 'true'. If its not present then, it will // If yes, then it just returns 'true'. If its not present then, it will
// update it and return 'false' // update it and return 'false'
public static setArrayValue(settingName: string, value: string): boolean { public static setArrayValue(settingName: string, value: string): boolean {
const settingValue: Array<any> = this.value(settingName); const settingValue: any[] = this.value(settingName);
if (settingValue.includes(value)) return true; if (settingValue.includes(value)) return true;
settingValue.push(value); settingValue.push(value);
this.setValue(settingName, settingValue); this.setValue(settingName, settingValue);

View File

@@ -10,7 +10,7 @@ const shared = require('../../../components/shared/config-shared.js');
const logger = Logger.create('defaultPluginsUtils'); const logger = Logger.create('defaultPluginsUtils');
export function checkPreInstalledDefaultPlugins(defaultPluginsId: string[], pluginSettings: PluginSettings) { export function checkPreInstalledDefaultPlugins(defaultPluginsId: string[], pluginSettings: PluginSettings) {
const installedDefaultPlugins: Array<string> = Setting.value('installedDefaultPlugins'); const installedDefaultPlugins: string[] = Setting.value('installedDefaultPlugins');
for (const pluginId of defaultPluginsId) { for (const pluginId of defaultPluginsId) {
// if pluginId is present in pluginSettings and not in installedDefaultPlugins array, // if pluginId is present in pluginSettings and not in installedDefaultPlugins array,
// then its either pre-installed by user or just uninstalled // then its either pre-installed by user or just uninstalled

View File

@@ -55,7 +55,7 @@ interface SafxInterface {
unlink(uriString: string): Promise<boolean>; unlink(uriString: string): Promise<boolean>;
mkdir(uriString: string): Promise<DocumentFileDetail>; mkdir(uriString: string): Promise<DocumentFileDetail>;
rename(uriString: string, newName: string): Promise<DocumentFileDetail>; rename(uriString: string, newName: string): Promise<DocumentFileDetail>;
getPersistedUriPermissions(): Promise<Array<string>>; getPersistedUriPermissions(): Promise<string[]>;
releasePersistableUriPermission(uriString: string): Promise<void>; releasePersistableUriPermission(uriString: string): Promise<void>;
listFiles(uriString: string): Promise<DocumentFileDetail[]>; listFiles(uriString: string): Promise<DocumentFileDetail[]>;
stat(uriString: string): Promise<DocumentFileDetail>; stat(uriString: string): Promise<DocumentFileDetail>;