mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
rm explicit return types, misc. linting
This commit is contained in:
parent
c74a46288b
commit
d28459d3c1
10 changed files with 42 additions and 44 deletions
|
|
@ -27,18 +27,18 @@ export const App: React.FC = () =>
|
|||
</Layout>
|
||||
</Router>;
|
||||
|
||||
const Logo = (): JSX.Element =>
|
||||
const Logo = () =>
|
||||
<img src={`${process.env.PUBLIC_URL}/logo_filterlists.png`}
|
||||
alt="FilterLists logo"
|
||||
height="44px"
|
||||
style={{ background: '#fff' }} />;
|
||||
|
||||
const NotFound = (props: RouteComponentProps): JSX.Element =>
|
||||
const NotFound = (props: RouteComponentProps) =>
|
||||
<h2>
|
||||
404 Not Found: <code>{props.location.pathname}</code>
|
||||
</h2>;
|
||||
|
||||
const CopyrightAuthor = (): JSX.Element =>
|
||||
const CopyrightAuthor = () =>
|
||||
<span>
|
||||
©{new Date().getFullYear()}
|
||||
<a href="https://collinmbarrett.com"
|
||||
|
|
@ -47,28 +47,28 @@ const CopyrightAuthor = (): JSX.Element =>
|
|||
Collin M. Barrett</a>
|
||||
</span>;
|
||||
|
||||
const Community = (): JSX.Element =>
|
||||
const Community = () =>
|
||||
<a href="https://hub.filterlists.com"
|
||||
title="FilterLists Discourse community forum"
|
||||
target="_blank" rel="noopener noreferrer">
|
||||
Community
|
||||
</a>;
|
||||
|
||||
const GitHub = (): JSX.Element =>
|
||||
const GitHub = () =>
|
||||
<a href="https://github.com/collinbarrett/FilterLists"
|
||||
title="FilterLists git repository on GitHub"
|
||||
target="_blank" rel="noopener noreferrer">
|
||||
GitHub
|
||||
</a>;
|
||||
|
||||
const Api = (): JSX.Element =>
|
||||
const Api = () =>
|
||||
<a href="/api/v1/lists"
|
||||
title="FilterLists API lists endpoint"
|
||||
target="_blank" rel="noopener noreferrer">
|
||||
API
|
||||
</a>;
|
||||
|
||||
const Donate = (): JSX.Element =>
|
||||
const Donate = () =>
|
||||
<a href="https://beerpay.io/collinbarrett/FilterLists"
|
||||
title="Donate to FilterLists with Beerpay"
|
||||
target="_blank" rel="noopener noreferrer">
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ interface Props {
|
|||
descriptionSourceUrl: string;
|
||||
};
|
||||
|
||||
export const Description = (props: Props): JSX.Element =>
|
||||
export const Description = (props: Props) =>
|
||||
props.description
|
||||
? <blockquote cite={props.description}>{props.description}</blockquote>
|
||||
: <p>{props.description}</p>;
|
||||
|
|
@ -8,7 +8,7 @@ interface Props {
|
|||
showLabel?: boolean
|
||||
};
|
||||
|
||||
export const LicenseTag = (props: Props): JSX.Element | null =>
|
||||
export const LicenseTag = (props: Props) =>
|
||||
props.license && props.license.name
|
||||
? <div>
|
||||
{props.showLabel && <h3>License:</h3>}
|
||||
|
|
@ -18,7 +18,7 @@ export const LicenseTag = (props: Props): JSX.Element | null =>
|
|||
</div>
|
||||
: null;
|
||||
|
||||
const TagContents = (props: Props): JSX.Element =>
|
||||
const TagContents = (props: Props) =>
|
||||
props.license.descriptionUrl
|
||||
? <a href={props.license.descriptionUrl} target="_blank" rel="noopener noreferrer">
|
||||
{props.license.name}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ interface Props {
|
|||
list: List;
|
||||
};
|
||||
|
||||
export const ListInfoButton = (props: RouteComponentProps & Props): JSX.Element => {
|
||||
export const ListInfoButton = (props: RouteComponentProps & Props) => {
|
||||
const listPath = `/lists/${props.list.id}`;
|
||||
return <Button
|
||||
type="primary"
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ interface Props {
|
|||
viewUrlMirrors: string[];
|
||||
};
|
||||
|
||||
export const SubscribeButton = (props: Props): JSX.Element => {
|
||||
export const SubscribeButton = (props: Props) => {
|
||||
const buttonProps = buildButtonProps(props.name, props.viewUrl);
|
||||
return <span>
|
||||
<Button disabled={buttonProps[1]}
|
||||
|
|
|
|||
|
|
@ -1,23 +1,19 @@
|
|||
import { Tag } from 'antd';
|
||||
import React from 'react';
|
||||
|
||||
import { Language } from '../../interfaces/Language';
|
||||
import styles from './LanguageCloud.module.css';
|
||||
|
||||
interface LanguageData {
|
||||
iso6391: string;
|
||||
name: string;
|
||||
};
|
||||
|
||||
interface Props {
|
||||
languages: LanguageData[]
|
||||
languages: Language[]
|
||||
showLabel?: boolean
|
||||
};
|
||||
|
||||
export const LanguageCloud = (props: Props): JSX.Element | null =>
|
||||
export const LanguageCloud = (props: Props) =>
|
||||
props.languages && props.languages.length
|
||||
? <div className={styles.grow}>
|
||||
{props.showLabel && <h3>{`Language${props.languages.length > 1 ? "s" : ""}:`}</h3>}
|
||||
{props.languages.map((l: LanguageData, i: number) =>
|
||||
{props.languages.map((l: Language, i: number) =>
|
||||
<Tag key={i} title={l.name}>{l.iso6391}</Tag>)}
|
||||
</div>
|
||||
: null;
|
||||
|
|
@ -44,25 +44,38 @@ export class ListsTable extends React.Component<RouteComponentProps, State> {
|
|||
}
|
||||
|
||||
private fetchData() {
|
||||
this.fetchLists();
|
||||
this.fetchLanguages();
|
||||
this.fetchTags();
|
||||
this.fetchLicenses();
|
||||
}
|
||||
|
||||
private fetchLists() {
|
||||
fetch("/api/v1/lists")
|
||||
.then(response => response.json())
|
||||
.then(json => (json as List[]).sort((a, b) => a.name.localeCompare(b.name)))
|
||||
.then(lists => { this.setState({ lists: lists }); })
|
||||
.then(lists => { this.setState({ lists: lists }); });
|
||||
}
|
||||
|
||||
private fetchLanguages() {
|
||||
fetch("/api/v1/languages")
|
||||
.then(response => response.json())
|
||||
.then(json => (json as Language[]).sort((a, b) => a.name.localeCompare(b.name)))
|
||||
.then(languages => { this.setState({ languages: languages }); })
|
||||
.then(languages => { this.setState({ languages: languages }); });
|
||||
}
|
||||
|
||||
private fetchTags() {
|
||||
fetch("/api/v1/tags")
|
||||
.then(response => response.json())
|
||||
.then(json => (json as Tag[]).sort((a, b) => a.name.localeCompare(b.name)))
|
||||
.then(tags => { this.setState({ tags: tags }); })
|
||||
.then(tags => { this.setState({ tags: tags }); });
|
||||
}
|
||||
|
||||
private fetchLicenses() {
|
||||
fetch("/api/v1/licenses")
|
||||
.then(response => response.json())
|
||||
.then(json => (json as License[]).sort((a, b) => a.name.localeCompare(b.name)))
|
||||
.then(licenses => { this.setState({ licenses: licenses }); })
|
||||
.then(licenses => { this.setState({ licenses: licenses }); });
|
||||
}
|
||||
|
||||
private updatePageSize() {
|
||||
|
|
@ -80,16 +93,11 @@ export class ListsTable extends React.Component<RouteComponentProps, State> {
|
|||
rowKey={record => record.id.toString()}
|
||||
loading={this.state.lists.length ? false : true}
|
||||
size="small"
|
||||
pagination={{
|
||||
size: "small",
|
||||
simple: true,
|
||||
style: { float: "left" },
|
||||
pageSize: this.state.pageSize
|
||||
}}
|
||||
pagination={{ size: "small", simple: true, style: { float: "left" }, pageSize: this.state.pageSize }}
|
||||
scroll={{ x: this.state.isNarrowWindow ? undefined : 1200 }}>
|
||||
<Table.Column<List>
|
||||
title="Info"
|
||||
dataIndex={nameof<List>("viewUrl")}
|
||||
dataIndex={nameof<List>("id")}
|
||||
className={styles.nogrow}
|
||||
fixed="left"
|
||||
render={(_text: string, record: List) => <ListInfoButton list={record} {...this.props} />} />
|
||||
|
|
@ -124,10 +132,7 @@ export class ListsTable extends React.Component<RouteComponentProps, State> {
|
|||
sorter={(a, b) => arraySorter(a.languageIds, b.languageIds, this.state.languages)}
|
||||
width={125}
|
||||
className={styles.nogrow}
|
||||
render={(languageIds: number[]) =>
|
||||
languageIds
|
||||
? <LanguageCloud languages={this.state.languages.filter((l: Language) => languageIds.includes(l.id))} />
|
||||
: null} />}
|
||||
render={(languageIds: number[]) => languageIds ? <LanguageCloud languages={this.state.languages.filter((l: Language) => languageIds.includes(l.id))} /> : null} />}
|
||||
{this.state.isNarrowWindow
|
||||
? null
|
||||
: <Table.Column<List>
|
||||
|
|
@ -136,10 +141,7 @@ export class ListsTable extends React.Component<RouteComponentProps, State> {
|
|||
sorter={(a, b) => arraySorter(a.tagIds, b.tagIds, this.state.tags)}
|
||||
width={275}
|
||||
className={styles.nogrow}
|
||||
render={(tagIds: number[]) =>
|
||||
tagIds
|
||||
? <TagCloud tags={this.state.tags.filter((t: Tag) => tagIds.includes(t.id))} />
|
||||
: null} />}
|
||||
render={(tagIds: number[]) => tagIds ? <TagCloud tags={this.state.tags.filter((t: Tag) => tagIds.includes(t.id))} /> : null} />}
|
||||
</Table>
|
||||
<Route path="/lists/:id" render={props => {
|
||||
const list = this.state.lists.find(l => l.id === +props.match.params.id);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ interface Props {
|
|||
showLabel?: boolean
|
||||
};
|
||||
|
||||
export const TagCloud = (props: Props): JSX.Element | null =>
|
||||
export const TagCloud = (props: Props) =>
|
||||
props.tags && props.tags.length
|
||||
? <div className={styles.grow}>
|
||||
{props.showLabel && <h3>{`Tag${props.tags.length > 1 ? "s" : ""}:`}</h3>}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
body {
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
||||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
|
||||
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
|
||||
sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
|
||||
monospace;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
//https://stackoverflow.com/a/50470026/2343739
|
||||
export const nameof = <T>(name: Extract<keyof T, string>): string => name;
|
||||
export const nameof = <T>(name: Extract<keyof T, string>) => name;
|
||||
Loading…
Reference in a new issue