minor linting

This commit is contained in:
Collin M. Barrett 2019-08-31 17:13:07 -05:00
parent 043c2790d9
commit da549da826
18 changed files with 71 additions and 70 deletions

View file

@ -20,4 +20,4 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
yarn-error.log*

Binary file not shown.

View file

@ -39,4 +39,4 @@
"last 1 safari version"
]
}
}
}

View file

@ -53,25 +53,25 @@ const Community = () =>
title="FilterLists Discourse community forum"
target="_blank" rel="noopener noreferrer">
Community
</a>;
</a>;
const GitHub = () =>
<a href="https://github.com/collinbarrett/FilterLists"
title="FilterLists git repository on GitHub"
target="_blank" rel="noopener noreferrer">
GitHub
</a>;
</a>;
const Api = () =>
<a href="/api/v1/lists"
title="FilterLists API lists endpoint"
target="_blank" rel="noopener noreferrer">
API
</a>;
</a>;
const Donate = () =>
<a href="https://beerpay.io/collinbarrett/FilterLists"
title="Donate to FilterLists with Beerpay"
target="_blank" rel="noopener noreferrer">
Donate
</a>;
</a>;

View file

@ -23,4 +23,6 @@ const TagContents = (props: Props) =>
? <a href={props.license.descriptionUrl} target="_blank" rel="noopener noreferrer">
{props.license.name}
</a>
: <span>{props.license.name}</span>
: <>
{props.license.name}
</>;

View file

@ -10,12 +10,14 @@ interface Props {
export const ListInfoButton = (props: RouteComponentProps & Props) => {
const listPath = `/lists/${props.list.id}`;
return <Button
type="primary"
title={`View more information about ${props.list.name}.`}
onClick={() => props.location.pathname === listPath
? props.history.push("/")
: props.history.push(listPath)} >
<Icon type="info-circle" />
</Button>
return (
<Button
type="primary"
title={`View more information about ${props.list.name}.`}
onClick={() => props.location.pathname === listPath
? props.history.push("/")
: props.history.push(listPath)} >
<Icon type="info-circle" />
</Button>
);
};

View file

@ -23,15 +23,11 @@ interface Props {
export const ListInfoDrawer = (props: RouteComponentProps & Props) => {
const [originalTitle] = useState<string>(document.title);
useEffect(() => {
const updateTitle = () => {
document.title = props.list.name + " | " + originalTitle;
}
const updateTitle = () => document.title = props.list.name + " | " + originalTitle;
updateTitle();
return () => { document.title = originalTitle; }
return () => { document.title = originalTitle; };
}, [props.list, originalTitle]);
return (
<Drawer
visible={true}
@ -107,5 +103,5 @@ export const ListInfoDrawer = (props: RouteComponentProps & Props) => {
icon="dollar" />}
</ButtonGroup>
</Drawer>
)
}
);
};

View file

@ -23,7 +23,7 @@ const PrimaryButton = (props: Props) => {
{...buttonProps[0]}>
Subscribe
</Button>
)
);
};
const MirrorButtons = (props: Props) =>
@ -39,7 +39,7 @@ interface MirrorButtonProps {
index: number;
viewUrlMirror: string;
name: string;
}
};
const MirrorButton = (props: MirrorButtonProps) => {
const buttonProps = buildButtonProps(props.name, props.viewUrlMirror);
@ -52,8 +52,8 @@ const MirrorButton = (props: MirrorButtonProps) => {
{...buttonProps[0]}>
{`Subscribe (Mirror ${props.index + 1})`}
</Button>
)
}
);
};
const buildButtonProps = (name: string, viewUrl: string): [ButtonProps, boolean] => {
let type: ButtonType = "primary";
@ -70,22 +70,22 @@ const buildButtonProps = (name: string, viewUrl: string): [ButtonProps, boolean]
if (viewUrl.includes(".onion/")) {
type = "dashed";
prefixes.push("TOR");
}
};
if (viewUrl.includes("http://")) {
type = "danger";
prefixes.push("INSECURE");
}
};
// Software protocols
if (viewUrl.includes(".tpl")) {
disabled = true; // IE not supported by FilterLists
}
};
if (viewUrl.includes(".lsrules") || viewUrl.includes("?hostformat=littlesnitch")) {
href = `x-littlesnitch:subscribe-rules?url=${hrefLocation}`;
message = `Subscribe to ${name} with Little Snitch's rule group subscription feature.`;
}
};
const title = `${prefixes.length ? prefixes.join(" | ") + " | " : ""}${message}`;
return [{ type, href, title }, disabled]
}
return [{ type, href, title }, disabled];
};

View file

@ -5,8 +5,8 @@ import { Language } from '../../interfaces/Language';
import styles from './LanguageCloud.module.css';
interface Props {
languages: Language[]
showLabel?: boolean
languages: Language[];
showLabel?: boolean;
};
export const LanguageCloud = (props: Props) =>

View file

@ -12,7 +12,7 @@ interface Props {
languages: Language[];
licenses: License[];
tags: Tag[];
}
};
export const ListDrawer = (props: Props) => {
const renderDrawer = (rp: RouteComponentProps<any, StaticContext, any>) => {
@ -24,7 +24,7 @@ export const ListDrawer = (props: Props) => {
license={list.licenseId ? props.licenses.find((l: License) => list.licenseId === l.id) : undefined}
tags={list.tagIds && props.tags.filter((t: Tag) => list.tagIds.includes(t.id))}
{...rp} />
: props.lists && props.lists.length && <Redirect to={{ pathname: "/", }} />
: props.lists && props.lists.length && <Redirect to={{ pathname: "/", }} />;
};
return <Route path="/lists/:id" render={renderDrawer} />
}
return <Route path="/lists/:id" render={renderDrawer} />;
};

View file

@ -20,7 +20,7 @@ interface Props {
languages: Language[];
licenses: License[];
tags: Tag[];
}
};
export const ListsTable = (props: RouteComponentProps & Props) => {
const tablePageSize = useTablePageSizer();
@ -80,5 +80,5 @@ export const ListsTable = (props: RouteComponentProps & Props) => {
className={styles.nogrow}
render={(tagIds: number[]) => tagIds ? <TagCloud tags={props.tags.filter((t: Tag) => tagIds.includes(t.id))} /> : null} />}
</Table>
)
}
);
};

View file

@ -15,5 +15,5 @@ export const ListsTableHoc = (props: RouteComponentProps) => {
<ListsTable lists={lists} languages={languages} licenses={licenses} tags={tags} {...props} />
<ListDrawer lists={lists} languages={languages} licenses={licenses} tags={tags} />
</>
)
}
);
};

View file

@ -1,17 +1,18 @@
interface ArraySortableEntity {
id: number;
name: string;
}
};
export const arraySorter = (a: number[], b: number[], entities: ArraySortableEntity[]): number => a && a.length
? b && b.length
? a.length === b.length
? entities.filter((e: ArraySortableEntity) => a.indexOf(e.id) > -1).map((e: ArraySortableEntity) => e.name).join().toLowerCase()
> entities.filter((e: ArraySortableEntity) => b.indexOf(e.id) > -1).map((e: ArraySortableEntity) => e.name).join().toLowerCase()
? 1
: -1
: a.length > b.length
? -1
: 1
: -1
: 1;
export const arraySorter = (a: number[], b: number[], entities: ArraySortableEntity[]) =>
a && a.length
? b && b.length
? a.length === b.length
? entities.filter((e: ArraySortableEntity) => a.indexOf(e.id) > -1).map((e: ArraySortableEntity) => e.name).join().toLowerCase()
> entities.filter((e: ArraySortableEntity) => b.indexOf(e.id) > -1).map((e: ArraySortableEntity) => e.name).join().toLowerCase()
? 1
: -1
: a.length > b.length
? -1
: 1
: -1
: 1;

View file

@ -1,3 +1,3 @@
import { ListsTableHoc } from './ListsTableHoc';
export { ListsTableHoc as ListsTable }
export { ListsTableHoc as ListsTable };

View file

@ -5,8 +5,8 @@ import { Tag as TagInterface } from '../../interfaces/Tag';
import styles from './TagCloud.module.css';
interface Props {
tags: TagInterface[]
showLabel?: boolean
tags: TagInterface[];
showLabel?: boolean;
};
export const TagCloud = (props: Props) =>

View file

@ -3,11 +3,10 @@ import { useEffect, useState } from 'react';
export const useApiData = <T extends {}>(url: string) => {
const [data, setData] = useState<T>();
useEffect(() => {
const fetchData = async () => {
const fetchData = async () =>
(await fetch(url))
.json()
.then(r => setData(r));
};
fetchData();
}, [url]);
return data;

View file

@ -3,18 +3,19 @@ import { useEffect, useState } from 'react';
interface TablePageSize {
pageSize: number;
isNarrowWindow: boolean;
}
};
export const useTablePageSizer = () => {
const calculateSize = () => ({
pageSize: Math.floor((window.innerHeight - 211.5) / 56),
isNarrowWindow: window.innerWidth < 576 ? true : false
});
const [state, setState] = useState<TablePageSize>(calculateSize());
useEffect(() => {
const updatePageSize = () => setState(calculateSize())
const updatePageSize = () => setState(calculateSize());
window.addEventListener('resize', updatePageSize);
return () => window.removeEventListener('resize', updatePageSize);
}, []);
return state;
}
};
const calculateSize = () => ({
pageSize: Math.floor((window.innerHeight - 211.5) / 56),
isNarrowWindow: window.innerWidth < 576 ? true : false
});

View file

@ -1,3 +1,3 @@
import { nameof } from './nameof';
export { nameof }
export { nameof };