style: eslint curly rule (#11913)

* style: eslint curly rule

* curly for ts
This commit is contained in:
Evan Rusackas 2020-12-03 10:20:05 -08:00 committed by GitHub
parent 8c063efa75
commit 38b720b0a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 11 deletions

View File

@ -80,6 +80,7 @@ module.exports = {
'@typescript-eslint/explicit-module-boundary-types': 0, // re-enable up for discussion '@typescript-eslint/explicit-module-boundary-types': 0, // re-enable up for discussion
camelcase: 0, camelcase: 0,
'class-methods-use-this': 0, 'class-methods-use-this': 0,
curly: 1,
'func-names': 0, 'func-names': 0,
'guard-for-in': 0, 'guard-for-in': 0,
'import/no-cycle': 0, // re-enable up for discussion, might require some major refactors 'import/no-cycle': 0, // re-enable up for discussion, might require some major refactors
@ -189,6 +190,7 @@ module.exports = {
}, },
], ],
'class-methods-use-this': 0, 'class-methods-use-this': 0,
curly: 1,
'func-names': 0, 'func-names': 0,
'guard-for-in': 0, 'guard-for-in': 0,
'import/extensions': [ 'import/extensions': [

View File

@ -421,18 +421,21 @@ class DatasourceEditor extends React.PureComponent {
SupersetClient.get({ endpoint }) SupersetClient.get({ endpoint })
.then(({ json }) => { .then(({ json }) => {
const results = this.updateColumns(json); const results = this.updateColumns(json);
if (results.modified.length) if (results.modified.length) {
this.props.addSuccessToast( this.props.addSuccessToast(
t('Modified columns: %s', results.modified.join(', ')), t('Modified columns: %s', results.modified.join(', ')),
); );
if (results.removed.length) }
if (results.removed.length) {
this.props.addSuccessToast( this.props.addSuccessToast(
t('Removed columns: %s', results.removed.join(', ')), t('Removed columns: %s', results.removed.join(', ')),
); );
if (results.added.length) }
if (results.added.length) {
this.props.addSuccessToast( this.props.addSuccessToast(
t('New columns added: %s', results.added.join(', ')), t('New columns added: %s', results.added.join(', ')),
); );
}
this.props.addSuccessToast(t('Metadata has been synced')); this.props.addSuccessToast(t('Metadata has been synced'));
this.setState({ metadataLoading: false }); this.setState({ metadataLoading: false });
}) })

View File

@ -57,10 +57,11 @@ export default function downloadAsImage(
return (event: SyntheticEvent) => { return (event: SyntheticEvent) => {
const elementToPrint = event.currentTarget.closest(selector); const elementToPrint = event.currentTarget.closest(selector);
if (!elementToPrint) if (!elementToPrint) {
return addWarningToast( return addWarningToast(
t('Image download failed, please refresh and try again.'), t('Image download failed, please refresh and try again.'),
); );
}
return domToImage return domToImage
.toJpeg(elementToPrint, { .toJpeg(elementToPrint, {

View File

@ -167,7 +167,7 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
original: { kind }, original: { kind },
}, },
}: any) => { }: any) => {
if (kind === 'physical') if (kind === 'physical') {
return ( return (
<TooltipWrapper <TooltipWrapper
label="physical-dataset" label="physical-dataset"
@ -176,6 +176,7 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
<Icon name="dataset-physical" /> <Icon name="dataset-physical" />
</TooltipWrapper> </TooltipWrapper>
); );
}
return ( return (
<TooltipWrapper <TooltipWrapper
@ -582,8 +583,9 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
const { virtualCount, physicalCount } = selected.reduce( const { virtualCount, physicalCount } = selected.reduce(
(acc, e) => { (acc, e) => {
if (e.original.kind === 'physical') acc.physicalCount += 1; if (e.original.kind === 'physical') acc.physicalCount += 1;
else if (e.original.kind === 'virtual') else if (e.original.kind === 'virtual') {
acc.virtualCount += 1; acc.virtualCount += 1;
}
return acc; return acc;
}, },
{ virtualCount: 0, physicalCount: 0 }, { virtualCount: 0, physicalCount: 0 },

View File

@ -98,8 +98,9 @@ describe('QueryPreviewModal', () => {
.first() .first()
.props(); .props();
if (typeof props.onClick === 'function') if (typeof props.onClick === 'function') {
props.onClick({} as React.MouseEvent); props.onClick({} as React.MouseEvent);
}
}); });
wrapper.update(); wrapper.update();
@ -129,8 +130,9 @@ describe('QueryPreviewModal', () => {
.find('[data-test="previous-query"]') .find('[data-test="previous-query"]')
.first() .first()
.props(); .props();
if (typeof props.onClick === 'function') if (typeof props.onClick === 'function') {
props.onClick({} as React.MouseEvent); props.onClick({} as React.MouseEvent);
}
}); });
expect(mockedProps2.fetchData).toHaveBeenCalledWith(0); expect(mockedProps2.fetchData).toHaveBeenCalledWith(0);
@ -141,8 +143,9 @@ describe('QueryPreviewModal', () => {
it('calls fetchData with next index', () => { it('calls fetchData with next index', () => {
act(() => { act(() => {
const props = wrapper.find('[data-test="next-query"]').first().props(); const props = wrapper.find('[data-test="next-query"]').first().props();
if (typeof props.onClick === 'function') if (typeof props.onClick === 'function') {
props.onClick({} as React.MouseEvent); props.onClick({} as React.MouseEvent);
}
}); });
expect(mockedProps.fetchData).toHaveBeenCalledWith(1); expect(mockedProps.fetchData).toHaveBeenCalledWith(1);
@ -170,8 +173,9 @@ describe('QueryPreviewModal', () => {
.first() .first()
.props(); .props();
if (typeof props.onClick === 'function') if (typeof props.onClick === 'function') {
props.onClick({} as React.MouseEvent); props.onClick({} as React.MouseEvent);
}
expect(mockedProps.openInSqlLab).toHaveBeenCalled(); expect(mockedProps.openInSqlLab).toHaveBeenCalled();
}); });

View File

@ -214,8 +214,9 @@ const SavedQueries = ({
)} )}
<Menu.Item <Menu.Item
onClick={() => { onClick={() => {
if (query.id) if (query.id) {
copyQueryLink(query.id, addDangerToast, addSuccessToast); copyQueryLink(query.id, addDangerToast, addSuccessToast);
}
}} }}
> >
{t('Share')} {t('Share')}