Unverified Commit 2825dd74 authored by Marcos Iglesias's avatar Marcos Iglesias Committed by GitHub

chore: Removes 84 unused variables (#600)

Signed-off-by: 's avatarMarcos Iglesias Valle <golodhros@gmail.com>
parent 30807312
...@@ -29,7 +29,7 @@ describe('ImagePreview', () => { ...@@ -29,7 +29,7 @@ describe('ImagePreview', () => {
describe('onSuccess', () => { describe('onSuccess', () => {
let currentState; let currentState;
beforeAll(() => { beforeAll(() => {
const { props, wrapper } = setup(); const { wrapper } = setup();
wrapper.instance().onSuccess(); wrapper.instance().onSuccess();
currentState = wrapper.state(); currentState = wrapper.state();
}); });
...@@ -44,7 +44,7 @@ describe('ImagePreview', () => { ...@@ -44,7 +44,7 @@ describe('ImagePreview', () => {
describe('onError', () => { describe('onError', () => {
let currentState; let currentState;
beforeAll(() => { beforeAll(() => {
const { props, wrapper } = setup(); const { wrapper } = setup();
const event = {} as React.SyntheticEvent<HTMLImageElement>; const event = {} as React.SyntheticEvent<HTMLImageElement>;
wrapper.instance().onError(event); wrapper.instance().onError(event);
currentState = wrapper.state(); currentState = wrapper.state();
...@@ -111,7 +111,7 @@ describe('ImagePreview', () => { ...@@ -111,7 +111,7 @@ describe('ImagePreview', () => {
describe('when there is an error', () => { describe('when there is an error', () => {
it('renders a link', () => { it('renders a link', () => {
const { props, wrapper } = setup(); const { wrapper } = setup();
wrapper.instance().setState({ hasError: true }); wrapper.instance().setState({ hasError: true });
wrapper.update(); wrapper.update();
......
...@@ -6,7 +6,7 @@ import { OverlayTrigger, Popover } from 'react-bootstrap'; ...@@ -6,7 +6,7 @@ import { OverlayTrigger, Popover } from 'react-bootstrap';
import { ResourceType } from 'interfaces'; import { ResourceType } from 'interfaces';
import { getSourceDisplayName, getSourceIconClass } from 'config/config-utils'; import { getSourceDisplayName } from 'config/config-utils';
import './styles.scss'; import './styles.scss';
...@@ -24,7 +24,6 @@ type GoToDashboardLinkProps = { ...@@ -24,7 +24,6 @@ type GoToDashboardLinkProps = {
const QUERY_LABEL = 'Query'; const QUERY_LABEL = 'Query';
const LINK_TOOLTIP_TEXT = 'View in'; const LINK_TOOLTIP_TEXT = 'View in';
const LOADING_QUERY_MESSAGE = 'Loading Query Component, please wait...';
const LazyComponent = React.lazy(() => import('./CodeBlock')); const LazyComponent = React.lazy(() => import('./CodeBlock'));
......
...@@ -7,7 +7,6 @@ import * as History from 'history'; ...@@ -7,7 +7,6 @@ import * as History from 'history';
import { shallow } from 'enzyme'; import { shallow } from 'enzyme';
import AvatarLabel from 'components/common/AvatarLabel';
import LoadingSpinner from 'components/common/LoadingSpinner'; import LoadingSpinner from 'components/common/LoadingSpinner';
import Breadcrumb from 'components/common/Breadcrumb'; import Breadcrumb from 'components/common/Breadcrumb';
import BookmarkIcon from 'components/common/Bookmark/BookmarkIcon'; import BookmarkIcon from 'components/common/Bookmark/BookmarkIcon';
...@@ -16,7 +15,6 @@ import ResourceList from 'components/common/ResourceList'; ...@@ -16,7 +15,6 @@ import ResourceList from 'components/common/ResourceList';
import TabsComponent from 'components/common/TabsComponent'; import TabsComponent from 'components/common/TabsComponent';
import { dashboardMetadata } from 'fixtures/metadata/dashboard'; import { dashboardMetadata } from 'fixtures/metadata/dashboard';
import { NO_TIMESTAMP_TEXT } from 'components/constants'; import { NO_TIMESTAMP_TEXT } from 'components/constants';
import * as LogUtils from 'utils/logUtils';
import { ResourceType } from 'interfaces'; import { ResourceType } from 'interfaces';
import { BadgeStyle } from 'config/config-types'; import { BadgeStyle } from 'config/config-types';
import ChartList from './ChartList'; import ChartList from './ChartList';
......
...@@ -9,13 +9,7 @@ import BugReportFeedbackForm from './FeedbackForm/BugReportFeedbackForm'; ...@@ -9,13 +9,7 @@ import BugReportFeedbackForm from './FeedbackForm/BugReportFeedbackForm';
import RatingFeedbackForm from './FeedbackForm/RatingFeedbackForm'; import RatingFeedbackForm from './FeedbackForm/RatingFeedbackForm';
import RequestFeedbackForm from './FeedbackForm/RequestFeedbackForm'; import RequestFeedbackForm from './FeedbackForm/RequestFeedbackForm';
import Feedback, { FeedbackProps, FeedbackType } from '.'; import Feedback, { FeedbackProps, FeedbackType } from '.';
import { import { BUG_REPORT_TEXT, RATING_TEXT, REQUEST_TEXT } from './constants';
BUG_REPORT_TEXT,
BUTTON_CLOSE_TEXT,
FEEDBACK_TYPE_TEXT,
RATING_TEXT,
REQUEST_TEXT,
} from './constants';
describe('Feedback', () => { describe('Feedback', () => {
const setStateSpy = jest.spyOn(Feedback.prototype, 'setState'); const setStateSpy = jest.spyOn(Feedback.prototype, 'setState');
...@@ -29,13 +23,13 @@ describe('Feedback', () => { ...@@ -29,13 +23,13 @@ describe('Feedback', () => {
}; };
describe('constructor', () => { describe('constructor', () => {
let props;
let wrapper; let wrapper;
beforeAll(() => { beforeAll(() => {
const setupResult = setup(); const setupResult = setup();
props = setupResult.props;
wrapper = setupResult.wrapper; wrapper = setupResult.wrapper;
}); });
it('sets state.isOpen to false', () => { it('sets state.isOpen to false', () => {
expect(wrapper.state().isOpen).toEqual(false); expect(wrapper.state().isOpen).toEqual(false);
}); });
...@@ -52,22 +46,24 @@ describe('Feedback', () => { ...@@ -52,22 +46,24 @@ describe('Feedback', () => {
describe('toggle', () => { describe('toggle', () => {
it('calls setState with negation of state.isOpen', () => { it('calls setState with negation of state.isOpen', () => {
setStateSpy.mockClear(); setStateSpy.mockClear();
const { props, wrapper } = setup(); const { wrapper } = setup();
const previsOpenState = wrapper.state().isOpen; const previsOpenState = wrapper.state().isOpen;
wrapper.instance().toggle(); wrapper.instance().toggle();
expect(setStateSpy).toHaveBeenCalledWith({ isOpen: !previsOpenState }); expect(setStateSpy).toHaveBeenCalledWith({ isOpen: !previsOpenState });
}); });
}); });
describe('changeType', () => { describe('changeType', () => {
let props;
let wrapper; let wrapper;
beforeAll(() => { beforeAll(() => {
const setupResult = setup(); const setupResult = setup();
props = setupResult.props;
wrapper = setupResult.wrapper; wrapper = setupResult.wrapper;
setStateSpy.mockClear(); setStateSpy.mockClear();
}); });
it('returns method that calls setState with correct values if type === FeedbackType.Bug', () => { it('returns method that calls setState with correct values if type === FeedbackType.Bug', () => {
wrapper.instance().changeType(FeedbackType.Bug)(); wrapper.instance().changeType(FeedbackType.Bug)();
expect(setStateSpy).toHaveBeenCalledWith({ expect(setStateSpy).toHaveBeenCalledWith({
...@@ -99,9 +95,9 @@ describe('Feedback', () => { ...@@ -99,9 +95,9 @@ describe('Feedback', () => {
let feedbackComponent; let feedbackComponent;
let props; let props;
let wrapper; let wrapper;
let changeTypeSpy; let changeTypeSpy;
let changeTypeMockResult; let changeTypeMockResult;
beforeAll(() => { beforeAll(() => {
const setupResult = setup({ title: 'I am a title' }); const setupResult = setup({ title: 'I am a title' });
props = setupResult.props; props = setupResult.props;
...@@ -116,6 +112,7 @@ describe('Feedback', () => { ...@@ -116,6 +112,7 @@ describe('Feedback', () => {
feedbackIcon = wrapper.children().at(0); feedbackIcon = wrapper.children().at(0);
feedbackComponent = wrapper.children().at(1); feedbackComponent = wrapper.children().at(1);
}); });
it('renders help button with correct props', () => { it('renders help button with correct props', () => {
expect(feedbackIcon.exists()).toBe(true); expect(feedbackIcon.exists()).toBe(true);
expect(feedbackIcon.props().className).toEqual( expect(feedbackIcon.props().className).toEqual(
...@@ -322,13 +319,13 @@ describe('Feedback', () => { ...@@ -322,13 +319,13 @@ describe('Feedback', () => {
}); });
describe('if !state.isOpen', () => { describe('if !state.isOpen', () => {
let props;
let wrapper; let wrapper;
beforeAll(() => { beforeAll(() => {
const setupResult = setup(); const setupResult = setup();
props = setupResult.props;
wrapper = setupResult.wrapper; wrapper = setupResult.wrapper;
}); });
it('renders help button with correct props', () => { it('renders help button with correct props', () => {
const feedbackIcon = wrapper.children().at(0); const feedbackIcon = wrapper.children().at(0);
expect(feedbackIcon.exists()).toBe(true); expect(feedbackIcon.exists()).toBe(true);
......
...@@ -77,18 +77,21 @@ describe('ExploreButton', () => { ...@@ -77,18 +77,21 @@ describe('ExploreButton', () => {
it('returns null if explore is not enabled', () => { it('returns null if explore is not enabled', () => {
mockExploreEnabled = false; mockExploreEnabled = false;
const { props, wrapper } = setup(); const { wrapper } = setup();
expect(wrapper.instance().render()).toBeNull(); expect(wrapper.instance().render()).toBeNull();
}); });
it('returns null if the generated url is empty', () => { it('returns null if the generated url is empty', () => {
const { props, wrapper } = setup(); const { wrapper } = setup();
mockExploreUrl = ''; mockExploreUrl = '';
expect(wrapper.instance().render()).toBeNull(); expect(wrapper.instance().render()).toBeNull();
}); });
it('renders a link to the explore URL', () => { it('renders a link to the explore URL', () => {
const { props, wrapper } = setup(); const { wrapper } = setup();
expect(wrapper.find('a').props()).toMatchObject({ expect(wrapper.find('a').props()).toMatchObject({
href: mockExploreUrl, href: mockExploreUrl,
target: '_blank', target: '_blank',
......
...@@ -5,7 +5,6 @@ import * as React from 'react'; ...@@ -5,7 +5,6 @@ import * as React from 'react';
import { shallow } from 'enzyme'; import { shallow } from 'enzyme';
import { ResourceReport } from 'interfaces/TableMetadata'; import { ResourceReport } from 'interfaces/TableMetadata';
import { logClick } from 'ducks/utilMethods';
import TableReportsDropdown from '.'; import TableReportsDropdown from '.';
describe('TableReportsDropdown component', () => { describe('TableReportsDropdown component', () => {
...@@ -27,6 +26,7 @@ describe('TableReportsDropdown component', () => { ...@@ -27,6 +26,7 @@ describe('TableReportsDropdown component', () => {
const container = tableReportsDropdown.find('DropdownMenu'); const container = tableReportsDropdown.find('DropdownMenu');
expect(container.exists()).toBe(true); expect(container.exists()).toBe(true);
}); });
it('do not render resource reports', () => { it('do not render resource reports', () => {
const container = shallow( const container = shallow(
<TableReportsDropdown resourceReports={[]} /> <TableReportsDropdown resourceReports={[]} />
......
...@@ -21,7 +21,7 @@ const TableReportsDropdown: React.FC<ResourceReportProps> = ({ ...@@ -21,7 +21,7 @@ const TableReportsDropdown: React.FC<ResourceReportProps> = ({
</Dropdown.Toggle> </Dropdown.Toggle>
<Dropdown.Menu className="profile-menu"> <Dropdown.Menu className="profile-menu">
{resourceReports.map((report) => ( {resourceReports.map((report) => (
<li> <li key={report.url}>
<a target="_blank" rel="noreferrer" href={`${report.url}`}> <a target="_blank" rel="noreferrer" href={`${report.url}`}>
{`${report.name}`} {`${report.name}`}
</a> </a>
......
...@@ -37,7 +37,7 @@ describe('BookmarkIcon', () => { ...@@ -37,7 +37,7 @@ describe('BookmarkIcon', () => {
stopPropagation: jest.fn(), stopPropagation: jest.fn(),
}; };
it('stops propagation and prevents default', () => { it('stops propagation and prevents default', () => {
const { props, wrapper } = setup(); const { wrapper } = setup();
wrapper.find('div').simulate('click', clickEvent); wrapper.find('div').simulate('click', clickEvent);
expect(clickEvent.preventDefault).toHaveBeenCalled(); expect(clickEvent.preventDefault).toHaveBeenCalled();
expect(clickEvent.stopPropagation).toHaveBeenCalled(); expect(clickEvent.stopPropagation).toHaveBeenCalled();
...@@ -69,17 +69,17 @@ describe('BookmarkIcon', () => { ...@@ -69,17 +69,17 @@ describe('BookmarkIcon', () => {
describe('render', () => { describe('render', () => {
it('renders an empty bookmark when not bookmarked', () => { it('renders an empty bookmark when not bookmarked', () => {
const { props, wrapper } = setup({ isBookmarked: false }); const { wrapper } = setup({ isBookmarked: false });
expect(wrapper.find('.icon-bookmark').exists()).toBe(true); expect(wrapper.find('.icon-bookmark').exists()).toBe(true);
}); });
it('renders a filled star when bookmarked', () => { it('renders a filled star when bookmarked', () => {
const { props, wrapper } = setup({ isBookmarked: true }); const { wrapper } = setup({ isBookmarked: true });
expect(wrapper.find('.icon-bookmark-filled').exists()).toBe(true); expect(wrapper.find('.icon-bookmark-filled').exists()).toBe(true);
}); });
it('renders a large star when specified', () => { it('renders a large star when specified', () => {
const { props, wrapper } = setup({ large: true }); const { wrapper } = setup({ large: true });
expect(wrapper.find('.bookmark-large').exists()).toBe(true); expect(wrapper.find('.bookmark-large').exists()).toBe(true);
}); });
}); });
......
...@@ -8,7 +8,7 @@ import { shallow } from 'enzyme'; ...@@ -8,7 +8,7 @@ import { shallow } from 'enzyme';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import BookmarkIcon from 'components/common/Bookmark/BookmarkIcon'; import BookmarkIcon from 'components/common/Bookmark/BookmarkIcon';
import SchemaInfo from 'components/common/ResourceListItem/SchemaInfo'; import SchemaInfo from 'components/common/ResourceListItem/SchemaInfo';
import { ResourceType, Badge, TagType } from 'interfaces'; import { ResourceType, TagType } from 'interfaces';
import * as ConfigUtils from 'config/config-utils'; import * as ConfigUtils from 'config/config-utils';
import BadgeList from 'components/common/BadgeList'; import BadgeList from 'components/common/BadgeList';
...@@ -68,9 +68,8 @@ describe('TableListItem', () => { ...@@ -68,9 +68,8 @@ describe('TableListItem', () => {
it('calls getSourceIconClass with given database id', () => { it('calls getSourceIconClass with given database id', () => {
const testValue = 'noEffectOnTest'; const testValue = 'noEffectOnTest';
const givenResource = ResourceType.table; const givenResource = ResourceType.table;
const iconClass = wrapper
.instance() wrapper.instance().generateResourceIconClass(testValue, givenResource);
.generateResourceIconClass(testValue, givenResource);
expect(getDBIconClassSpy).toHaveBeenCalledWith(testValue, givenResource); expect(getDBIconClassSpy).toHaveBeenCalledWith(testValue, givenResource);
}); });
...@@ -129,7 +128,7 @@ describe('TableListItem', () => { ...@@ -129,7 +128,7 @@ describe('TableListItem', () => {
describe('if props.table not have schema description', () => { describe('if props.table not have schema description', () => {
it('if schema description is empty string', () => { it('if schema description is empty string', () => {
const { props, wrapper } = setup({ const { wrapper } = setup({
table: { table: {
type: ResourceType.table, type: ResourceType.table,
cluster: '', cluster: '',
...@@ -149,7 +148,7 @@ describe('TableListItem', () => { ...@@ -149,7 +148,7 @@ describe('TableListItem', () => {
}); });
it('if schema description is null', () => { it('if schema description is null', () => {
const { props, wrapper } = setup({ const { wrapper } = setup({
table: { table: {
type: ResourceType.table, type: ResourceType.table,
cluster: '', cluster: '',
...@@ -221,7 +220,7 @@ describe('TableListItem', () => { ...@@ -221,7 +220,7 @@ describe('TableListItem', () => {
describe('if props.table does not have badges', () => { describe('if props.table does not have badges', () => {
it('does not render badges section', () => { it('does not render badges section', () => {
const { props, wrapper } = setup({ const { wrapper } = setup({
table: { table: {
type: ResourceType.table, type: ResourceType.table,
cluster: '', cluster: '',
...@@ -238,7 +237,7 @@ describe('TableListItem', () => { ...@@ -238,7 +237,7 @@ describe('TableListItem', () => {
}); });
it('or if they are empty does not render badges section', () => { it('or if they are empty does not render badges section', () => {
const { props, wrapper } = setup({ const { wrapper } = setup({
table: { table: {
type: ResourceType.table, type: ResourceType.table,
cluster: '', cluster: '',
......
...@@ -19,7 +19,6 @@ import { ...@@ -19,7 +19,6 @@ import {
noResultsExample, noResultsExample,
} from 'fixtures/search/inlineResults'; } from 'fixtures/search/inlineResults';
import { logClick } from 'ducks/utilMethods';
import { SearchItem, SearchItemProps, mapStateToProps } from '..'; import { SearchItem, SearchItemProps, mapStateToProps } from '..';
jest.mock('ducks/utilMethods', () => ({ jest.mock('ducks/utilMethods', () => ({
...@@ -52,7 +51,7 @@ describe('SearchItem', () => { ...@@ -52,7 +51,7 @@ describe('SearchItem', () => {
describe('renderIndicator', () => { describe('renderIndicator', () => {
it('renders LoadingSpinner if props.isLoading', () => { it('renders LoadingSpinner if props.isLoading', () => {
const { props, wrapper } = setup({ isLoading: true }); const { wrapper } = setup({ isLoading: true });
const content = shallow( const content = shallow(
<div>{wrapper.instance().renderIndicator()}</div> <div>{wrapper.instance().renderIndicator()}</div>
); );
...@@ -60,13 +59,13 @@ describe('SearchItem', () => { ...@@ -60,13 +59,13 @@ describe('SearchItem', () => {
}); });
it('renders correct text if !props.hasResults', () => { it('renders correct text if !props.hasResults', () => {
const { props, wrapper } = setup({ hasResults: false }); const { wrapper } = setup({ hasResults: false });
const content = shallow(wrapper.instance().renderIndicator()); const content = shallow(wrapper.instance().renderIndicator());
expect(content.text()).toBe(SEARCH_ITEM_NO_RESULTS); expect(content.text()).toBe(SEARCH_ITEM_NO_RESULTS);
}); });
it('renders nothing if !props.Loading and props.hasResults', () => { it('renders nothing if !props.Loading and props.hasResults', () => {
const { props, wrapper } = setup({ isLoading: false, hasResults: true }); const { wrapper } = setup({ isLoading: false, hasResults: true });
expect(wrapper.instance().renderIndicator()).toBe(null); expect(wrapper.instance().renderIndicator()).toBe(null);
}); });
}); });
......
...@@ -98,8 +98,10 @@ export class SearchBar extends React.Component<SearchBarProps, SearchBarState> { ...@@ -98,8 +98,10 @@ export class SearchBar extends React.Component<SearchBarProps, SearchBarState> {
}; };
componentDidUpdate = (prevProps: SearchBarProps) => { componentDidUpdate = (prevProps: SearchBarProps) => {
if (this.props.searchTerm !== prevProps.searchTerm) { const { searchTerm } = this.props;
this.setState({ searchTerm: this.props.searchTerm });
if (searchTerm !== prevProps.searchTerm) {
this.setState({ searchTerm });
} }
}; };
...@@ -121,8 +123,11 @@ export class SearchBar extends React.Component<SearchBarProps, SearchBarState> { ...@@ -121,8 +123,11 @@ export class SearchBar extends React.Component<SearchBarProps, SearchBarState> {
handleValueSubmit = (event: React.FormEvent<HTMLFormElement>): void => { handleValueSubmit = (event: React.FormEvent<HTMLFormElement>): void => {
const searchTerm = this.state.searchTerm.trim(); const searchTerm = this.state.searchTerm.trim();
event.preventDefault(); event.preventDefault();
if (this.isFormValid(searchTerm)) { if (this.isFormValid(searchTerm)) {
this.props.submitSearch(searchTerm); const { submitSearch } = this.props;
submitSearch(searchTerm);
this.hideTypeAhead(); this.hideTypeAhead();
} }
}; };
......
...@@ -22,7 +22,6 @@ describe('dashboard reducer', () => { ...@@ -22,7 +22,6 @@ describe('dashboard reducer', () => {
}); });
it('should handle GetDashboard.REQUEST', () => { it('should handle GetDashboard.REQUEST', () => {
const term = 'testSearch';
expect(reducer(testState, getDashboard({ uri: 'testUri' }))).toEqual({ expect(reducer(testState, getDashboard({ uri: 'testUri' }))).toEqual({
...testState, ...testState,
isLoading: true, isLoading: true,
......
import axios, { AxiosResponse } from 'axios'; import axios from 'axios';
import { NotificationType } from 'interfaces'; import { NotificationType } from 'interfaces';
import AppConfig from 'config/config'; import AppConfig from 'config/config';
import * as API from '../v0'; import * as API from '../v0';
...@@ -26,7 +26,7 @@ describe('getIssues', () => { ...@@ -26,7 +26,7 @@ describe('getIssues', () => {
it('calls axios with correct parameters if tableKey provided', async () => { it('calls axios with correct parameters if tableKey provided', async () => {
expect.assertions(1); expect.assertions(1);
await API.getIssues('tableKey').then((data) => { await API.getIssues('tableKey').then(() => {
expect(axiosMock).toHaveBeenCalledWith( expect(axiosMock).toHaveBeenCalledWith(
`${API.API_PATH}/issues?key=tableKey` `${API.API_PATH}/issues?key=tableKey`
); );
...@@ -35,6 +35,7 @@ describe('getIssues', () => { ...@@ -35,6 +35,7 @@ describe('getIssues', () => {
it('returns response data', async () => { it('returns response data', async () => {
expect.assertions(1); expect.assertions(1);
await API.getIssues('tableKey').then((data) => { await API.getIssues('tableKey').then((data) => {
expect(data).toEqual(mockGetResponse.data.issues); expect(data).toEqual(mockGetResponse.data.issues);
}); });
......
import axios, { AxiosResponse, AxiosError } from 'axios'; import axios, { AxiosResponse } from 'axios';
export const API_PATH = '/api/metadata/v0'; export const API_PATH = '/api/metadata/v0';
...@@ -14,7 +14,7 @@ export function getLastIndexed() { ...@@ -14,7 +14,7 @@ export function getLastIndexed() {
return data.timestamp; return data.timestamp;
}) })
.catch((e) => { .catch(() => {
const timestamp = null; const timestamp = null;
return Promise.reject({ return Promise.reject({
timestamp, timestamp,
......
import axios, { AxiosResponse } from 'axios'; import axios, { AxiosResponse } from 'axios';
import {
DashboardSearchResults,
TableSearchResults,
UserSearchResults,
} from 'ducks/search/types';
import globalState from 'fixtures/globalState'; import globalState from 'fixtures/globalState';
import { ResourceType, SearchType } from 'interfaces'; import { ResourceType, SearchType } from 'interfaces';
......
...@@ -7,7 +7,7 @@ import reducer, { ...@@ -7,7 +7,7 @@ import reducer, {
initialFilterState, initialFilterState,
FilterReducerState, FilterReducerState,
UpdateSearchFilter, UpdateSearchFilter,
} from '../reducer'; } from './reducer';
describe('filters reducer', () => { describe('filters reducer', () => {
describe('actions', () => { describe('actions', () => {
...@@ -57,8 +57,6 @@ describe('filters reducer', () => { ...@@ -57,8 +57,6 @@ describe('filters reducer', () => {
}); });
it('does not update the filter state if request does not contains filter information', () => { it('does not update the filter state if request does not contains filter information', () => {
const givenResource = ResourceType.table;
const givenFilters = { database: { testDb: true } };
const result = reducer( const result = reducer(
testState, testState,
submitSearchResource({ submitSearchResource({
......
...@@ -7,10 +7,10 @@ import * as SearchUtils from 'ducks/search/utils'; ...@@ -7,10 +7,10 @@ import * as SearchUtils from 'ducks/search/utils';
import globalState from 'fixtures/globalState'; import globalState from 'fixtures/globalState';
import { datasetFilterExample } from 'fixtures/search/filters'; import { datasetFilterExample } from 'fixtures/search/filters';
import { ResourceType, SearchType } from 'interfaces'; import { SearchType } from 'interfaces';
import { updateFilterByCategory, UpdateSearchFilter } from '../reducer'; import { updateFilterByCategory, UpdateSearchFilter } from './reducer';
import * as Sagas from '../sagas'; import * as Sagas from './sagas';
describe('filter sagas', () => { describe('filter sagas', () => {
describe('filterWatcher', () => { describe('filterWatcher', () => {
......
import { ResourceType, SearchType } from 'interfaces'; import { ResourceType, SearchType } from 'interfaces';
import * as NavigationUtils from 'utils/navigationUtils'; import * as NavigationUtils from 'utils/navigationUtils';
import * as SearchUtils from 'ducks/search/utils';
import globalState from 'fixtures/globalState'; import globalState from 'fixtures/globalState';
import * as API from '../api/v0';
import * as filterReducer from '../filters/reducer'; import * as filterReducer from './filters/reducer';
import reducer, { import reducer, {
getInlineResults, getInlineResults,
...@@ -30,7 +28,7 @@ import reducer, { ...@@ -30,7 +28,7 @@ import reducer, {
updateFromInlineResult, updateFromInlineResult,
updateSearchState, updateSearchState,
urlDidUpdate, urlDidUpdate,
} from '../reducer'; } from './reducer';
import { import {
LoadPreviousSearch, LoadPreviousSearch,
InlineSearch, InlineSearch,
...@@ -42,7 +40,7 @@ import { ...@@ -42,7 +40,7 @@ import {
SearchResponsePayload, SearchResponsePayload,
SubmitSearch, SubmitSearch,
UrlDidUpdate, UrlDidUpdate,
} from '../types'; } from './types';
const MOCK_TABLE_FILTER_STATE = { database: { hive: true } }; const MOCK_TABLE_FILTER_STATE = { database: { hive: true } };
const MOCK_FILTER_STATE = { const MOCK_FILTER_STATE = {
...@@ -52,7 +50,7 @@ const filterReducerSpy = jest ...@@ -52,7 +50,7 @@ const filterReducerSpy = jest
.spyOn(filterReducer, 'default') .spyOn(filterReducer, 'default')
.mockImplementation(() => MOCK_FILTER_STATE); .mockImplementation(() => MOCK_FILTER_STATE);
const updateSearchUrlSpy = jest.spyOn(NavigationUtils, 'updateSearchUrl'); jest.spyOn(NavigationUtils, 'updateSearchUrl');
const searchState = globalState.search; const searchState = globalState.search;
describe('search reducer', () => { describe('search reducer', () => {
...@@ -492,7 +490,8 @@ describe('search reducer', () => { ...@@ -492,7 +490,8 @@ describe('search reducer', () => {
it('calls filter reducer with existing filters', () => { it('calls filter reducer with existing filters', () => {
filterReducerSpy.mockClear(); filterReducerSpy.mockClear();
const result = reducer(initialState, filterAction); reducer(initialState, filterAction);
expect(filterReducerSpy).toHaveBeenCalledWith( expect(filterReducerSpy).toHaveBeenCalledWith(
initialState.filters, initialState.filters,
filterAction filterAction
......
...@@ -18,7 +18,6 @@ import * as API from './api/v0'; ...@@ -18,7 +18,6 @@ import * as API from './api/v0';
import { import {
LoadPreviousSearch, LoadPreviousSearch,
LoadPreviousSearchRequest,
SearchAll, SearchAll,
SearchAllRequest, SearchAllRequest,
SearchResource, SearchResource,
...@@ -45,14 +44,13 @@ import { ...@@ -45,14 +44,13 @@ import {
searchResourceFailure, searchResourceFailure,
searchResourceSuccess, searchResourceSuccess,
getInlineResults, getInlineResults,
getInlineResultsDebounce,
getInlineResultsSuccess, getInlineResultsSuccess,
getInlineResultsFailure, getInlineResultsFailure,
updateFromInlineResult, updateFromInlineResult,
updateSearchState, updateSearchState,
submitSearchResource, submitSearchResource,
} from './reducer'; } from './reducer';
import { initialFilterState, UpdateSearchFilter } from './filters/reducer'; import { initialFilterState } from './filters/reducer';
import { autoSelectResource, getPageIndex, getSearchState } from './utils'; import { autoSelectResource, getPageIndex, getSearchState } from './utils';
// SEARCH SAGAS // SEARCH SAGAS
...@@ -194,9 +192,7 @@ export function* urlDidUpdateWatcher(): SagaIterator { ...@@ -194,9 +192,7 @@ export function* urlDidUpdateWatcher(): SagaIterator {
* Handles workflow for user actions on navigations components. * Handles workflow for user actions on navigations components.
* Leverages BrowserHistory or updates search url accordingly. * Leverages BrowserHistory or updates search url accordingly.
*/ */
export function* loadPreviousSearchWorker( export function* loadPreviousSearchWorker(): SagaIterator {
action: LoadPreviousSearchRequest
): SagaIterator {
const state = yield select(getSearchState); const state = yield select(getSearchState);
if (state.search_term === '') { if (state.search_term === '') {
BrowserHistory.goBack(); BrowserHistory.goBack();
......
import { testSaga } from 'redux-saga-test-plan'; import { testSaga } from 'redux-saga-test-plan';
import { debounce } from 'redux-saga/effects';
import { DEFAULT_RESOURCE_TYPE, ResourceType, SearchType } from 'interfaces'; import { ResourceType, SearchType } from 'interfaces';
import * as NavigationUtils from 'utils/navigationUtils'; import * as NavigationUtils from 'utils/navigationUtils';
import * as SearchUtils from 'ducks/search/utils'; import * as SearchUtils from 'ducks/search/utils';
...@@ -11,30 +10,20 @@ import * as API from '../api/v0'; ...@@ -11,30 +10,20 @@ import * as API from '../api/v0';
import * as Sagas from '../sagas'; import * as Sagas from '../sagas';
import { import {
initialState,
initialInlineResultsState,
loadPreviousSearch,
searchAll, searchAll,
searchAllFailure, searchAllFailure,
searchAllSuccess,
SearchReducerState,
searchResource, searchResource,
searchResourceFailure, searchResourceFailure,
searchResourceSuccess, searchResourceSuccess,
selectInlineResult,
submitSearch, submitSearch,
submitSearchResource, submitSearchResource,
updateFromInlineResult,
updateSearchState, updateSearchState,
urlDidUpdate, urlDidUpdate,
} from '../reducer'; } from '../reducer';
import { import {
LoadPreviousSearch, LoadPreviousSearch,
InlineSearch, InlineSearch,
InlineSearchResponsePayload,
InlineSearchUpdatePayload,
SearchAll, SearchAll,
SearchAllResponsePayload,
SearchResource, SearchResource,
SearchResponsePayload, SearchResponsePayload,
SubmitSearch, SubmitSearch,
...@@ -225,7 +214,7 @@ describe('search sagas', () => { ...@@ -225,7 +214,7 @@ describe('search sagas', () => {
searchType: SearchType.FILTER, searchType: SearchType.FILTER,
resourceFilters: { database: { hive: true } }, resourceFilters: { database: { hive: true } },
}); });
const { search_term, resource } = searchState; const { resource } = searchState;
testSaga(Sagas.submitSearchResourceWorker, filterAction) testSaga(Sagas.submitSearchResourceWorker, filterAction)
.next() .next()
.select(SearchUtils.getSearchState) .select(SearchUtils.getSearchState)
...@@ -243,7 +232,7 @@ describe('search sagas', () => { ...@@ -243,7 +232,7 @@ describe('search sagas', () => {
resourceFilters: { database: { hive: true } }, resourceFilters: { database: { hive: true } },
resource: ResourceType.table, resource: ResourceType.table,
}); });
const { search_term, resource } = searchState;
testSaga(Sagas.submitSearchResourceWorker, filterAction) testSaga(Sagas.submitSearchResourceWorker, filterAction)
.next() .next()
.select(SearchUtils.getSearchState) .select(SearchUtils.getSearchState)
...@@ -271,7 +260,7 @@ describe('search sagas', () => { ...@@ -271,7 +260,7 @@ describe('search sagas', () => {
it('it update url if necessary with existing state values', () => { it('it update url if necessary with existing state values', () => {
updateSearchUrlSpy.mockClear(); updateSearchUrlSpy.mockClear();
const action = updateSearchState({ updateUrl: true }); const action = updateSearchState({ updateUrl: true });
const { search_term, resource } = searchState;
testSaga(Sagas.updateSearchStateWorker, action) testSaga(Sagas.updateSearchStateWorker, action)
.next() .next()
.select(SearchUtils.getSearchState) .select(SearchUtils.getSearchState)
...@@ -291,7 +280,7 @@ describe('search sagas', () => { ...@@ -291,7 +280,7 @@ describe('search sagas', () => {
filters: { [ResourceType.table]: { database: { bigquery: true } } }, filters: { [ResourceType.table]: { database: { bigquery: true } } },
submitSearch: true, submitSearch: true,
}); });
const { search_term, resource } = searchState;
testSaga(Sagas.updateSearchStateWorker, action) testSaga(Sagas.updateSearchStateWorker, action)
.next() .next()
.select(SearchUtils.getSearchState) .select(SearchUtils.getSearchState)
...@@ -417,7 +406,7 @@ describe('search sagas', () => { ...@@ -417,7 +406,7 @@ describe('search sagas', () => {
it('applies the existing search state into the URL', () => { it('applies the existing search state into the URL', () => {
updateSearchUrlSpy.mockClear(); updateSearchUrlSpy.mockClear();
testSaga(Sagas.loadPreviousSearchWorker, loadPreviousSearch()) testSaga(Sagas.loadPreviousSearchWorker)
.next() .next()
.select(SearchUtils.getSearchState) .select(SearchUtils.getSearchState)
.next(searchState) .next(searchState)
......
import axios from 'axios';
import * as qs from 'simple-query-string'; import * as qs from 'simple-query-string';
import * as Utils from 'ducks/utilMethods'; import * as Utils from 'ducks/utilMethods';
import globalState from 'fixtures/globalState'; import globalState from 'fixtures/globalState';
import { relatedDashboards } from 'fixtures/metadata/table';
import { NotificationType, UpdateMethod, UpdateOwnerPayload } from 'interfaces'; import { NotificationType, UpdateMethod } from 'interfaces';
import * as Helpers from './helpers'; import * as Helpers from './helpers';
import * as API from './v0'; import * as API from './v0';
...@@ -17,7 +15,6 @@ jest.mock('axios'); ...@@ -17,7 +15,6 @@ jest.mock('axios');
describe('helpers', () => { describe('helpers', () => {
let mockResponseData: API.TableDataAPI; let mockResponseData: API.TableDataAPI;
let mockRelatedDashboardsResponseData: API.RelatedDashboardDataAPI;
let tableResponseData: API.TableData; let tableResponseData: API.TableData;
beforeAll(() => { beforeAll(() => {
tableResponseData = { tableResponseData = {
...@@ -35,10 +32,6 @@ describe('helpers', () => { ...@@ -35,10 +32,6 @@ describe('helpers', () => {
{ tag_count: 1, tag_name: 'aname' }, { tag_count: 1, tag_name: 'aname' },
], ],
}; };
mockRelatedDashboardsResponseData = {
dashboards: relatedDashboards,
msg: '',
};
mockResponseData = { mockResponseData = {
tableData: tableResponseData, tableData: tableResponseData,
msg: 'Success', msg: 'Success',
......
import * as qs from 'simple-query-string'; import * as qs from 'simple-query-string';
import { filterFromObj, sortTagsAlphabetical } from 'ducks/utilMethods'; import { filterFromObj } from 'ducks/utilMethods';
import { import {
NotificationType, NotificationType,
OwnerDict, OwnerDict,
PeopleUser, PeopleUser,
TableMetadata, TableMetadata,
Tag,
UpdateMethod, UpdateMethod,
UpdateOwnerPayload, UpdateOwnerPayload,
User, User,
......
...@@ -77,7 +77,7 @@ export function getTableDashboards(tableKey: string) { ...@@ -77,7 +77,7 @@ export function getTableDashboards(tableKey: string) {
if (response && response.data && response.data.msg) { if (response && response.data && response.data.msg) {
msg = response.data.msg; msg = response.data.msg;
} }
const status = response ? response.status : null;
return Promise.reject({ msg, dashboards: [] }); return Promise.reject({ msg, dashboards: [] });
}); });
} }
...@@ -126,7 +126,7 @@ export function generateOwnerUpdateRequests( ...@@ -126,7 +126,7 @@ export function generateOwnerUpdateRequests(
/* Chain requests to send notification on success to desired users */ /* Chain requests to send notification on success to desired users */
const request = axios(updatePayload) const request = axios(updatePayload)
.then((response) => { .then(() => {
return axios.get(`/api/metadata/v0/user?user_id=${item.id}`); return axios.get(`/api/metadata/v0/user?user_id=${item.id}`);
}) })
.then((response) => { .then((response) => {
......
...@@ -5,15 +5,13 @@ import { ...@@ -5,15 +5,13 @@ import {
PreviewQueryParams, PreviewQueryParams,
TableMetadata, TableMetadata,
Tag, Tag,
UpdateMethod,
UpdateOwnerPayload,
User, User,
} from 'interfaces'; } from 'interfaces';
import { dashboardSummary } from 'fixtures/metadata/dashboard'; import { dashboardSummary } from 'fixtures/metadata/dashboard';
import globalState from 'fixtures/globalState'; import globalState from 'fixtures/globalState';
import * as API from '../api/v0'; import * as API from './api/v0';
import reducer, { import reducer, {
getTableData, getTableData,
...@@ -31,11 +29,10 @@ import reducer, { ...@@ -31,11 +29,10 @@ import reducer, {
getPreviewData, getPreviewData,
getPreviewDataFailure, getPreviewDataFailure,
getPreviewDataSuccess, getPreviewDataSuccess,
initialPreviewState,
initialTableDataState, initialTableDataState,
initialState, initialState,
TableMetadataReducerState, TableMetadataReducerState,
} from '../reducer'; } from './reducer';
import { import {
getTableDataWatcher, getTableDataWatcher,
...@@ -50,7 +47,7 @@ import { ...@@ -50,7 +47,7 @@ import {
updateColumnDescriptionWorker, updateColumnDescriptionWorker,
getPreviewDataWatcher, getPreviewDataWatcher,
getPreviewDataWorker, getPreviewDataWorker,
} from '../sagas'; } from './sagas';
import { import {
GetTableData, GetTableData,
...@@ -59,7 +56,7 @@ import { ...@@ -59,7 +56,7 @@ import {
GetColumnDescription, GetColumnDescription,
UpdateColumnDescription, UpdateColumnDescription,
GetPreviewData, GetPreviewData,
} from '../types'; } from './types';
describe('tableMetadata ducks', () => { describe('tableMetadata ducks', () => {
let expectedData: TableMetadata; let expectedData: TableMetadata;
...@@ -68,7 +65,6 @@ describe('tableMetadata ducks', () => { ...@@ -68,7 +65,6 @@ describe('tableMetadata ducks', () => {
let expectedStatus: number; let expectedStatus: number;
let mockSuccess; let mockSuccess;
let mockFailure; let mockFailure;
let updatePayload: UpdateOwnerPayload[];
let testKey: string; let testKey: string;
let testIndex: string; let testIndex: string;
let testSource: string; let testSource: string;
...@@ -78,6 +74,7 @@ describe('tableMetadata ducks', () => { ...@@ -78,6 +74,7 @@ describe('tableMetadata ducks', () => {
let newDescription: string; let newDescription: string;
let previewData: PreviewData; let previewData: PreviewData;
let queryParams: PreviewQueryParams; let queryParams: PreviewQueryParams;
beforeAll(() => { beforeAll(() => {
expectedData = globalState.tableMetadata.tableData; expectedData = globalState.tableMetadata.tableData;
expectedOwners = { expectedOwners = {
...@@ -97,8 +94,6 @@ describe('tableMetadata ducks', () => { ...@@ -97,8 +94,6 @@ describe('tableMetadata ducks', () => {
mockSuccess = jest.fn().mockImplementation(() => {}); mockSuccess = jest.fn().mockImplementation(() => {});
mockFailure = jest.fn().mockImplementation(() => {}); mockFailure = jest.fn().mockImplementation(() => {});
updatePayload = [{ method: UpdateMethod.PUT, id: 'testId' }];
testKey = 'tableKey'; testKey = 'tableKey';
testIndex = '3'; testIndex = '3';
testSource = 'search'; testSource = 'search';
...@@ -443,7 +438,6 @@ describe('tableMetadata ducks', () => { ...@@ -443,7 +438,6 @@ describe('tableMetadata ducks', () => {
describe('handles request error', () => { describe('handles request error', () => {
let sagaTest; let sagaTest;
beforeAll(() => { beforeAll(() => {
const mockNewTableData: TableMetadata = initialTableDataState;
sagaTest = (action) => { sagaTest = (action) => {
return testSaga(getTableDescriptionWorker, action) return testSaga(getTableDescriptionWorker, action)
.next() .next()
...@@ -549,6 +543,7 @@ describe('tableMetadata ducks', () => { ...@@ -549,6 +543,7 @@ describe('tableMetadata ducks', () => {
let sagaTest; let sagaTest;
beforeAll(() => { beforeAll(() => {
const mockNewTableData: TableMetadata = initialTableDataState; const mockNewTableData: TableMetadata = initialTableDataState;
sagaTest = (action) => { sagaTest = (action) => {
return testSaga(getColumnDescriptionWorker, action) return testSaga(getColumnDescriptionWorker, action)
.next() .next()
...@@ -579,7 +574,6 @@ describe('tableMetadata ducks', () => { ...@@ -579,7 +574,6 @@ describe('tableMetadata ducks', () => {
describe('handles request error', () => { describe('handles request error', () => {
let sagaTest; let sagaTest;
beforeAll(() => { beforeAll(() => {
const mockNewTableData: TableMetadata = initialTableDataState;
sagaTest = (action) => { sagaTest = (action) => {
return testSaga(getColumnDescriptionWorker, action) return testSaga(getColumnDescriptionWorker, action)
.next() .next()
......
...@@ -4,7 +4,7 @@ import { OwnerDict, UpdateMethod, UpdateOwnerPayload } from 'interfaces'; ...@@ -4,7 +4,7 @@ import { OwnerDict, UpdateMethod, UpdateOwnerPayload } from 'interfaces';
import globalState from 'fixtures/globalState'; import globalState from 'fixtures/globalState';
import * as API from '../../api/v0'; import * as API from '../api/v0';
import reducer, { import reducer, {
updateTableOwner, updateTableOwner,
...@@ -12,20 +12,18 @@ import reducer, { ...@@ -12,20 +12,18 @@ import reducer, {
updateTableOwnerSuccess, updateTableOwnerSuccess,
initialOwnersState, initialOwnersState,
TableOwnerReducerState, TableOwnerReducerState,
} from '../reducer'; } from './reducer';
import { import {
getTableData, getTableData,
getTableDataFailure, getTableDataFailure,
getTableDataSuccess, getTableDataSuccess,
} from '../../reducer'; } from '../reducer';
import { updateTableOwnerWorker, updateTableOwnerWatcher } from '../sagas'; import { updateTableOwnerWorker, updateTableOwnerWatcher } from './sagas';
import { GetTableData, UpdateTableOwner } from '../../types'; import { UpdateTableOwner } from '../types';
const generateOwnerUpdateRequestsSpy = jest jest.spyOn(API, 'generateOwnerUpdateRequests').mockImplementation(() => []);
.spyOn(API, 'generateOwnerUpdateRequests')
.mockImplementation((payload, key) => []);
describe('tableMetadata:owners ducks', () => { describe('tableMetadata:owners ducks', () => {
let expectedOwners: OwnerDict; let expectedOwners: OwnerDict;
......
...@@ -5,7 +5,6 @@ import { ...@@ -5,7 +5,6 @@ import {
PreviewQueryParams, PreviewQueryParams,
TableMetadata, TableMetadata,
Tag, Tag,
User,
} from 'interfaces'; } from 'interfaces';
import { import {
......
...@@ -25,10 +25,12 @@ describe('getAllTags', () => { ...@@ -25,10 +25,12 @@ describe('getAllTags', () => {
config: {}, config: {},
}; };
const axiosMock = jest jest
.spyOn(axios, 'get') .spyOn(axios, 'get')
.mockImplementation(() => Promise.resolve(mockResponse)); .mockImplementation(() => Promise.resolve(mockResponse));
expect.assertions(1); expect.assertions(1);
await API.getAllTags().then((sortedTags) => { await API.getAllTags().then((sortedTags) => {
expect(sortedTags).toEqual(expectedTags); expect(sortedTags).toEqual(expectedTags);
}); });
......
...@@ -11,19 +11,19 @@ ...@@ -11,19 +11,19 @@
"build": "cross-env TS_NODE_PROJECT='tsconfig.webpack.json' webpack --progress --config webpack.prod.ts", "build": "cross-env TS_NODE_PROJECT='tsconfig.webpack.json' webpack --progress --config webpack.prod.ts",
"dev-build": "cross-env TS_NODE_PROJECT='tsconfig.webpack.json' webpack --progress --config webpack.dev.ts", "dev-build": "cross-env TS_NODE_PROJECT='tsconfig.webpack.json' webpack --progress --config webpack.dev.ts",
"test": "cross-env TZ=UTC jest --coverage --collectCoverageFrom=js/**/*.{js,jsx,ts,tsx}", "test": "cross-env TZ=UTC jest --coverage --collectCoverageFrom=js/**/*.{js,jsx,ts,tsx}",
"test:watch": "cross-env TZ=UTC jest --watch",
"posttest": "npm run format", "posttest": "npm run format",
"test-nocov": "cross-env TZ=UTC jest", "test-nocov": "cross-env TZ=UTC jest",
"watch": "cross-env TS_NODE_PROJECT='tsconfig.webpack.json' webpack --progress --config webpack.dev.ts --watch", "watch": "cross-env TS_NODE_PROJECT='tsconfig.webpack.json' webpack --progress --config webpack.dev.ts --watch",
"lint": "npm run eslint", "lint": "npm run eslint",
"lint-fix": "npm run eslint-fix", "lint:fix": "npm run eslint:fix",
"eslint": "eslint --ignore-path=.eslintignore --ext .js,.jsx,.ts,.tsx .", "eslint": "eslint --ignore-path=.eslintignore --ext .js,.jsx,.ts,.tsx .",
"eslint:errors": "eslint --ignore-path=.eslintignore --quiet --ext .js,.jsx,.ts,.tsx .", "eslint:errors": "eslint --ignore-path=.eslintignore --quiet --ext .js,.jsx,.ts,.tsx .",
"eslint-fix": "eslint --fix --ignore-path=.eslintignore --ext .js,.jsx,.ts,.tsx .", "eslint:fix": "eslint --fix --ignore-path=.eslintignore --ext .js,.jsx,.ts,.tsx .",
"test:watch": "cross-env TZ=UTC jest --watch",
"tsc": "tsc", "tsc": "tsc",
"clean-sass-vars": "find-unused-sass-variables ./js", "clean-sass-vars": "find-unused-sass-variables ./js",
"stylelint": "stylelint '**/*.scss'", "stylelint": "stylelint '**/*.scss'",
"stylelint-fix": "stylelint --fix '**/*.scss'", "stylelint:fix": "stylelint --fix '**/*.scss'",
"format": "prettier --loglevel warn --write \"**/*.{ts,tsx,css,scss}\"", "format": "prettier --loglevel warn --write \"**/*.{ts,tsx,css,scss}\"",
"storybook": "cross-env TS_NODE_PROJECT='tsconfig.webpack.json' start-storybook -p 6006", "storybook": "cross-env TS_NODE_PROJECT='tsconfig.webpack.json' start-storybook -p 6006",
"build-storybook": "cross-env TS_NODE_PROJECT='tsconfig.webpack.json' build-storybook" "build-storybook": "cross-env TS_NODE_PROJECT='tsconfig.webpack.json' build-storybook"
...@@ -290,7 +290,6 @@ ...@@ -290,7 +290,6 @@
"never" "never"
], ],
"@typescript-eslint/dot-notation": "warn", "@typescript-eslint/dot-notation": "warn",
"@typescript-eslint/lines-between-class-members": "warn",
"@typescript-eslint/naming-convention": "warn", "@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/no-unused-vars": "warn", "@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/member-delimiter-style": [ "@typescript-eslint/member-delimiter-style": [
...@@ -550,7 +549,7 @@ ...@@ -550,7 +549,7 @@
], ],
"*.scss": [ "*.scss": [
"prettier --write", "prettier --write",
"npm run stylelint-fix" "npm run stylelint:fix"
] ]
} }
} }
...@@ -52,7 +52,7 @@ To run specific tests, run `npm run test-nocov -t <regex>`, where `<regex>` is a ...@@ -52,7 +52,7 @@ To run specific tests, run `npm run test-nocov -t <regex>`, where `<regex>` is a
### Developing React Components ### Developing React Components
To preview React components in isolation, use [Storybook](https://storybook.js.org/). Just add a `<componentName>.story.tsx` file in the same folder as your component. In that file, show your component in different states. Then run `npm run storybook`, which will open your browser to the storybook browse page. To preview React components in isolation, use [Storybook](https://storybook.js.org/). Just add a `<componentName>.story.tsx` file in the same folder as your component. In that file, show your component in different states. Then run `npm run storybook`, which will open your browser to the storybook browse page.
Using Storybook makes it much easier to quickly iterate on components when getting to certain states requires multiple steps of UI manipulation. The gallery also serves as a convenient place to see what reusable components are available so you can avoid reinventing the wheel. Using Storybook makes it much easier to quickly iterate on components when getting to certain states requires multiple steps of UI manipulation. The gallery also serves as a convenient place to see what reusable components are available so you can avoid reinventing the wheel.
...@@ -68,8 +68,8 @@ We also use [Prettier][prettier] to help us keep consistent formatting on our Ty ...@@ -68,8 +68,8 @@ We also use [Prettier][prettier] to help us keep consistent formatting on our Ty
Whenever you want to run these tasks manually, you can execute: Whenever you want to run these tasks manually, you can execute:
- `npm run lint` to run ESLint and `npm run lint-fix` to auto-fix most of them. - `npm run lint` to run ESLint and `npm run lint:fix` to auto-fix most of them.
- `npm run stylelint` to run Stylelint and `npm run stylelint-fix` to trigger the auto-fix. - `npm run stylelint` to run Stylelint and `npm run stylelint:fix` to trigger the auto-fix.
- `npm run format` to run Prettier on both the TypeScript and Sass files - `npm run format` to run Prettier on both the TypeScript and Sass files
We also check your changed files and format them when you create a new commit, making it easy for you and for the project to keep a consistent code style. We do this leveraging [Husky][husky] and [Lint-staged][lint-staged]. We also check your changed files and format them when you create a new commit, making it easy for you and for the project to keep a consistent code style. We do this leveraging [Husky][husky] and [Lint-staged][lint-staged].
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment