Skip to content

Commit

Permalink
style: fix eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
prinsss committed Jan 4, 2024
1 parent a18c6ea commit 1c97af5
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/components/table/columns-tweet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const columns = [
class="link"
onClick={() =>
info.table.options.meta?.setRawDataPreview(
extractTweetFullText(info.row.original) as any,
extractTweetFullText(info.row.original) as unknown as Tweet,
)
}
>
Expand Down
1 change: 1 addition & 0 deletions src/components/table/pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from '@tabler/icons-preact';

type PaginationProps = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
table: Table<any>;
};

Expand Down
2 changes: 2 additions & 0 deletions src/components/table/table-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ declare module '@tanstack/table-core' {
setRawDataPreview: (data: TData | null) => void;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface ColumnMeta<TData extends RowData, TValue> {
exportable?: boolean;
exportKey?: string;
exportHeader?: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
exportValue?: (row: Row<TData>) => any;
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/core/extensions/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export class ExtensionManager {
* This need to be done before any XHR request is made.
*/
private installHttpHooks() {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const manager = this;

unsafeWindow.XMLHttpRequest.prototype.open = function (method: string, url: string) {
Expand All @@ -128,6 +129,7 @@ export class ExtensionManager {
});

// @ts-expect-error it's fine.
// eslint-disable-next-line prefer-rest-params
xhrOpen.apply(this, arguments);
};

Expand Down
6 changes: 1 addition & 5 deletions src/modules/user-media/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import {
TimelineTweet,
Tweet,
} from '@/types';
import {
extractTimelineTweet,
isTimelineEntryProfileGrid,
isTimelineEntryTweet,
} from '@/utils/api';
import { extractTimelineTweet, isTimelineEntryProfileGrid } from '@/utils/api';
import logger from '@/utils/logger';

// The global store for "UserMedia".
Expand Down
3 changes: 2 additions & 1 deletion src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ export function useToggle(defaultValue = false) {
* @example
* cx('foo', 'bar', false && 'baz') // => 'foo bar'
*/
export function cx(...classNames: any[]) {
export function cx(...classNames: (string | boolean | undefined)[]) {
return classNames.filter(Boolean).join(' ');
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function isEqual(obj1: any, obj2: any) {
return JSON.stringify(obj1) === JSON.stringify(obj2);
}
Expand Down
2 changes: 2 additions & 0 deletions src/utils/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export async function zipStreamDownload(

// Add files to zip archive stream.
const readableZipStream: ReadableStream = createWriter({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async pull(ctrl: any) {
const fileInfo = fileIterator.next();
if (fileInfo.done) {
Expand Down Expand Up @@ -64,6 +65,7 @@ export async function zipStreamDownload(
},
});

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const chunks: any[] = [];
const writableOutputStream = new WritableStream({
write(chunk) {
Expand Down
3 changes: 2 additions & 1 deletion src/utils/exporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ export const EXPORT_FORMAT = {

export type ExportFormatType = (typeof EXPORT_FORMAT)[keyof typeof EXPORT_FORMAT];

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type DataType = Record<string, any>;

/**
* Escape characters for CSV file.
*/
export function csvEscapeStr(str: string) {
return `"${str.replace(/\"/g, '""').replace(/\n/g, '\\n').replace(/\r/g, '\\r')}"`;
return `"${str.replace(/"/g, '""').replace(/\n/g, '\\n').replace(/\r/g, '\\r')}"`;
}

/**
Expand Down
13 changes: 8 additions & 5 deletions src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export interface LogLine {

export const logLinesSignal = signal<LogLine[]>([]);

// eslint-disable-next-line @typescript-eslint/no-explicit-any
type LogExtraArgs = any[];

/**
* Global logger that writes logs to both screen and console.
*/
Expand All @@ -16,22 +19,22 @@ class Logger {
private buffer: LogLine[] = [];
private bufferTimer: number | null = null;

public info(line: string, ...args: any[]) {
public info(line: string, ...args: LogExtraArgs) {
console.info('[twitter-web-exporter]', line, ...args);
this.writeBuffer({ type: 'info', line, index: this.index++ });
}

public warn(line: string, ...args: any[]) {
public warn(line: string, ...args: LogExtraArgs) {
console.warn('[twitter-web-exporter]', line, ...args);
this.writeBuffer({ type: 'warn', line, index: this.index++ });
}

public error(line: string, ...args: any[]) {
public error(line: string, ...args: LogExtraArgs) {
console.error('[twitter-web-exporter]', line, ...args);
this.writeBuffer({ type: 'error', line, index: this.index++ });
}

public errorWithBanner(msg: string, err?: Error, ...args: any[]) {
public errorWithBanner(msg: string, err?: Error, ...args: LogExtraArgs) {
this.error(
`${msg} (Message: ${err?.message ?? 'none'})\n` +
' This may be a problem caused by Twitter updates.\n Please file an issue on GitHub:\n' +
Expand All @@ -40,7 +43,7 @@ class Logger {
);
}

public debug(...args: any[]) {
public debug(...args: LogExtraArgs) {
console.debug('[twitter-web-exporter]', ...args);
}

Expand Down
1 change: 1 addition & 0 deletions src/utils/zip-stream.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-var, @typescript-eslint/ban-ts-comment */
// @ts-nocheck
/**
* This file zip-stream.ts is copied from StreamSaver.js.
Expand Down

0 comments on commit 1c97af5

Please sign in to comment.