1
0
mirror of https://github.com/SomboChea/ui synced 2026-01-17 16:45:49 +07:00

chore: migrate eslint@6.6.0 (#227)

* chore: migrate to eslint6

* chore: migrate to eslint6
This commit is contained in:
Juan Picado @jotadeveloper
2019-10-27 15:49:30 +01:00
committed by GitHub
parent 2a2784ba39
commit e6b53c0479
31 changed files with 409 additions and 196 deletions

View File

@@ -1,5 +1,3 @@
/* eslint-disable @typescript-eslint/no-object-literal-type-assertion */
import { handleResponseType } from '../../src/utils/api';
describe('api', () => {

View File

@@ -3,11 +3,17 @@ import { PackageMetaInterface } from '../../types/packageMeta';
import API from './api';
export async function callReadme(packageName: string, packageVersion?: string): Promise<string | {}> {
return await API.request<string | {}>(`package/readme/${packageName}${packageVersion ? `?v=${packageVersion}` : ''}`, 'GET');
return await API.request<string | {}>(
`package/readme/${packageName}${packageVersion ? `?v=${packageVersion}` : ''}`,
'GET'
);
}
export async function callDetailPage(packageName: string, packageVersion?: string): Promise<PackageMetaInterface | {}> {
const packageMeta = await API.request<PackageMetaInterface | {}>(`sidebar/${packageName}${packageVersion ? `?v=${packageVersion}` : ''}`, 'GET');
const packageMeta = await API.request<PackageMetaInterface | {}>(
`sidebar/${packageName}${packageVersion ? `?v=${packageVersion}` : ''}`,
'GET'
);
return packageMeta;
}

View File

@@ -1,6 +1,8 @@
import { SyntheticEvent } from 'react';
export const copyToClipBoardUtility = (str: string): ((e: SyntheticEvent<HTMLElement>) => void) => (event: SyntheticEvent<HTMLElement>): void => {
export const copyToClipBoardUtility = (str: string): ((e: SyntheticEvent<HTMLElement>) => void) => (
event: SyntheticEvent<HTMLElement>
): void => {
event.preventDefault();
const node = document.createElement('div');

View File

@@ -1,3 +1,13 @@
export default function fileSizeSI(a: number, b?: typeof Math, c?: (p: number) => number, d?: number, e?: number): string {
return ((b = Math), (c = b.log), (d = 1e3), (e = (c(a) / c(d)) | 0), a / b.pow(d, e)).toFixed(2) + ' ' + (e ? 'kMGTPEZY'[--e] + 'B' : 'Bytes');
export default function fileSizeSI(
a: number,
b?: typeof Math,
c?: (p: number) => number,
d?: number,
e?: number
): string {
return (
((b = Math), (c = b.log), (d = 1e3), (e = (c(a) / c(d)) | 0), a / b.pow(d, e)).toFixed(2) +
' ' +
(e ? 'kMGTPEZY'[--e] + 'B' : 'Bytes')
);
}

View File

@@ -40,7 +40,11 @@ describe('isTokenExpire', (): void => {
test('isTokenExpire - token is not a valid json token', (): void => {
const token = generateInvalidToken();
const result = ['Invalid token:', new SyntaxError('Unexpected token i in JSON at position 0'), 'xxxxxx.aW52YWxpZHRva2Vu.xxxxxx'];
const result = [
'Invalid token:',
new SyntaxError('Unexpected token i in JSON at position 0'),
'xxxxxx.aW52YWxpZHRva2Vu.xxxxxx',
];
expect(isTokenExpire(token)).toBeTruthy();
expect(console.error).toHaveBeenCalledWith(...result);
});
@@ -66,7 +70,7 @@ describe('makeLogin', (): void => {
test('makeLogin - should login successfully', async (): Promise<void> => {
const { username, password } = { username: 'sam', password: '1234' };
const result = { token: 'TEST_TOKEN', username: 'sam' };
const result = { token: 'TEST_TOKEN', username: 'sam' }; // pragma: allowlist secret
const login = await makeLogin(username, password);
expect(login).toEqual(result);
});

View File

@@ -1,6 +1,13 @@
import { packageMeta } from '../../jest/unit/components/store/packageMeta';
import { formatLicense, formatRepository, formatDate, formatDateDistance, getLastUpdatedPackageTime, getRecentReleases } from './package';
import {
formatLicense,
formatRepository,
formatDate,
formatDateDistance,
getLastUpdatedPackageTime,
getRecentReleases,
} from './package';
describe('formatLicense', (): void => {
test('should check license field different values', (): void => {