Enabled @typescript-eslint/unbound-method eslint rule again

This commit is contained in:
Alejandro Celaya 2021-02-28 17:21:26 +01:00
parent c8f8416c06
commit 86544f4b24
4 changed files with 18 additions and 22 deletions

View file

@ -16,7 +16,7 @@
},
"rules": {
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-return": "off",

View file

@ -10,6 +10,6 @@ export interface GroupedNewVisits {
export const groupNewVisitsByType = pipe(
groupBy((newVisit: CreateVisit) => isOrphanVisit(newVisit.visit) ? 'orphanVisits' : 'regularVisits'),
// @ts-ignore-error Type declaration on groupBy is not correct. It can return undefined props
// @ts-expect-error Type declaration on groupBy is not correct. It can return undefined props
(result): GroupedNewVisits => ({ orphanVisits: [], regularVisits: [], ...result }),
);

View file

@ -9,16 +9,15 @@ describe('ServersExporter', () => {
click: jest.fn(),
style: {},
});
const appendChild = jest.fn();
const removeChild = jest.fn();
const createWindowMock = (isIe10 = true) => Mock.of<Window>({
navigator: {
msSaveBlob: isIe10 ? jest.fn() : undefined,
},
document: {
createElement: jest.fn(() => createLinkMock()),
body: {
appendChild: jest.fn(),
removeChild: jest.fn(),
},
body: { appendChild, removeChild },
},
});
const storageMock = Mock.of<LocalStorage>({
@ -33,15 +32,14 @@ describe('ServersExporter', () => {
},
})),
});
const createCsvjsonMock = (throwError = false) => Mock.of<CsvJson>({
toCSV: jest.fn(() => {
if (throwError) {
throw new Error('');
}
return '';
}),
const erroneousToCsv = jest.fn(() => {
throw new Error('');
});
const createCsvjsonMock = (throwError = false) => Mock.of<CsvJson>({
toCSV: throwError ? erroneousToCsv : jest.fn(() => ''),
});
beforeEach(jest.clearAllMocks);
describe('exportServers', () => {
let originalConsole: Console;
@ -61,12 +59,11 @@ describe('ServersExporter', () => {
it('logs an error if something fails', () => {
const csvjsonMock = createCsvjsonMock(true);
const exporter = new ServersExporter(storageMock, createWindowMock(), csvjsonMock);
const { toCSV } = csvjsonMock;
exporter.exportServers();
expect(error).toHaveBeenCalledTimes(1);
expect(toCSV).toHaveBeenCalledTimes(1);
expect(erroneousToCsv).toHaveBeenCalledTimes(1);
});
it('makes use of msSaveBlob API when available', () => {
@ -84,8 +81,7 @@ describe('ServersExporter', () => {
it('makes use of download link API when available', () => {
const windowMock = createWindowMock(false);
const exporter = new ServersExporter(storageMock, windowMock, createCsvjsonMock());
const { document: { createElement, body } } = windowMock;
const { appendChild, removeChild } = body;
const { document: { createElement } } = windowMock;
exporter.exportServers();

View file

@ -25,7 +25,7 @@ describe('<DefaultChart />', () => {
const { labels, datasets } = doughnut.prop('data') as any;
const [{ title, data, backgroundColor, borderColor }] = datasets;
const { legend, legendCallback, scales } = doughnut.prop('options') ?? {};
const { legend, scales, ...options } = doughnut.prop('options') ?? {};
expect(title).toEqual('The chart');
expect(labels).toEqual(keys(stats));
@ -46,7 +46,7 @@ describe('<DefaultChart />', () => {
]);
expect(borderColor).toEqual('white');
expect(legend).toEqual({ display: false });
expect(typeof legendCallback).toEqual('function');
expect(typeof options.legendCallback).toEqual('function');
expect(scales).toBeUndefined();
expect(cols).toHaveLength(2);
});
@ -61,12 +61,12 @@ describe('<DefaultChart />', () => {
expect(horizontal).toHaveLength(1);
const { datasets: [{ backgroundColor, borderColor }] } = horizontal.prop('data') as any;
const { legend, legendCallback, scales } = horizontal.prop('options') ?? {};
const { legend, scales, ...options } = horizontal.prop('options') ?? {};
expect(backgroundColor).toEqual(MAIN_COLOR_ALPHA);
expect(borderColor).toEqual(MAIN_COLOR);
expect(legend).toEqual({ display: false });
expect(legendCallback).toEqual(false);
expect(typeof options.legendCallback).toEqual('boolean');
expect(scales).toEqual({
xAxes: [
{