Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

Commit

Permalink
chore: upgrade eslint and babel
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmud committed Jan 10, 2021
1 parent 543e6b1 commit 950f236
Show file tree
Hide file tree
Showing 36 changed files with 450 additions and 426 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ name: Upload Chomatic Build

on:
workflow_run:
workflows: ["build-and-test-workflow"]
workflows: ['build-and-test-workflow']
types:
- completed

jobs:
upload:
runs-on: ubuntu-latest
if: >
${{ github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success' }}
${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion
== 'success' }}
steps:
- name: 'Download artifact'
uses: actions/github-script@v3.1.0
Expand Down
38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,32 +77,32 @@
"@typescript-eslint/eslint-plugin": "^4.1.0",
"@typescript-eslint/parser": "^4.1.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.1.0",
"babel-loader": "^8.0.6",
"babel-plugin-dynamic-import-node": "^2.3.0",
"babel-plugin-emotion": "^10.0.29",
"babel-jest": "^26.6.3",
"babel-loader": "^8.2.2",
"babel-plugin-dynamic-import-node": "^2.3.3",
"babel-plugin-emotion": "^11.0.0",
"babel-plugin-jsx-remove-data-test-id": "^2.1.3",
"babel-plugin-lodash": "^3.3.4",
"babel-plugin-typescript-to-proptypes": "^1.4.2",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.1",
"enzyme-to-json": "^3.4.3",
"eslint": "^7.8.1",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint": "^7.17.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^7.1.0",
"eslint-import-resolver-typescript": "^2.3.0",
"eslint-import-resolver-webpack": "^0.12.2",
"eslint-plugin-cypress": "^2.11.1",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^23.17.1",
"eslint-plugin-jest-dom": "^3.2.4",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-no-only-tests": "^2.0.1",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-react": "^7.20.6",
"eslint-plugin-react-hooks": "^4.1.2",
"eslint-import-resolver-webpack": "^0.13.0",
"eslint-plugin-cypress": "^2.11.2",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.1.3",
"eslint-plugin-jest-dom": "^3.6.5",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-no-only-tests": "^2.4.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-testing-library": "^3.10.1",
"eslint-plugin-unicorn": "^23.0.0",
"eslint-plugin-unicorn": "^25.0.1",
"esprint": "^0.7.0",
"fast-glob": "^3.2.4",
"fs-extra": "^9.0.0",
Expand All @@ -116,7 +116,7 @@
"jsdom": "^16.4.0",
"lerna": "^3.15.0",
"lint-staged": "^10.0.3",
"prettier": "^2.1.1",
"prettier": "^2.2.1",
"react": "^16.13.1",
"react-bootstrap": "^0.33.1",
"react-dom": "^16.13.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function MetricOption({
}: MetricOptionProps) {
const verbose = metric.verbose_name || metric.metric_name || metric.label;
const link = url ? (
<a href={url} target={openInNewWindow ? '_blank' : ''}>
<a href={url} target={openInNewWindow ? '_blank' : ''} rel="noreferrer">
{verbose}
</a>
) : (
Expand Down
20 changes: 8 additions & 12 deletions packages/superset-ui-chart-controls/src/shared-controls/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,11 @@ const metrics: SharedControlConfig<'MetricsControl'> = {
const metric = mainMetric(c.savedMetrics);
return metric ? [metric] : null;
},
mapStateToProps: ({ datasource }) => {
return {
columns: datasource ? datasource.columns : [],
savedMetrics: datasource ? datasource.metrics : [],
datasourceType: datasource?.type,
};
},
mapStateToProps: ({ datasource }) => ({
columns: datasource ? datasource.columns : [],
savedMetrics: datasource ? datasource.metrics : [],
datasourceType: datasource?.type,
}),
description: t('One or many metrics to display'),
};

Expand All @@ -166,11 +164,9 @@ const datasourceControl: SharedControlConfig<'DatasourceControl'> = {
label: t('Datasource'),
default: null,
description: null,
mapStateToProps: ({ datasource }) => {
return {
datasource,
};
},
mapStateToProps: ({ datasource }) => ({
datasource,
}),
};

const viz_type: SharedControlConfig<'VizTypeControl'> = {
Expand Down
6 changes: 3 additions & 3 deletions packages/superset-ui-core/src/chart/clients/ChartClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ export default class ChartClient {
...options,
};

return this.client.post(requestConfig).then(response => {
return Array.isArray(response.json) ? response.json : [response.json];
});
return this.client
.post(requestConfig)
.then(response => (Array.isArray(response.json) ? response.json : [response.json]));
}

return Promise.reject(new Error(`Unknown chart type: ${visType}`));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ export async function defineSharedModule(name: string, fetchModule: () => Promis
*/
export async function defineSharedModules(moduleMap: { [key: string]: () => Promise<Module> }) {
return Promise.all(
Object.entries(moduleMap).map(([name, fetchModule]) => {
return defineSharedModule(name, fetchModule);
}),
Object.entries(moduleMap).map(([name, fetchModule]) => defineSharedModule(name, fetchModule)),
);
}

Expand Down
2 changes: 2 additions & 0 deletions packages/superset-ui-core/src/models/Registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export default class Registry<V, W extends V | Promise<V> = V | Promise<V>> {
this.has(key) && (('value' in item && item.value !== value) || 'loader' in item);
if (willOverwrite) {
if (this.overwritePolicy === OverwritePolicy.WARN) {
// eslint-disable-next-line no-console
console.warn(`Item with key "${key}" already exists. You are assigning a new value.`);
} else if (this.overwritePolicy === OverwritePolicy.PROHIBIT) {
throw new Error(`Item with key "${key}" already exists. Cannot overwrite.`);
Expand All @@ -105,6 +106,7 @@ export default class Registry<V, W extends V | Promise<V> = V | Promise<V>> {
this.has(key) && (('loader' in item && item.loader !== loader) || 'value' in item);
if (willOverwrite) {
if (this.overwritePolicy === OverwritePolicy.WARN) {
// eslint-disable-next-line no-console
console.warn(`Item with key "${key}" already exists. You are assigning a new value.`);
} else if (this.overwritePolicy === OverwritePolicy.PROHIBIT) {
throw new Error(`Item with key "${key}" already exists. Cannot overwrite.`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,31 +88,29 @@ describe('ChartDataProvider', () => {
});

describe('ChartClient.loadDatasource', () => {
it('does not method if loadDatasource is false', () => {
return new Promise(done => {
it('does not method if loadDatasource is false', () =>
new Promise(done => {
expect.assertions(1);
setup({ loadDatasource: false });
setTimeout(() => {
expect(mockLoadDatasource.mock.calls).toHaveLength(0);
done();
}, 0);
});
});
}));

it('calls method on mount if loadDatasource is true', () => {
return new Promise(done => {
it('calls method on mount if loadDatasource is true', () =>
new Promise(done => {
expect.assertions(2);
setup({ loadDatasource: true });
setTimeout(() => {
expect(mockLoadDatasource.mock.calls).toHaveLength(1);
expect(mockLoadDatasource.mock.calls[0][0]).toEqual(props.formData.datasource);
done();
}, 0);
});
});
}));

it('should pass datasourceRequestOptions to ChartClient.loadDatasource', () => {
return new Promise(done => {
it('should pass datasourceRequestOptions to ChartClient.loadDatasource', () =>
new Promise(done => {
expect.assertions(2);
const options = { host: 'override' };
setup({ loadDatasource: true, datasourceRequestOptions: options });
Expand All @@ -121,11 +119,10 @@ describe('ChartDataProvider', () => {
expect(mockLoadDatasource.mock.calls[0][1]).toEqual(options);
done();
}, 0);
});
});
}));

it('calls ChartClient.loadDatasource if loadDatasource is true and formData or sliceId change', () => {
return new Promise(done => {
it('calls ChartClient.loadDatasource if loadDatasource is true and formData or sliceId change', () =>
new Promise(done => {
expect.assertions(3);
const newDatasource = 'test';
const wrapper = setup({ loadDatasource: true });
Expand All @@ -137,25 +134,23 @@ describe('ChartDataProvider', () => {
expect(mockLoadDatasource.mock.calls[1][0]).toEqual(newDatasource);
done();
}, 0);
});
});
}));
});

describe('ChartClient.loadQueryData', () => {
it('calls method on mount', () => {
return new Promise(done => {
it('calls method on mount', () =>
new Promise(done => {
expect.assertions(2);
setup();
setTimeout(() => {
expect(mockLoadQueryData.mock.calls).toHaveLength(1);
expect(mockLoadQueryData.mock.calls[0][0]).toEqual(props.formData);
done();
}, 0);
});
});
}));

it('should pass queryDataRequestOptions to ChartClient.loadQueryData', () => {
return new Promise(done => {
it('should pass queryDataRequestOptions to ChartClient.loadQueryData', () =>
new Promise(done => {
expect.assertions(2);
const options = { host: 'override' };
setup({ queryRequestOptions: options });
Expand All @@ -164,11 +159,10 @@ describe('ChartDataProvider', () => {
expect(mockLoadQueryData.mock.calls[0][1]).toEqual(options);
done();
}, 0);
});
});
}));

it('calls ChartClient.loadQueryData when formData or sliceId change', () => {
return new Promise(done => {
it('calls ChartClient.loadQueryData when formData or sliceId change', () =>
new Promise(done => {
expect.assertions(3);
const newFormData = { key: 'test' };
const wrapper = setup();
Expand All @@ -180,8 +174,7 @@ describe('ChartDataProvider', () => {
expect(mockLoadQueryData.mock.calls[1][0]).toEqual(newFormData);
done();
}, 0);
});
});
}));
});

describe('children', () => {
Expand All @@ -194,8 +187,8 @@ describe('ChartDataProvider', () => {
expect(children.mock.calls[0][0]).toEqual({ loading: true });
});

it('calls children({ payload }) when loaded', () => {
return new Promise(done => {
it('calls children({ payload }) when loaded', () =>
new Promise(done => {
expect.assertions(2);
const children = jest.fn<React.ReactNode, unknown[]>();
setup({ children, loadDatasource: true });
Expand All @@ -211,11 +204,10 @@ describe('ChartDataProvider', () => {
});
done();
}, 0);
});
});
}));

it('calls children({ error }) upon request error', () => {
return new Promise(done => {
it('calls children({ error }) upon request error', () =>
new Promise(done => {
expect.assertions(2);
const children = jest.fn<React.ReactNode, unknown[]>();
mockLoadFormData = jest.fn(() => Promise.reject(new Error('error')));
Expand All @@ -227,11 +219,10 @@ describe('ChartDataProvider', () => {
expect(children.mock.calls[1][0]).toEqual({ error: new Error('error') });
done();
}, 0);
});
});
}));

it('calls children({ error }) upon JS error', () => {
return new Promise(done => {
it('calls children({ error }) upon JS error', () =>
new Promise(done => {
expect.assertions(2);
const children = jest.fn<React.ReactNode, unknown[]>();

Expand All @@ -246,13 +237,12 @@ describe('ChartDataProvider', () => {
expect(children.mock.calls[1][0]).toEqual({ error: new Error('non-async error') });
done();
}, 0);
});
});
}));
});

describe('callbacks', () => {
it('calls onLoad(payload) when loaded', () => {
return new Promise(done => {
it('calls onLoad(payload) when loaded', () =>
new Promise(done => {
expect.assertions(2);
const onLoaded = jest.fn<void, unknown[]>();
setup({ onLoaded, loadDatasource: true });
Expand All @@ -266,11 +256,10 @@ describe('ChartDataProvider', () => {
});
done();
}, 0);
});
});
}));

it('calls onError(error) upon request error', () => {
return new Promise(done => {
it('calls onError(error) upon request error', () =>
new Promise(done => {
expect.assertions(2);
const onError = jest.fn<void, unknown[]>();
mockLoadFormData = jest.fn(() => Promise.reject(new Error('error')));
Expand All @@ -281,11 +270,10 @@ describe('ChartDataProvider', () => {
expect(onError.mock.calls[0][0]).toEqual(new Error('error'));
done();
}, 0);
});
});
}));

it('calls onError(error) upon JS error', () => {
return new Promise(done => {
it('calls onError(error) upon JS error', () =>
new Promise(done => {
expect.assertions(2);
const onError = jest.fn<void, unknown[]>();

Expand All @@ -299,7 +287,6 @@ describe('ChartDataProvider', () => {
expect(onError.mock.calls[0][0]).toEqual(new Error('non-async error'));
done();
}, 0);
});
});
}));
});
});
Loading

0 comments on commit 950f236

Please sign in to comment.