mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 09:30:31 +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": {
|
"typescript": {
|
||||||
"version": "4.0.2",
|
"version": "3.9.7",
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.7.tgz",
|
||||||
"integrity": "sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ==",
|
"integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"uglify-es": {
|
"uglify-es": {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "npm run lint:js && npm run lint:css",
|
"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:js:fix": "npm run lint:js -- --fix",
|
||||||
"lint:css": "stylelint src/*.scss src/**/*.scss",
|
"lint:css": "stylelint src/*.scss src/**/*.scss",
|
||||||
"lint:css:fix": "npm run lint:css -- --fix",
|
"lint:css:fix": "npm run lint:css -- --fix",
|
||||||
|
@ -148,7 +148,7 @@
|
||||||
"terser-webpack-plugin": "^2.1.2",
|
"terser-webpack-plugin": "^2.1.2",
|
||||||
"ts-jest": "^26.0.0",
|
"ts-jest": "^26.0.0",
|
||||||
"ts-mockery": "^1.2.0",
|
"ts-mockery": "^1.2.0",
|
||||||
"typescript": "^4.0.2",
|
"typescript": "^3.9.7",
|
||||||
"url-loader": "^2.2.0",
|
"url-loader": "^2.2.0",
|
||||||
"webpack": "^4.41.0",
|
"webpack": "^4.41.0",
|
||||||
"webpack-dev-server": "^3.8.2",
|
"webpack-dev-server": "^3.8.2",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Action, Dispatch } from 'redux';
|
import { Action, Dispatch } from 'redux';
|
||||||
import { buildActionCreator, buildReducer } from '../../utils/helpers/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 { GetState } from '../../container/types';
|
||||||
import { ShlinkApiClientBuilder } from '../../utils/services/ShlinkApiClientBuilder';
|
import { ShlinkApiClientBuilder } from '../../utils/services/ShlinkApiClientBuilder';
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import React, { FC } from 'react';
|
import React, { FC } from 'react';
|
||||||
import { Modal, ModalBody } from 'reactstrap';
|
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 { prop } from 'ramda';
|
||||||
import { CityStats } from '../types';
|
import { CityStats } from '../types';
|
||||||
import './MapModal.scss';
|
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) {
|
if (locations.length === 0) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ export const getShortUrlVisits = (buildShlinkApiClient: ShlinkApiClientBuilder)
|
||||||
query: { domain?: OptionalString } = {},
|
query: { domain?: OptionalString } = {},
|
||||||
) => async (dispatch: Dispatch, getState: GetState) => {
|
) => async (dispatch: Dispatch, getState: GetState) => {
|
||||||
const { getShortUrlVisits } = buildShlinkApiClient(getState);
|
const { getShortUrlVisits } = buildShlinkApiClient(getState);
|
||||||
const visitsLoader = (page: number, itemsPerPage: number) => getShortUrlVisits(
|
const visitsLoader = async (page: number, itemsPerPage: number) => getShortUrlVisits(
|
||||||
shortCode,
|
shortCode,
|
||||||
{ ...query, page, itemsPerPage },
|
{ ...query, page, itemsPerPage },
|
||||||
);
|
);
|
||||||
|
|
|
@ -68,7 +68,10 @@ export const getTagVisits = (buildShlinkApiClient: ShlinkApiClientBuilder) => (t
|
||||||
getState: GetState,
|
getState: GetState,
|
||||||
) => {
|
) => {
|
||||||
const { getTagVisits } = buildShlinkApiClient(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 extraFinishActionData: Partial<TagVisitsAction> = { tag };
|
||||||
const actionMap = {
|
const actionMap = {
|
||||||
start: GET_TAG_VISITS_START,
|
start: GET_TAG_VISITS_START,
|
||||||
|
|
|
@ -8,27 +8,26 @@ import reducer, {
|
||||||
deleteShortUrl,
|
deleteShortUrl,
|
||||||
} from '../../../src/short-urls/reducers/shortUrlDeletion';
|
} from '../../../src/short-urls/reducers/shortUrlDeletion';
|
||||||
import { ProblemDetailsError } from '../../../src/utils/services/types';
|
import { ProblemDetailsError } from '../../../src/utils/services/types';
|
||||||
|
import ShlinkApiClient from '../../../src/utils/services/ShlinkApiClient';
|
||||||
|
|
||||||
describe('shortUrlDeletionReducer', () => {
|
describe('shortUrlDeletionReducer', () => {
|
||||||
describe('reducer', () => {
|
describe('reducer', () => {
|
||||||
|
|
||||||
|
|
||||||
it('returns loading on DELETE_SHORT_URL_START', () =>
|
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: '',
|
shortCode: '',
|
||||||
loading: true,
|
loading: true,
|
||||||
error: false,
|
error: false,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('returns default on RESET_DELETE_SHORT_URL', () =>
|
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: '',
|
shortCode: '',
|
||||||
loading: false,
|
loading: false,
|
||||||
error: false,
|
error: false,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('returns shortCode on SHORT_URL_DELETED', () =>
|
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',
|
shortCode: 'foo',
|
||||||
loading: false,
|
loading: false,
|
||||||
error: false,
|
error: false,
|
||||||
|
@ -37,7 +36,7 @@ describe('shortUrlDeletionReducer', () => {
|
||||||
it('returns errorData on DELETE_SHORT_URL_ERROR', () => {
|
it('returns errorData on DELETE_SHORT_URL_ERROR', () => {
|
||||||
const errorData = Mock.of<ProblemDetailsError>({ type: 'bar' });
|
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: '',
|
shortCode: '',
|
||||||
loading: false,
|
loading: false,
|
||||||
error: true,
|
error: true,
|
||||||
|
@ -63,9 +62,9 @@ describe('shortUrlDeletionReducer', () => {
|
||||||
it.each(
|
it.each(
|
||||||
[[ undefined ], [ null ], [ 'example.com' ]],
|
[[ undefined ], [ null ], [ 'example.com' ]],
|
||||||
)('dispatches proper actions if API client request succeeds', async (domain) => {
|
)('dispatches proper actions if API client request succeeds', async (domain) => {
|
||||||
const apiClientMock = {
|
const apiClientMock = Mock.of<ShlinkApiClient>({
|
||||||
deleteShortUrl: jest.fn(() => ''),
|
deleteShortUrl: jest.fn(() => ''),
|
||||||
};
|
});
|
||||||
const shortCode = 'abc123';
|
const shortCode = 'abc123';
|
||||||
|
|
||||||
await deleteShortUrl(() => apiClientMock)(shortCode, domain)(dispatch, getState);
|
await deleteShortUrl(() => apiClientMock)(shortCode, domain)(dispatch, getState);
|
||||||
|
@ -81,9 +80,9 @@ describe('shortUrlDeletionReducer', () => {
|
||||||
it('dispatches proper actions if API client request fails', async () => {
|
it('dispatches proper actions if API client request fails', async () => {
|
||||||
const data = { foo: 'bar' };
|
const data = { foo: 'bar' };
|
||||||
const error = { response: { data } };
|
const error = { response: { data } };
|
||||||
const apiClientMock = {
|
const apiClientMock = Mock.of<ShlinkApiClient>({
|
||||||
deleteShortUrl: jest.fn(() => Promise.reject(error)),
|
deleteShortUrl: jest.fn(async () => Promise.reject(error)),
|
||||||
};
|
});
|
||||||
const shortCode = 'abc123';
|
const shortCode = 'abc123';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue