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

Tools: Implement @typescript-eslint/no-explicit-any rule

This commit is contained in:
Laurent Cozic
2024-04-05 12:16:49 +01:00
parent 42900bcc66
commit 2e2a2b3193
654 changed files with 2971 additions and 170 deletions

View File

@@ -40,7 +40,9 @@ export const testData = {
},
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
export async function createTestData(data: any) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
async function recurseStruct(s: any, parentId = '') {
for (const n in s) {
if (n.toLowerCase().includes('folder')) {
@@ -64,7 +66,9 @@ export async function createTestData(data: any) {
await recurseStruct(data);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
export async function checkTestData(data: any) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
async function recurseCheck(s: any) {
for (const n in s) {
const obj = s[n];

View File

@@ -38,7 +38,7 @@ export async function remoteResources() {
return remoteItemsByTypes([BaseModel.TYPE_RESOURCE]);
}
// eslint-disable-next-line @typescript-eslint/ban-types -- Old code before rule was applied
// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-explicit-any -- Old code before rule was applied, Old code before rule was applied
export async function localNotesFoldersSameAsRemote(locals: any[], expect: Function) {
let error = null;
try {

View File

@@ -268,6 +268,7 @@ const settingFilename = (id: number): string => {
return `settings-${id}.json`;
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
async function switchClient(id: number, options: any = null) {
options = { keychainEnabled: false, ...options };
@@ -335,6 +336,7 @@ async function clearDatabase(id: number = null) {
await databases_[id].transactionExecBatch(queries);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
async function setupDatabase(id: number = null, options: any = null) {
options = { keychainEnabled: false, ...options };
@@ -385,6 +387,7 @@ async function clearSettingFile(id: number) {
await fs.remove(Setting.settingFilePath);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
export async function createFolderTree(parentId: string, tree: any[], num = 0): Promise<FolderEntity> {
let rootFolder: FolderEntity = null;
@@ -445,6 +448,7 @@ const createNoteAndResource = async (options: CreateNoteAndResourceOptions = nul
return { note, resource };
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
async function setupDatabaseAndSynchronizer(id: number, options: any = null) {
if (id === null) id = currentClient_;
@@ -503,6 +507,7 @@ function synchronizer(id: number = null) {
// This is like calling synchronizer.start() but it handles the
// complexity of passing around the sync context depending on
// the client.
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
async function synchronizerStart(id: number = null, extraOptions: any = null) {
if (id === null) id = currentClient_;
@@ -703,6 +708,7 @@ function fileApi() {
return fileApis_[syncTargetId_];
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
function objectsEqual(o1: any, o2: any) {
if (Object.getOwnPropertyNames(o1).length !== Object.getOwnPropertyNames(o2).length) return false;
for (const n in o1) {
@@ -723,7 +729,7 @@ async function checkThrowAsync(asyncFn: Function) {
return hasThrown;
}
// eslint-disable-next-line @typescript-eslint/ban-types -- Old code before rule was applied
// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-explicit-any -- Old code before rule was applied, Old code before rule was applied
async function expectThrow(asyncFn: Function, errorCode: any = undefined, errorMessage: string = undefined) {
let hasThrown = false;
let thrownError = null;
@@ -817,18 +823,22 @@ async function allSyncTargetItemsEncrypted() {
return totalCount === encryptedCount;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
function id(a: any) {
return a.id;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
function ids(a: any[]) {
return a.map(n => n.id);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
function sortedIds(a: any[]) {
return ids(a).sort();
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
function at(a: any[], indexes: any[]) {
const out = [];
for (let i = 0; i < indexes.length; i++) {
@@ -847,6 +857,7 @@ async function createNTestFolders(n: number) {
return folders;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
async function createNTestNotes(n: number, folder: any, tagIds: string[] = null, title = 'note') {
const notes = [];
for (let i = 0; i < n; i++) {
@@ -932,6 +943,7 @@ export async function naughtyStrings() {
class TestApp extends BaseApplication {
private hasGui_: boolean;
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
private middlewareCalls_: any[];
private logger_: LoggerWrapper;
@@ -948,6 +960,7 @@ class TestApp extends BaseApplication {
return this.hasGui_;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
public async start(argv: any[]) {
this.logger_.info('Test app starting...');
@@ -969,6 +982,7 @@ class TestApp extends BaseApplication {
this.logger_.info('Test app started...');
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
public async generalMiddleware(store: any, next: any, action: any) {
this.middlewareCalls_.push(true);
try {