Skip to content

Commit

Permalink
fix: linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Aug 6, 2020
1 parent 16bbf83 commit f375a30
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions core/store/src/state/context/document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export const DocumentContextProvider: FC<{ docId: string | undefined }> = ({
/**
* Retrieves a Document object from a document id
*/
export const useDocument = (docId: string) => {
export const useDocument = (docId?: string) => {
const store = useStore();
return store.docs[docId];
return docId ? store.docs[docId] : undefined;
};

export const useGetDocument = () => {
Expand Down
8 changes: 4 additions & 4 deletions plugins/axe-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
- [<ins>AxeAllyBlock</ins>](#insaxeallyblockins)
- [<ins>AxeContextProvider</ins>](#insaxecontextproviderins)
- [<ins>SelectionContextProvider</ins>](#insselectioncontextproviderins)
- [<ins>isTagSelected</ins>](#insistagselectedins)
- [<ins>useIsTagSelected</ins>](#insistagselectedins)
- [<ins>isSelected</ins>](#insisselectedins)
- [<ins>isTagSelected</ins>](#insistagselectedins-1)
- [<ins>useIsTagSelected</ins>](#insistagselectedins-1)
- [<ins>overview</ins>](#insoverviewins)

# In action
Expand Down Expand Up @@ -100,15 +100,15 @@ _AxeContextProvider [source code](https://github.com/ccontrols/component-control

_SelectionContextProvider [source code](https://github.com/ccontrols/component-controls/tree/master/plugins/axe-plugin/src/state/context.tsx)_

## <ins>isTagSelected</ins>
## <ins>useIsTagSelected</ins>

_isTagSelected [source code](https://github.com/ccontrols/component-controls/tree/master/plugins/axe-plugin/src/state/context.tsx)_

## <ins>isSelected</ins>

_isSelected [source code](https://github.com/ccontrols/component-controls/tree/master/plugins/axe-plugin/src/state/recoil.tsx)_

## <ins>isTagSelected</ins>
## <ins>useIsTagSelected</ins>

_isTagSelected [source code](https://github.com/ccontrols/component-controls/tree/master/plugins/axe-plugin/src/state/recoil.tsx)_

Expand Down
4 changes: 2 additions & 2 deletions plugins/axe-plugin/src/components/AllyDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import {
AxeContext,
useTaggedList,
SelectionContext,
isTagSelected,
useIsTagSelected,
} from '../state/context';

type StatsStatus = 'passes' | 'violations';

const TagSelectionCheckbox: FC<{ tag: string }> = ({ tag }) => {
const isSelected = isTagSelected(tag);
const isSelected = useIsTagSelected(tag);
const { selection, setSelection } = useContext(SelectionContext);
const tagged = useTaggedList();
const toggleTagSelected = (tag: string) => {
Expand Down
2 changes: 1 addition & 1 deletion plugins/axe-plugin/src/state/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const SelectionContextProvider: FC = ({ children }) => {
);
};

export const isTagSelected = (tag: string = '') => {
export const useIsTagSelected = (tag: string = '') => {
const tagged = useTaggedList();
const { selection } = useContext(SelectionContext);
return tagged[tag]
Expand Down
2 changes: 1 addition & 1 deletion plugins/axe-plugin/src/state/recoil.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const isSelected = (targets?: Selection) =>
},
});

export const isTagSelected = (tag: string = '') =>
export const useIsTagSelected = (tag: string = '') =>
selector<boolean>({
key: `isTagSelected_${tag}`,
get: ({ get }: any) => {
Expand Down
3 changes: 1 addition & 2 deletions ui/app/src/DocumentHomePage/DocumentHomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ export const DocumentHomePage: FC<DocumentHomePageProps> = ({ type }) => {
const config = useConfig();
const { categories } = config || {};
const isCategory = categories?.includes(type);
const pages = useSortedDocByType(type);
if (isCategory) {
return <CategoryList type={type} />;
}

const pages = useSortedDocByType(type);
const page = config.pages?.[type] || {};
if (page.indexHome) {
return (
Expand Down
2 changes: 1 addition & 1 deletion ui/blocks/src/StoryConfig/StoryConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const StoryConfig: FC<StoryConfigProps> = ({
}) => {
const story = useStory({ id, name });
const doc = useCurrentDocument();
const docPackage = doc && doc.package ? usePackage(doc.package) : undefined;
const docPackage = usePackage(doc?.package);
return (
<StoryBlockContainer {...rest}>
<BaseStoryConfig
Expand Down
2 changes: 1 addition & 1 deletion ui/blocks/src/StorySource/StorySource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const StorySource: FC<StorySourceProps> = ({
}) => {
const story = useStory({ id, name });
const doc = useCurrentDocument();
const docPackage = doc && doc.package ? usePackage(doc.package) : undefined;
const docPackage = usePackage(doc?.package);

return (
<StoryBlockContainer {...rest}>
Expand Down
2 changes: 1 addition & 1 deletion ui/blocks/src/Title/Title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const Title: FC<TitleProps> = ({ id, name, children, ...rest }) => {
id,
name,
});
const doc = story && story.doc ? useDocument(story.doc) : undefined;
const doc = useDocument(story?.doc);
const component = useStoryComponent({
id,
name,
Expand Down
3 changes: 2 additions & 1 deletion ui/components/src/Link/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import React, { FC, useMemo } from 'react';
import { LinkProps } from 'theme-ui';
import { ExternalLink } from '../ExternalLink';
import { useGetLinkClass } from './LinkContext';

export const Link: FC<LinkProps> = props => {
const { href } = props;
//https://stackoverflow.com/questions/10687099/how-to-test-if-a-url-string-is-absolute-or-relative/10687158
const r = useMemo(() => new RegExp('^(?:[a-z]+:)?//', 'i'), []);
const LinkClass = useGetLinkClass();
if (typeof href === 'string' && r.test(href)) {
//@ts-ignore
return <ExternalLink {...props} />;
}
const LinkClass = useGetLinkClass();
return <LinkClass {...props} />;
};
5 changes: 2 additions & 3 deletions ui/components/src/Navmenu/Navmenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,7 @@ export const Navmenu: FC<NavMenuProps> = ({

const renderItem = (item: MenuItem, level: number = 1) => {
const { expandedItems } = state;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { items, id, label, widget, icon, onClick, ...rest } = item;
const { items, id, label, widget, icon, ...rest } = item;
const itemId = id || label;
const isExpanded: boolean =
expandedItems && itemId ? expandedItems.includes(item) : false;
Expand All @@ -281,6 +280,7 @@ export const Navmenu: FC<NavMenuProps> = ({
textDecoration: 'none',
cursor: 'pointer',
}}
{...rest}
onClick={(e: any) => {
if (items) {
e.stopPropagation();
Expand All @@ -290,7 +290,6 @@ export const Navmenu: FC<NavMenuProps> = ({
}
}}
className={isActiveParent ? 'active' : undefined}
{...rest}
>
<Flex variant="navmenu.itemcontainer">
<Box variant="navmenu.iteminner">
Expand Down
1 change: 1 addition & 0 deletions ui/components/src/SearchInput/SearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export const SearchInput = <ItemType extends SearchInputItemType>({
break;
case TAB:
case ESC:
default:
updateIsOpen(false);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion ui/components/src/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
resetIdCounter,
} from 'react-tabs';

export { resetIdCounter as resetTabCounter };
export const resetTabCounter = resetIdCounter;
/**
* Tab heading - you should specify the title/label string as the children property. To be created inside the `<TabList />` component through the children prop.
*/
Expand Down

0 comments on commit f375a30

Please sign in to comment.