fix-linting-errors

This commit is contained in:
SleeplessOne1917 2023-08-03 23:28:30 -04:00
parent 3ec08b1479
commit e9b1a8324f
2 changed files with 13 additions and 17 deletions

View file

@ -8,12 +8,12 @@ fs.readdir(translationDir, (_err, files) => {
const lang = filename.split(".")[0];
try {
const json = JSON.parse(
fs.readFileSync(translationDir + filename, "utf8")
fs.readFileSync(translationDir + filename, "utf8"),
);
let data = `export const ${lang} = {\n translation: {`;
for (const key in json) {
if (key in json) {
const value = json[key].replace(/"/g, '\\"');
const value = json[key].replace(/"/g, '\\"').replace("\n", "\\n");
data += `\n ${key}: "${value}",`;
}
}
@ -67,14 +67,14 @@ ${optionKeys.map(key => `${indent}| "${key}"`).join("\n")};
export type I18nKeys = NoOptionI18nKeys | OptionI18nKeys;
export type TTypedOptions<TKey extends OptionI18nKeys> =${Array.from(
optionMap.entries()
optionMap.entries(),
).reduce(
(acc, [key, options]) =>
`${acc} TKey extends \"${key}\" ? ${
options.reduce((acc, cur) => acc + `${cur}: string | number; `, "{ ") +
"}"
} :\n${indent}`,
""
"",
)} (Record<string, unknown> | string);
export interface TFunctionTyped {

View file

@ -17,7 +17,7 @@ import {
restoreScrollPosition,
saveScrollPosition,
} from "@utils/browser";
import { debounce, randomStr } from "@utils/helpers";
import { debounce, getIdFromString, randomStr } from "@utils/helpers";
import { isImage } from "@utils/media";
import { RouteDataResponse } from "@utils/types";
import autosize from "autosize";
@ -90,13 +90,12 @@ import { HtmlTags } from "../common/html-tags";
import { Icon, Spinner } from "../common/icon";
import { Sidebar } from "../community/sidebar";
import { PostListing } from "./post-listing";
import { RouteComponentProps } from "inferno-router/dist/Route";
const commentsShownInterval = 15;
interface PostParams {
post_id?: number;
comment_id?: number;
post_id?: string;
comment_id?: string;
}
type PostData = RouteDataResponse<{
postRes: GetPostResponse;
@ -117,10 +116,7 @@ interface PostState {
isIsomorphic: boolean;
}
export class Post extends Component<
RouteComponentProps<PostParams>,
PostState
> {
export class Post extends Component<any, PostState> {
private isoData = setIsoData<PostData>(this.context);
private commentScrollDebounced: () => void;
state: PostState = {
@ -201,17 +197,17 @@ export class Post extends Component<
});
const auth = myAuth();
const { post_id, comment_id } = this.props.match.params;
const { post_id, comment_id } = this.props.match.params as PostParams;
this.setState({
postRes: await HttpService.client.getPost({
id: post_id,
comment_id: comment_id,
id: getIdFromString(post_id),
comment_id: getIdFromString(comment_id),
auth,
}),
commentsRes: await HttpService.client.getComments({
post_id: this.props.match.params.post_id,
parent_id: comment_id,
post_id: getIdFromString(post_id),
parent_id: getIdFromString(comment_id),
max_depth: commentTreeMaxDepth,
sort: this.state.commentSort,
type_: "All",