Skip to content

Commit

Permalink
chore: sort imports
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasgerstmayr committed Mar 3, 2022
1 parent 3e4e914 commit e49cf52
Show file tree
Hide file tree
Showing 69 changed files with 190 additions and 99 deletions.
1 change: 1 addition & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ module.exports = {
...require('./node_modules/@grafana/toolkit/src/config/prettier.plugin.config.json'),
// If this is not here, prettier takes default 'always', which doesnt seem to be the rule that grafana-toolkit is linting by
arrowParens: 'avoid',
importOrder: ["^@grafana/(.*)$", "^[./]"],
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@grafana/ui": "^8.4.1",
"@testing-library/jest-dom": "5.4.0",
"@testing-library/react": "^10.0.2",
"@trivago/prettier-plugin-sort-imports": "^3.2.0",
"@types/blueimp-md5": "^2.7.0",
"@types/d3-selection": "^1.4.2",
"@types/enzyme": "^3.10.5",
Expand Down
2 changes: 1 addition & 1 deletion src/common/services/pmapi/PmApiService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BackendSrv, BackendSrvRequest, FetchResponse } from '@grafana/runtime';
import { defaults, has } from 'lodash';
import { firstValueFrom } from 'rxjs';
import { BackendSrv, BackendSrvRequest, FetchResponse } from '@grafana/runtime';
import { GenericError, NetworkError } from '../../types/errors';
import { DefaultRequestOptions, getRequestOptions, timeout, TimeoutError } from '../../utils';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/common/services/pmsearch/PmSearchApiService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BackendSrv, BackendSrvRequest, FetchResponse } from '@grafana/runtime';
import { defaults, has } from 'lodash';
import { firstValueFrom } from 'rxjs';
import { BackendSrv, BackendSrvRequest, FetchResponse } from '@grafana/runtime';
import { SearchEntityUtil } from '../../../components/search/utils/SearchEntityUtil';
import { NetworkError } from '../../types/errors';
import { DefaultRequestOptions, getRequestOptions, timeout, TimeoutError } from '../../utils';
Expand Down
2 changes: 1 addition & 1 deletion src/common/services/pmseries/PmSeriesApiService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BackendSrv, BackendSrvRequest, FetchResponse } from '@grafana/runtime';
import { defaults } from 'lodash';
import { firstValueFrom } from 'rxjs';
import { BackendSrv, BackendSrvRequest, FetchResponse } from '@grafana/runtime';
import { NetworkError } from '../../types/errors';
import { DefaultRequestOptions, getRequestOptions, timeout, TimeoutError } from '../../utils';
import {
Expand Down
4 changes: 2 additions & 2 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { DataSourceInstanceSettings } from '@grafana/data';
import { BackendSrvRequest } from '@grafana/runtime';
import { isString } from 'lodash';
import rootLogger, { LogLevelDesc } from 'loglevel';
import logPrefixer from 'loglevel-plugin-prefix';
import { Required } from 'utility-types';
import { DataSourceInstanceSettings } from '@grafana/data';
import { BackendSrvRequest } from '@grafana/runtime';
import { GenericError } from './types/errors';

rootLogger.setDefaultLevel('INFO');
Expand Down
4 changes: 2 additions & 2 deletions src/components/appconfig/config.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { css } from 'emotion';
import React, { PureComponent } from 'react';
import { AppPluginMeta, PluginConfigPageProps } from '@grafana/data';
import { BackendSrv, getBackendSrv } from '@grafana/runtime';
import { Button, Icon } from '@grafana/ui';
import { css } from 'emotion';
import React, { PureComponent } from 'react';
import { AppSettings } from './types';

interface Props extends PluginConfigPageProps<AppPluginMeta<AppSettings>> {}
Expand Down
2 changes: 1 addition & 1 deletion src/components/monaco/MonacoEditorLazy.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ErrorWithStack, LoadingPlaceholder } from '@grafana/ui';
import React from 'react';
import { useAsync } from 'react-use';
import { ErrorWithStack, LoadingPlaceholder } from '@grafana/ui';
import { MonacoEditorWrapperProps } from './MonacoEditorWrapper';

// COPY FROM https://github.com/grafana/grafana/blob/master/packages/grafana-ui/src/components/Monaco/CodeEditorLazy.tsx
Expand Down
2 changes: 1 addition & 1 deletion src/components/monaco/MonacoEditorWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Themeable, withTheme } from '@grafana/ui';
import * as Monaco from 'monaco-editor/esm/vs/editor/editor.api';
import React, { PureComponent } from 'react';
import MonacoEditor, { MonacoEditorProps } from 'react-monaco-editor';
import { Themeable, withTheme } from '@grafana/ui';

export interface MonacoLanguageDefinition {
/** unique language ID.
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/Search.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AppRootProps } from '@grafana/data';
import React from 'react';
import { Provider } from 'react-redux';
import { AnyAction, Store } from 'redux';
import { Persistor } from 'redux-persist';
import { PersistGate } from 'redux-persist/integration/react';
import { AppRootProps } from '@grafana/data';
import App from './App';
import Loader from './components/Loader/Loader';
import ServicesContext from './contexts/services';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GrafanaThemeType } from '@grafana/data';
import { getTheme } from '@grafana/ui';
import { shallow } from 'enzyme';
import React from 'react';
import { GrafanaThemeType } from '@grafana/data';
import { getTheme } from '@grafana/ui';
import { EntityType } from '../../../../common/services/pmsearch/types';
import { BookmarkItem } from '../../store/slices/search/slices/bookmarks/state';
import { BookmarkList } from './BookmarkList';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button, Themeable, VerticalGroup, withTheme } from '@grafana/ui';
import { cx } from 'emotion';
import React from 'react';
import { Button, Themeable, VerticalGroup, withTheme } from '@grafana/ui';
import { EntityType } from '../../../../common/services/pmsearch/types';
import { BookmarkItem } from '../../store/slices/search/slices/bookmarks/state';
import { bookmarkListBtnWithNoSpacing, bookmarkListContainer, bookmarkListContainerMultiCol } from './styles';
Expand Down
4 changes: 2 additions & 2 deletions src/components/search/components/Card/Card.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GrafanaThemeType } from '@grafana/data';
import { getTheme } from '@grafana/ui';
import { shallow } from 'enzyme';
import React from 'react';
import { GrafanaThemeType } from '@grafana/data';
import { getTheme } from '@grafana/ui';
import { Card } from './Card';

describe('<Card/>', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/components/Card/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Themeable, withTheme } from '@grafana/ui';
import React from 'react';
import { Themeable, withTheme } from '@grafana/ui';
import { getCardStyles } from './styles';

export interface CardBasicProps {
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/components/Card/styles.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { css } from 'emotion';
import { GrafanaTheme } from '@grafana/data';
import { stylesFactory } from '@grafana/ui';
import { css } from 'emotion';

export const getCardStyles = stylesFactory((theme: GrafanaTheme, background: 'weak' | 'strong') => {
return {
Expand Down
4 changes: 2 additions & 2 deletions src/components/search/components/Loader/Loader.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GrafanaThemeType } from '@grafana/data';
import { getTheme } from '@grafana/ui';
import { render, shallow } from 'enzyme';
import React from 'react';
import { GrafanaThemeType } from '@grafana/data';
import { getTheme } from '@grafana/ui';
import { Loader } from './Loader';

describe('<Loader/>', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/components/Loader/Loader.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Spinner, Themeable, withTheme } from '@grafana/ui';
import { css, cx } from 'emotion';
import React from 'react';
import { Spinner, Themeable, withTheme } from '@grafana/ui';
import { spinner, spinnerContainer, spinnerOuter } from './styles';

export interface LoaderBasicProps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button, VerticalGroup } from '@grafana/ui';
import { cx } from 'emotion';
import React from 'react';
import { Button, VerticalGroup } from '@grafana/ui';
import { SearchQuery } from '../../store/slices/search/shared/state';
import { wrappedBtn } from '../../styles';
import { SearchEntityUtil } from '../../utils/SearchEntityUtil';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GrafanaThemeType } from '@grafana/data';
import { getTheme } from '@grafana/ui';
import { render, shallow } from 'enzyme';
import React from 'react';
import { GrafanaThemeType } from '@grafana/data';
import { getTheme } from '@grafana/ui';
import { EntityType, TextItemResponse } from '../../../../common/services/pmsearch/types';
import { SearchResult } from './SearchResult';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button, HorizontalGroup, Themeable, withTheme } from '@grafana/ui';
import React from 'react';
import { Button, HorizontalGroup, Themeable, withTheme } from '@grafana/ui';
import { TextItemResponse } from '../../../../common/services/pmsearch/types';
import Card from '../Card/Card';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/components/SearchResult/styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GrafanaTheme } from '@grafana/data';
import { css } from 'emotion';
import { GrafanaTheme } from '@grafana/data';

const searchResultItem = css`
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
jest.mock('../../../../common/services/pmsearch/PmSearchApiService');
jest.mock('../../../../common/services/pmseries/PmSeriesApiService');
jest.mock('../../services/EntityDetailService');
import { shallow } from 'enzyme';
import React from 'react';
import { PmSearchApiService } from '../../../../common/services/pmsearch/PmSearchApiService';
Expand All @@ -10,6 +7,10 @@ import EntityService from '../../services/EntityDetailService';
import { Services } from '../../services/services';
import withServices, { WithServicesProps } from './withServices';

jest.mock('../../../../common/services/pmsearch/PmSearchApiService');
jest.mock('../../../../common/services/pmseries/PmSeriesApiService');
jest.mock('../../services/EntityDetailService');

type TestComponentProps = WithServicesProps & { test: string };

describe('withServices HOC', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/search/pages/Detail/DetailPage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SelectableValue } from '@grafana/data';
import { getLocationSrv, LocationSrv } from '@grafana/runtime';
import React from 'react';
import { connect } from 'react-redux';
import { SelectableValue } from '@grafana/data';
import { getLocationSrv, LocationSrv } from '@grafana/runtime';
import { EntityType } from '../../../../common/services/pmsearch/types';
import { RootState } from '../../store/reducer';
import { addBookmark, removeBookmark } from '../../store/slices/search/slices/bookmarks/actionCreators';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GrafanaThemeType } from '@grafana/data';
import { getTheme } from '@grafana/ui';
import { shallow } from 'enzyme';
import React from 'react';
import { GrafanaThemeType } from '@grafana/data';
import { getTheme } from '@grafana/ui';
import { EntityType } from '../../../../../common/services/pmsearch/types';
import { LoaderBasicProps } from '../../../components/Loader/Loader';
import { IndomEntity } from '../../../models/entities/indom';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button, HorizontalGroup, Themeable, VerticalGroup, withTheme } from '@grafana/ui';
import React from 'react';
import { connect } from 'react-redux';
import { Button, HorizontalGroup, Themeable, VerticalGroup, withTheme } from '@grafana/ui';
import { EntityType } from '../../../../../common/services/pmsearch/types';
import Card from '../../../components/Card/Card';
import Loader from '../../../components/Loader/Loader';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { VerticalGroup } from '@grafana/ui';
import { cx } from 'emotion';
import React from 'react';
import { VerticalGroup } from '@grafana/ui';
import { IndomEntitySparseItem } from '../../../../models/entities/indom';
import { gridItem, gridList, gridListSingleCol, gridValue } from '../../styles';

Expand Down
2 changes: 1 addition & 1 deletion src/components/search/pages/Detail/Metric/Meta/Meta.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button } from '@grafana/ui';
import { css } from 'emotion';
import React from 'react';
import { Button } from '@grafana/ui';
import { MetricEntityMeta } from '../../../../models/entities/metric';
import { gridItem, gridList, gridTitle, gridValue } from '../../styles';

Expand Down
4 changes: 2 additions & 2 deletions src/components/search/pages/Detail/Metric/Metric.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GrafanaThemeType } from '@grafana/data';
import { getTheme } from '@grafana/ui';
import { shallow } from 'enzyme';
import React from 'react';
import { GrafanaThemeType } from '@grafana/data';
import { getTheme } from '@grafana/ui';
import { EntityType } from '../../../../../common/services/pmsearch/types';
import { LoaderBasicProps } from '../../../components/Loader/Loader';
import { MetricEntity } from '../../../models/entities/metric';
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/pages/Detail/Metric/Metric.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button, HorizontalGroup, Themeable, VerticalGroup, withTheme } from '@grafana/ui';
import React from 'react';
import { connect } from 'react-redux';
import { Button, HorizontalGroup, Themeable, VerticalGroup, withTheme } from '@grafana/ui';
import { EntityType } from '../../../../../common/services/pmsearch/types';
import Card from '../../../components/Card/Card';
import Loader from '../../../components/Loader/Loader';
Expand Down
4 changes: 2 additions & 2 deletions src/components/search/pages/Detail/Metric/Series/Series.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { SelectableValue } from '@grafana/data';
import { RadioButtonGroup, VerticalGroup } from '@grafana/ui';
import React from 'react';
import { connect } from 'react-redux';
import { AnyAction, bindActionCreators } from 'redux';
import { ThunkDispatch } from 'redux-thunk';
import { SelectableValue } from '@grafana/data';
import { RadioButtonGroup, VerticalGroup } from '@grafana/ui';
import { EntityType } from '../../../../../../common/services/pmsearch/types';
import { MetricEntitySeries } from '../../../../models/entities/metric';
import { RootState } from '../../../../store/reducer';
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/pages/Detail/styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GrafanaTheme } from '@grafana/data';
import { css } from 'emotion';
import { GrafanaTheme } from '@grafana/data';

const detailPageContainer = css`
grid-area: content;
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/pages/Index/IndexPage.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { VerticalGroup } from '@grafana/ui';
import React from 'react';
import { connect } from 'react-redux';
import { AnyAction, bindActionCreators } from 'redux';
import { ThunkDispatch } from 'redux-thunk';
import { VerticalGroup } from '@grafana/ui';
import BookmarkList from '../../components/BookmarkList/BookmarkList';
import Card from '../../components/Card/Card';
import SearchHistoryList from '../../components/SearchHistoryList/SearchHistoryList';
Expand Down
4 changes: 2 additions & 2 deletions src/components/search/pages/Search/SearchPage.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GrafanaThemeType } from '@grafana/data';
import { getTheme } from '@grafana/ui';
import { shallow } from 'enzyme';
import React from 'react';
import { GrafanaThemeType } from '@grafana/data';
import { getTheme } from '@grafana/ui';
import { EntityType, TextResponse } from '../../../../common/services/pmsearch/types';
import { LoaderBasicProps } from '../../components/Loader/Loader';
import { SearchResultProps } from '../../components/SearchResult/SearchResult';
Expand Down
3 changes: 2 additions & 1 deletion src/components/search/pages/Search/SearchPage.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { HorizontalGroup, Pagination, Themeable, VerticalGroup, withTheme } from '@grafana/ui';
import { getLogger } from 'loglevel';
import React from 'react';
import { connect } from 'react-redux';
import { AnyAction, bindActionCreators } from 'redux';
import { ThunkDispatch } from 'redux-thunk';
import { HorizontalGroup, Pagination, Themeable, VerticalGroup, withTheme } from '@grafana/ui';
import { EntityType, TextItemResponse } from '../../../../common/services/pmsearch/types';
import Loader from '../../components/Loader/Loader';
import SearchResult from '../../components/SearchResult/SearchResult';
Expand All @@ -12,6 +12,7 @@ import { openDetail, querySearch } from '../../store/slices/search/shared/action
import { FetchStatus } from '../../store/slices/search/shared/state';
import { stripHtml } from '../../utils/utils';
import { paginationContainer, searchPageElapsed, searchPageMatchesDesc } from './styles';

const log = getLogger('search/SearchPage');

const mapStateToProps = (state: RootState) => ({
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/pages/Search/styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GrafanaTheme } from '@grafana/data';
import { css } from 'emotion';
import { GrafanaTheme } from '@grafana/data';

const searchPageContainer = css`
grid-area: content;
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/partials/Actions/Actions.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Button, VerticalGroup } from '@grafana/ui';
import React from 'react';
import { connect } from 'react-redux';
import { AnyAction, bindActionCreators } from 'redux';
import { ThunkDispatch } from 'redux-thunk';
import { Button, VerticalGroup } from '@grafana/ui';
import { RootState } from '../../store/reducer';
import { querySearch } from '../../store/slices/search/shared/actionCreators';
import { setView } from '../../store/slices/search/slices/view/actionCreators';
Expand Down
4 changes: 2 additions & 2 deletions src/components/search/partials/Aside/Aside.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GrafanaThemeType } from '@grafana/data';
import { getTheme } from '@grafana/ui';
import { shallow } from 'enzyme';
import React from 'react';
import { GrafanaThemeType } from '@grafana/data';
import { getTheme } from '@grafana/ui';
import { EntityType, SearchEntity } from '../../../../common/services/pmsearch/types';
import { OpenDetailActionCreator } from '../../store/slices/search/shared/actionCreators';
import { FetchStatus } from '../../store/slices/search/shared/state';
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/partials/Aside/Aside.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Button, Themeable, VerticalGroup, withTheme } from '@grafana/ui';
import { cx } from 'emotion';
import React from 'react';
import { connect } from 'react-redux';
import { AnyAction, bindActionCreators } from 'redux';
import { ThunkDispatch } from 'redux-thunk';
import { Button, Themeable, VerticalGroup, withTheme } from '@grafana/ui';
import { EntityType } from '../../../../common/services/pmsearch/types';
import BookmarkList from '../../components/BookmarkList/BookmarkList';
import Loader from '../../components/Loader/Loader';
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/partials/Aside/styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GrafanaTheme } from '@grafana/data';
import { css } from 'emotion';
import { GrafanaTheme } from '@grafana/data';

const asideContainer = css`
grid-area: aside;
Expand Down
11 changes: 6 additions & 5 deletions src/components/search/partials/SearchForm/SearchForm.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
jest.mock('../../../../common/services/pmsearch/PmSearchApiService');
jest.mock('../../../../common/services/pmseries/PmSeriesApiService');
jest.mock('../../services/EntityDetailService');
import { GrafanaThemeType } from '@grafana/data';
import { getTheme } from '@grafana/ui';
import { shallow } from 'enzyme';
import React from 'react';
import { AutosuggestPropsSingleSection } from 'react-autosuggest';
import { GrafanaThemeType } from '@grafana/data';
import { getTheme } from '@grafana/ui';
import { PmSearchApiService } from '../../../../common/services/pmsearch/PmSearchApiService';
import { AutocompleteSuggestion, SearchEntity } from '../../../../common/services/pmsearch/types';
import { PmSeriesApiService } from '../../../../common/services/pmseries/PmSeriesApiService';
Expand All @@ -14,6 +11,10 @@ import { Services } from '../../services/services';
import { QuerySearchActionCreator } from '../../store/slices/search/shared/actionCreators';
import { SearchForm, SearchFormProps, SearchFormReduxProps, SearchFormState } from './SearchForm';

jest.mock('../../../../common/services/pmsearch/PmSearchApiService');
jest.mock('../../../../common/services/pmseries/PmSeriesApiService');
jest.mock('../../services/EntityDetailService');

describe('<SearchForm/>', () => {
let mockReduxProps: SearchFormReduxProps;
let searchFormProps: SearchFormProps;
Expand Down
Loading

0 comments on commit e49cf52

Please sign in to comment.