mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 01:20:24 +03:00
Fixed coding styles and ensured linting command applies to ts and tsx files
This commit is contained in:
parent
f9c57ca659
commit
4083592212
7 changed files with 23 additions and 21 deletions
6
package-lock.json
generated
6
package-lock.json
generated
|
@ -22525,9 +22525,9 @@
|
|||
}
|
||||
},
|
||||
"typescript": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.2.tgz",
|
||||
"integrity": "sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ==",
|
||||
"version": "3.9.7",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.7.tgz",
|
||||
"integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==",
|
||||
"dev": true
|
||||
},
|
||||
"uglify-es": {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
"license": "MIT",
|
||||
"scripts": {
|
||||
"lint": "npm run lint:js && npm run lint:css",
|
||||
"lint:js": "eslint src test scripts config",
|
||||
"lint:js": "eslint --ext .js,.ts,.tsx src test scripts config",
|
||||
"lint:js:fix": "npm run lint:js -- --fix",
|
||||
"lint:css": "stylelint src/*.scss src/**/*.scss",
|
||||
"lint:css:fix": "npm run lint:css -- --fix",
|
||||
|
@ -148,7 +148,7 @@
|
|||
"terser-webpack-plugin": "^2.1.2",
|
||||
"ts-jest": "^26.0.0",
|
||||
"ts-mockery": "^1.2.0",
|
||||
"typescript": "^4.0.2",
|
||||
"typescript": "^3.9.7",
|
||||
"url-loader": "^2.2.0",
|
||||
"webpack": "^4.41.0",
|
||||
"webpack-dev-server": "^3.8.2",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Action, Dispatch } from 'redux';
|
||||
import { buildActionCreator, buildReducer } from '../../utils/helpers/redux';
|
||||
import { ProblemDetailsError} from '../../utils/services/types';
|
||||
import { ProblemDetailsError } from '../../utils/services/types';
|
||||
import { GetState } from '../../container/types';
|
||||
import { ShlinkApiClientBuilder } from '../../utils/services/ShlinkApiClientBuilder';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import React, { FC } from 'react';
|
||||
import { Modal, ModalBody } from 'reactstrap';
|
||||
import { Map, TileLayer, Marker, Popup, MapProps } from 'react-leaflet';
|
||||
import { Map, TileLayer, Marker, Popup } from 'react-leaflet';
|
||||
import { prop } from 'ramda';
|
||||
import { CityStats } from '../types';
|
||||
import './MapModal.scss';
|
||||
|
@ -19,7 +19,7 @@ const OpenStreetMapTile: FC = () => (
|
|||
/>
|
||||
);
|
||||
|
||||
const calculateMapProps = (locations: CityStats[]): Partial<MapProps> => {
|
||||
const calculateMapProps = (locations: CityStats[]): any => {
|
||||
if (locations.length === 0) {
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ export const getShortUrlVisits = (buildShlinkApiClient: ShlinkApiClientBuilder)
|
|||
query: { domain?: OptionalString } = {},
|
||||
) => async (dispatch: Dispatch, getState: GetState) => {
|
||||
const { getShortUrlVisits } = buildShlinkApiClient(getState);
|
||||
const visitsLoader = (page: number, itemsPerPage: number) => getShortUrlVisits(
|
||||
const visitsLoader = async (page: number, itemsPerPage: number) => getShortUrlVisits(
|
||||
shortCode,
|
||||
{ ...query, page, itemsPerPage },
|
||||
);
|
||||
|
|
|
@ -68,7 +68,10 @@ export const getTagVisits = (buildShlinkApiClient: ShlinkApiClientBuilder) => (t
|
|||
getState: GetState,
|
||||
) => {
|
||||
const { getTagVisits } = buildShlinkApiClient(getState);
|
||||
const visitsLoader = (page: number, itemsPerPage: number) => getTagVisits(tag, { ...query, page, itemsPerPage });
|
||||
const visitsLoader = async (page: number, itemsPerPage: number) => getTagVisits(
|
||||
tag,
|
||||
{ ...query, page, itemsPerPage },
|
||||
);
|
||||
const extraFinishActionData: Partial<TagVisitsAction> = { tag };
|
||||
const actionMap = {
|
||||
start: GET_TAG_VISITS_START,
|
||||
|
|
|
@ -8,27 +8,26 @@ import reducer, {
|
|||
deleteShortUrl,
|
||||
} from '../../../src/short-urls/reducers/shortUrlDeletion';
|
||||
import { ProblemDetailsError } from '../../../src/utils/services/types';
|
||||
import ShlinkApiClient from '../../../src/utils/services/ShlinkApiClient';
|
||||
|
||||
describe('shortUrlDeletionReducer', () => {
|
||||
describe('reducer', () => {
|
||||
|
||||
|
||||
it('returns loading on DELETE_SHORT_URL_START', () =>
|
||||
expect(reducer(undefined, { type: DELETE_SHORT_URL_START })).toEqual({
|
||||
expect(reducer(undefined, { type: DELETE_SHORT_URL_START } as any)).toEqual({
|
||||
shortCode: '',
|
||||
loading: true,
|
||||
error: false,
|
||||
}));
|
||||
|
||||
it('returns default on RESET_DELETE_SHORT_URL', () =>
|
||||
expect(reducer(undefined, { type: RESET_DELETE_SHORT_URL })).toEqual({
|
||||
expect(reducer(undefined, { type: RESET_DELETE_SHORT_URL } as any)).toEqual({
|
||||
shortCode: '',
|
||||
loading: false,
|
||||
error: false,
|
||||
}));
|
||||
|
||||
it('returns shortCode on SHORT_URL_DELETED', () =>
|
||||
expect(reducer(undefined, { type: SHORT_URL_DELETED, shortCode: 'foo' })).toEqual({
|
||||
expect(reducer(undefined, { type: SHORT_URL_DELETED, shortCode: 'foo' } as any)).toEqual({
|
||||
shortCode: 'foo',
|
||||
loading: false,
|
||||
error: false,
|
||||
|
@ -37,7 +36,7 @@ describe('shortUrlDeletionReducer', () => {
|
|||
it('returns errorData on DELETE_SHORT_URL_ERROR', () => {
|
||||
const errorData = Mock.of<ProblemDetailsError>({ type: 'bar' });
|
||||
|
||||
expect(reducer(undefined, { type: DELETE_SHORT_URL_ERROR, errorData })).toEqual({
|
||||
expect(reducer(undefined, { type: DELETE_SHORT_URL_ERROR, errorData } as any)).toEqual({
|
||||
shortCode: '',
|
||||
loading: false,
|
||||
error: true,
|
||||
|
@ -63,9 +62,9 @@ describe('shortUrlDeletionReducer', () => {
|
|||
it.each(
|
||||
[[ undefined ], [ null ], [ 'example.com' ]],
|
||||
)('dispatches proper actions if API client request succeeds', async (domain) => {
|
||||
const apiClientMock = {
|
||||
const apiClientMock = Mock.of<ShlinkApiClient>({
|
||||
deleteShortUrl: jest.fn(() => ''),
|
||||
};
|
||||
});
|
||||
const shortCode = 'abc123';
|
||||
|
||||
await deleteShortUrl(() => apiClientMock)(shortCode, domain)(dispatch, getState);
|
||||
|
@ -81,9 +80,9 @@ describe('shortUrlDeletionReducer', () => {
|
|||
it('dispatches proper actions if API client request fails', async () => {
|
||||
const data = { foo: 'bar' };
|
||||
const error = { response: { data } };
|
||||
const apiClientMock = {
|
||||
deleteShortUrl: jest.fn(() => Promise.reject(error)),
|
||||
};
|
||||
const apiClientMock = Mock.of<ShlinkApiClient>({
|
||||
deleteShortUrl: jest.fn(async () => Promise.reject(error)),
|
||||
});
|
||||
const shortCode = 'abc123';
|
||||
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue