diff --git a/.eslintrc b/.eslintrc index f5e6138229e..76172858245 100644 --- a/.eslintrc +++ b/.eslintrc @@ -3,7 +3,7 @@ "root": true, "overrides": [ { - "files": ["packages/grafana-ui/**/*.{ts,tsx}", "public/app/**/*.{ts,tsx}"], + "files": ["packages/grafana-ui/**/*/!(*.story).{ts,tsx}", "public/app/**/*.{ts,tsx}"], "rules": { "react-hooks/rules-of-hooks": "off", "react-hooks/exhaustive-deps": "off" diff --git a/packages/grafana-ui/src/components/FileUpload/FileUpload.story.tsx b/packages/grafana-ui/src/components/FileUpload/FileUpload.story.tsx index 8937b07bad0..205c469c71c 100644 --- a/packages/grafana-ui/src/components/FileUpload/FileUpload.story.tsx +++ b/packages/grafana-ui/src/components/FileUpload/FileUpload.story.tsx @@ -16,7 +16,7 @@ export default { }, }; -export const single = () => { +export const Single = () => { const size = useSize(); return ( { +export const Controlled = () => { const [checked, setChecked] = useState(false); const onChange = useCallback(e => setChecked(e.currentTarget.checked), [setChecked]); return ( diff --git a/packages/grafana-ui/src/components/Forms/Field.story.tsx b/packages/grafana-ui/src/components/Forms/Field.story.tsx index 9c3d7ce53e1..8fc8bdaf672 100644 --- a/packages/grafana-ui/src/components/Forms/Field.story.tsx +++ b/packages/grafana-ui/src/components/Forms/Field.story.tsx @@ -37,7 +37,7 @@ const getKnobs = () => { return { containerWidth, disabled, invalid, loading, error }; }; -export const simple = () => { +export const Simple = () => { const { containerWidth, ...otherProps } = getKnobs(); return (
@@ -48,7 +48,7 @@ export const simple = () => { ); }; -export const horizontalLayout = () => { +export const HorizontalLayout = () => { const [checked, setChecked] = useState(false); const onChange = useCallback(e => setChecked(e.currentTarget.checked), [setChecked]); const { containerWidth, ...otherProps } = getKnobs(); diff --git a/packages/grafana-ui/src/components/Forms/Form.story.tsx b/packages/grafana-ui/src/components/Forms/Form.story.tsx index 5d415902b58..ded2eb74857 100644 --- a/packages/grafana-ui/src/components/Forms/Form.story.tsx +++ b/packages/grafana-ui/src/components/Forms/Form.story.tsx @@ -120,11 +120,11 @@ const renderForm = (defaultValues?: Partial) => ( ); -export const basic = () => { +export const Basic = () => { return <>{renderForm()}; }; -export const defaultValues = () => { +export const DefaultValues = () => { const defaultValues = [ { name: 'Roger Waters', @@ -162,7 +162,7 @@ export const defaultValues = () => { ); }; -export const asyncValidation = () => { +export const AsyncValidation = () => { const passAsyncValidation = boolean('Pass username validation', true); return ( <> diff --git a/packages/grafana-ui/src/components/Forms/Legacy/Select/Select.story.internal.tsx b/packages/grafana-ui/src/components/Forms/Legacy/Select/Select.story.internal.tsx index 81a4b5e8fab..97748500b70 100644 --- a/packages/grafana-ui/src/components/Forms/Legacy/Select/Select.story.internal.tsx +++ b/packages/grafana-ui/src/components/Forms/Legacy/Select/Select.story.internal.tsx @@ -4,7 +4,7 @@ import { withKnobs, object } from '@storybook/addon-knobs'; import { withCenteredStory } from '../../../../utils/storybook/withCenteredStory'; import { UseState } from '../../../../utils/storybook/UseState'; import { SelectableValue } from '@grafana/data'; -import { Select, AsyncSelect } from './Select'; +import { Select, AsyncSelect as AsyncSelectComponent } from './Select'; export default { title: 'Forms/Legacy/Select', @@ -70,22 +70,19 @@ export const withAllowCustomValue = () => { ); }; -export const asyncSelect = () => { +export const AsyncSelect = () => { const [isLoading, setIsLoading] = useState(true); const [value, setValue] = useState>(); - const loadAsyncOptions = useCallback( - inputValue => { - return new Promise>>(resolve => { - setTimeout(() => { - setIsLoading(false); - resolve(options.filter(option => option.label && option.label.includes(inputValue))); - }, 1000); - }); - }, - [value] - ); + const loadAsyncOptions = useCallback(inputValue => { + return new Promise>>(resolve => { + setTimeout(() => { + setIsLoading(false); + resolve(options.filter(option => option.label && option.label.includes(inputValue))); + }, 1000); + }); + }, []); return ( - { +export const Simple = () => { const [selected, setSelected] = useState('graphite'); const BEHAVIOUR_GROUP = 'Behaviour props'; const disabled = boolean('Disabled', false, BEHAVIOUR_GROUP); @@ -42,7 +42,7 @@ export const simple = () => { ); }; -export const fullWidth = () => { +export const FullWidth = () => { const [selected, setSelected] = useState('elastic'); const BEHAVIOUR_GROUP = 'Behaviour props'; const disabled = boolean('Disabled', false, BEHAVIOUR_GROUP); diff --git a/packages/grafana-ui/src/components/Icon/Icon.story.tsx b/packages/grafana-ui/src/components/Icon/Icon.story.tsx index 4d8873fbe55..ccccb941e31 100644 --- a/packages/grafana-ui/src/components/Icon/Icon.story.tsx +++ b/packages/grafana-ui/src/components/Icon/Icon.story.tsx @@ -61,7 +61,7 @@ const IconWrapper: React.FC<{ name: IconName }> = ({ name }) => { const icons = getAvailableIcons().sort((a, b) => a.localeCompare(b)); -export const iconsOverview = () => { +export const IconsOverview = () => { const [filter, setFilter] = useState(''); const searchIcon = (event: ChangeEvent) => { diff --git a/packages/grafana-ui/src/components/IconButton/IconButton.story.tsx b/packages/grafana-ui/src/components/IconButton/IconButton.story.tsx index 79c253952ae..b6128cee333 100644 --- a/packages/grafana-ui/src/components/IconButton/IconButton.story.tsx +++ b/packages/grafana-ui/src/components/IconButton/IconButton.story.tsx @@ -15,7 +15,7 @@ export default { }, }; -export const simple = () => { +export const Simple = () => { const theme = useTheme(); return ( diff --git a/packages/grafana-ui/src/components/Input/Input.story.tsx b/packages/grafana-ui/src/components/Input/Input.story.tsx index 75f20dc09f3..a4a575ebb13 100644 --- a/packages/grafana-ui/src/components/Input/Input.story.tsx +++ b/packages/grafana-ui/src/components/Input/Input.story.tsx @@ -17,7 +17,7 @@ export default { }, }; -export const simple = () => { +export const Simple = () => { const prefixSuffixOpts = { None: null, Text: '$', @@ -96,7 +96,7 @@ export const simple = () => { ); }; -export const withFieldValidation = () => { +export const WithFieldValidation = () => { const [value, setValue] = useState(''); return ( diff --git a/packages/grafana-ui/src/components/Modal/Modal.story.tsx b/packages/grafana-ui/src/components/Modal/Modal.story.tsx index 0222507dc5e..66233da8ef6 100644 --- a/packages/grafana-ui/src/components/Modal/Modal.story.tsx +++ b/packages/grafana-ui/src/components/Modal/Modal.story.tsx @@ -58,7 +58,7 @@ const tabs = [ { label: '3rd child', value: 'third', active: false }, ]; -export const withTabs = () => { +export const WithTabs = () => { const [activeTab, setActiveTab] = useState('first'); const modalHeader = ( { }; }; -export const basic = () => { +export const Basic = () => { const [value, setValue] = useState>(); return ( @@ -107,7 +107,7 @@ export const basic = () => { /** * Uses plain values instead of SelectableValue */ -export const basicSelectPlainValue = () => { +export const BasicSelectPlainValue = () => { const [value, setValue] = useState(); return ( <> @@ -158,7 +158,7 @@ export const SelectWithOptionDescriptions = () => { /** * Uses plain values instead of SelectableValue */ -export const multiPlainValue = () => { +export const MultiPlainValue = () => { const [value, setValue] = useState(); return ( @@ -175,7 +175,7 @@ export const multiPlainValue = () => { ); }; -export const multiSelect = () => { +export const MultiSelectBasic = () => { const [value, setValue] = useState>>([]); return ( @@ -193,7 +193,7 @@ export const multiSelect = () => { ); }; -export const multiSelectAsync = () => { +export const MultiSelectAsync = () => { const [value, setValue] = useState>>(); return ( @@ -209,7 +209,7 @@ export const multiSelectAsync = () => { /> ); }; -export const buttonSelect = () => { +export const ButtonSelectBasic = () => { const [value, setValue] = useState>(); const icon = getIconKnob(); return ( @@ -227,7 +227,7 @@ export const buttonSelect = () => { ); }; -export const basicSelectAsync = () => { +export const BasicSelectAsync = () => { const [value, setValue] = useState>(); return ( @@ -243,7 +243,7 @@ export const basicSelectAsync = () => { ); }; -export const customizedControl = () => { +export const CustomizedControl = () => { const [value, setValue] = useState>(); return ( @@ -266,7 +266,7 @@ export const customizedControl = () => { ); }; -export const autoMenuPlacement = () => { +export const AutoMenuPlacement = () => { const [value, setValue] = useState>(); return ( @@ -285,7 +285,7 @@ export const autoMenuPlacement = () => { ); }; -export const customValueCreation = () => { +export const CustomValueCreation = () => { const [value, setValue] = useState>(); const [customOptions, setCustomOptions] = useState>>([]); const options = generateOptions(); diff --git a/packages/grafana-ui/src/components/Switch/Switch.story.tsx b/packages/grafana-ui/src/components/Switch/Switch.story.tsx index 66606a4028a..e567dbdf1d3 100644 --- a/packages/grafana-ui/src/components/Switch/Switch.story.tsx +++ b/packages/grafana-ui/src/components/Switch/Switch.story.tsx @@ -15,7 +15,7 @@ export default { }, }; -export const controlled = () => { +export const Controlled = () => { const [checked, setChecked] = useState(false); const onChange = useCallback(e => setChecked(e.currentTarget.checked), [setChecked]); const BEHAVIOUR_GROUP = 'Behaviour props'; @@ -23,7 +23,7 @@ export const controlled = () => { return ; }; -export const uncontrolled = () => { +export const Uncontrolled = () => { const BEHAVIOUR_GROUP = 'Behaviour props'; const disabled = boolean('Disabled', false, BEHAVIOUR_GROUP); return ;